~gpanders/dotfiles

1d18f96dd59e589645684721515f68eba5ebec3c — Greg Anders 1 year, 11 months ago c420543
Prune vim configuration

- Remove configurations for plugins no longer in use
- Remove a few custom "plugins" that don't get used much/ever
27 files changed, 52 insertions(+), 1468 deletions(-)

M vim/.vim/after/ftplugin/cmake.vim
M vim/.vim/after/ftplugin/python.vim
D vim/.vim/after/ftplugin/xxd.vim
D vim/.vim/after/plugin/coc.vim
D vim/.vim/after/plugin/jedi.vim
D vim/.vim/after/plugin/sneak.vim
D vim/.vim/after/plugin/ultisnips.vim
D vim/.vim/autoload/easyterm.vim
D vim/.vim/autoload/ft/xxd.vim
D vim/.vim/autoload/indent_text_object.vim
D vim/.vim/autoload/jumphome.vim
M vim/.vim/autoload/scratch.vim
M vim/.vim/autoload/vim.vim
D vim/.vim/coc-settings.json
D vim/.vim/plugin/binary.vim
D vim/.vim/plugin/coc.vim
D vim/.vim/plugin/indent_text_object.vim
D vim/.vim/plugin/jumphome.vim
D vim/.vim/plugin/slime.vim
D vim/.vim/plugin/vimwiki/convert.py
D vim/.vim/plugin/vimwiki/vimwiki.vim
D vim/.vim/snips/cpp.snippets
D vim/.vim/snips/pyrex.snippets
D vim/.vim/snips/python.snippets
D vim/.vim/snips/sh.snippets
D vim/.vim/snips/vhdl.snippets
M vim/.vim/vimrc
M vim/.vim/after/ftplugin/cmake.vim => vim/.vim/after/ftplugin/cmake.vim +2 -0
@@ 1,2 1,4 @@
" CMake
setlocal commentstring=#%s

let b:undo_ftplugin .= '|setl cms<'

M vim/.vim/after/ftplugin/python.vim => vim/.vim/after/ftplugin/python.vim +0 -16
@@ 1,22 1,6 @@
" Python specific settings
let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')

" gz opens a split window with a python shell
if !exists('g:pyterm_cmd')
  for s:cmd in ['ipython', 'python3', 'python']
    if executable(s:cmd)
      let g:pyterm_cmd = s:cmd
      break
    endif
  endfor
  unlet s:cmd
endif

if exists('g:pyterm_cmd')
  nnoremap <silent> <buffer> gz :<C-U>call easyterm#open(g:pyterm_cmd)<CR>
  let b:undo_ftplugin .= '|nun <buffer> gz'
endif

" Set textwidth to 88 to mimic black
setlocal textwidth=88


D vim/.vim/after/ftplugin/xxd.vim => vim/.vim/after/ftplugin/xxd.vim +0 -42
@@ 1,42 0,0 @@
" xxd filetype
" Author: Greg Anders <greg@gpanders.com>
" Written: 24 Dec 2018

let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')

normal! 11|

" Number of bytes per line. xxd default is 16
let b:bytes_per_line = 16

setl cursorline cursorcolumn
let b:undo_ftplugin .= '|setl cul< cuc<'

" Remap h and l to move byte-wise
noremap <silent> <buffer> h :<C-U>call ft#xxd#byteleft()<CR>
noremap <silent> <buffer> l :<C-U>call ft#xxd#byteright()<CR>
noremap <silent> <buffer> e :<C-U>call ft#xxd#byteright()<CR>l
noremap <silent> <buffer> w :<C-U>call ft#xxd#wordright()<CR>
noremap <silent> <buffer> W :<C-U>call ft#xxd#wordright()<CR>
noremap <silent> <buffer> b :<C-U>call ft#xxd#wordleft()<CR>
noremap <silent> <buffer> B :<C-U>call ft#xxd#wordleft()<CR>
noremap <silent> <buffer> ge :<C-U>call ft#xxd#byteleft()<CR>h
noremap <silent> <buffer> 0 11<Bar>
noremap <silent> <buffer> ^ 11<Bar>

let b:undo_ftplugin .= '|nun <buffer> h'
      \ . '|nun <buffer> l'
      \ . '|nun <buffer> e'
      \ . '|nun <buffer> w'
      \ . '|nun <buffer> W'
      \ . '|nun <buffer> b'
      \ . '|nun <buffer> B'
      \ . '|nun <buffer> ge'
      \ . '|nun <buffer> 0'
      \ . '|nun <buffer> ^'

augroup xxd
  autocmd!
  autocmd InsertLeave,TextChanged <buffer> call ft#xxd#update()
augroup END
let b:undo_ftplugin .= '|au! xxd * <buffer>'

D vim/.vim/after/plugin/coc.vim => vim/.vim/after/plugin/coc.vim +0 -26
@@ 1,26 0,0 @@
" coc.nvim configuration
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-01-04

if !get(g:, 'did_coc_loaded') || !has('nvim')
  finish
endif

let g:coc_filetypes = ['c', 'cpp', 'rust']

augroup plugin.coc
  autocmd!
  autocmd FileType *
        \ if index(g:coc_filetypes, &ft) >= 0 |
        \   inoremap <buffer> <silent> <expr> <C-Space> coc#refresh() |
        \   nmap <silent> <buffer> gr <Plug>(coc-references) |
        \   nmap <silent> <buffer> gd <Plug>(coc-definition) |
        \   exec 'au! plugin.coc CursorHoldI,CursorMovedI <buffer> call CocAction("showSignatureHelp")' |
        \   let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')
        \     . '|setl fex<'
        \     . '|iun <buffer> <C-Space>'
        \     . '|nun <buffer> gr'
        \     . '|nun <buffer> gd'
        \     . '|exe "au! plugin.coc * <buffer>"' |
        \ endif
augroup END

D vim/.vim/after/plugin/jedi.vim => vim/.vim/after/plugin/jedi.vim +0 -11
@@ 1,11 0,0 @@
" jedi-vim configuration
" Author: Greg Anders <greg@gpanders.com>

if exists(':JediDebugInfo') != 2
  finish
endif

let g:jedi#goto_command = "<Bslash>d"
let g:jedi#goto_assignments_command = "<Bslash>a"
let g:jedi#usages_command = "<Bslash>u"
let g:jedi#rename_command = "<Bslash>r"

D vim/.vim/after/plugin/sneak.vim => vim/.vim/after/plugin/sneak.vim +0 -7
@@ 1,7 0,0 @@
" vim-sneak configuration
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-03

if !get(g:, 'loaded_sneak_plugin')
  finish
endif

D vim/.vim/after/plugin/ultisnips.vim => vim/.vim/after/plugin/ultisnips.vim +0 -12
@@ 1,12 0,0 @@
" ultisnips configuration
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-02-27

if !get(g:, 'did_plugin_ultisnips')
  finish
endif

let g:UltiSnipsEnableSnipMate = 0
let g:UltiSnipsEditSplit = 'tabdo'
let g:UltiSnipsSnippetsDir = $VIMHOME . '/snips'
let g:UltiSnipsSnippetDirectories = ['snips']

D vim/.vim/autoload/easyterm.vim => vim/.vim/autoload/easyterm.vim +0 -38
@@ 1,38 0,0 @@
" Re-use a terminal buffer window for the same command
" Author: Greg Anders

" Create a terminal buffer using `cmd` as the command to start and an optional
" name as the second argument. If this function is called again with the same
" `cmd` / `name` argument, re-open the existing buffer instead of creating
" another new buffer. This is useful for terminal buffers that should persist
" (e.g. REPLs)
function easyterm#open(cmd, ...)
  if a:0 && !empty(a:1)
    let name = a:1
  else
    let name = a:cmd
  endif

  let buf = filter(range(1, bufnr('$')),
        \ 'bufexists(v:val) && getbufvar(v:val, "' . name . '", 0)')
  let height = winheight(0) / 3
  if empty(buf)
    " No buffer yet, so start a new one
    if has('nvim')
      execute 'botright ' . height . 'sp | term ' . a:cmd
    else
      execute 'botright term ' . a:cmd
      execute 'resize ' . height
    endif
    let b:{name} = 1
  else
    " Buffer already exists
    let bufinfo = getbufinfo(buf[0])[0]
    if !bufinfo.hidden && !empty(bufinfo.windows)
      let winnum = win_id2win(bufinfo.windows[0])
      execute winnum 'wincmd w'
    else
      execute 'botright sb ' . bufinfo.bufnr . ' | resize ' . height
    endif
  endif
endfunction

D vim/.vim/autoload/ft/xxd.vim => vim/.vim/autoload/ft/xxd.vim +0 -71
@@ 1,71 0,0 @@
function! ft#xxd#update()
  " Update the ASCII representation of the data after modifying hex values
  let view = winsaveview()
  let [_, lnum, col, _, _] = getcurpos()
  let line = getline('.')
  let linelen = strlen(line)
  let asciicolstart = linelen - b:bytes_per_line
  if col > asciicolstart
    " ASCII section
    " Place cursor at first non-whitespace character
    call cursor(lnum, asciicolstart)
    let ascii = line[asciicolstart-1:linelen-1]
    for i in range(1, b:bytes_per_line)
      call searchpos('[A-Za-z0-9]\{2\}', 'b', lnum)
      let char = ascii[b:bytes_per_line-i]
      if char !=# '.'
        let nr = printf('%.2x', char2nr(char))
        execute "normal! R" . nr . "\<Esc>h"
      endif
    endfor
  else
    silent %!xxd -r
    silent %!xxd
  endif
  call winrestview(view)
endfunction!


function! ft#xxd#byteleft()
  let [_, lnum, col, _, _] = getcurpos()
  if col <= 11
    return
  elseif col > 11 && col <= 52
    call search('[A-Za-z0-9]\{2\}', 'b', lnum)
  else
    execute 'normal! h'
  endif
endfunction!

function! ft#xxd#byteright()
  let [_, lnum, col, _, _] = getcurpos()
  if col >= 11 && col < 48
    call search('[A-Za-z0-9]\{2\}', '', lnum)
  elseif col == 48
    execute 'normal! w'
  else
    execute 'normal! l'
  endif
endfunction!

function! ft#xxd#wordleft()
  let [_, lnum, col, _, _] = getcurpos()
  if col <= 11
    if lnum > 1
      execute 'normal! 0B'
    else
      return
    endif
  else
    execute 'normal! B'
  endif
endfunction

function! ft#xxd#wordright()
  let [_, lnum, col, _, _] = getcurpos()
  if col >= 52
    execute 'normal! 2W'
  else
    execute 'normal! W'
  endif
endfunction

D vim/.vim/autoload/indent_text_object.vim => vim/.vim/autoload/indent_text_object.vim +0 -125
@@ 1,125 0,0 @@
" Source: https://vimways.org/2018/transactions-pending/
function! indent_text_object#in()
	" select all text in current indentation level excluding any empty lines
	" that precede or follow the current indentationt level;
	"
	" the current implementation is pretty fast, even for many lines since it
	" uses "search()" with "\%v" to find the unindented levels
	"
	" NOTE: if the current level of indentation is 1 (ie in virtual column 1),
	"       then the entire buffer will be selected
	"
	" WARNING: python devs have been known to become addicted to this

	" magic is needed for this
	let l:magic = &magic
	set magic

	" move to beginning of line and get virtcol (current indentation level)
	" BRAM: there is no searchpairvirtpos() ;)
	normal! ^
	let l:vCol = virtcol(getline('.') =~# '^\s*$' ? '$' : '.')

	" pattern matching anything except empty lines and lines with recorded
	" indentation level
	let l:pat = '^\(\s*\%'.l:vCol.'v\|^$\)\@!'

	" find first match (backwards & don't wrap or move cursor)
	let l:start = search(l:pat, 'bWn') + 1

	" next, find first match (forwards & don't wrap or move cursor)
	let l:end = search(l:pat, 'Wn')

	if (l:end !=# 0)
		" if search succeeded, it went too far, so subtract 1
		let l:end -= 1
	endif

	" go to start (this includes empty lines) and--importantly--column 0
	execute 'normal! '.l:start.'G0'

	" skip empty lines (unless already on one .. need to be in column 0)
	call search('^[^\n\r]', 'Wc')

	" go to end (this includes empty lines)
	execute 'normal! Vo'.l:end.'G'

	" skip backwards to last selected non-empty line
	call search('^[^\n\r]', 'bWc')

	" go to end-of-line 'cause why not
	normal! $o

	" restore magic
	let &magic = l:magic
endfunction

function! indent_text_object#around()
	" select all text in the current indentation level including any emtpy
	" lines that precede or follow the current indentation level;
	"
	" the current implementation is pretty fast, even for many lines since it
	" uses "search()" with "\%v" to find the unindented levels
	"
	" NOTE: if the current level of indentation is 1 (ie in virtual column 1),
	"       then the entire buffer will be selected
	"
	" WARNING: python devs have been known to become addicted to this

	" magic is needed for this (/\v doesn't seem work)
	let l:magic = &magic
	set magic

	" move to beginning of line and get virtcol (current indentation level)
	" BRAM: there is no searchpairvirtpos() ;)
	normal! ^
	let l:vCol = virtcol(getline('.') =~# '^\s*$' ? '$' : '.')

	" pattern matching anything except empty lines and lines with recorded
	" indentation level
	let l:pat = '^\(\s*\%'.l:vCol.'v\|^$\)\@!'

	" find first match (backwards & don't wrap or move cursor)
	let l:start = search(l:pat, 'bWn') + 1

	" NOTE: if l:start is 0, then search() failed; otherwise search() succeeded
	"       and l:start does not equal line('.')
	" FORMER: l:start is 0; so, if we add 1 to l:start, then it will match
	"         everything from beginning of the buffer (if you don't like
	"         this, then you can modify the code) since this will be the
	"         equivalent of "norm! 1G" below
	" LATTER: l:start is not 0 but is also not equal to line('.'); therefore,
	"         we want to add one to l:start since it will always match one
	"         line too high if search() succeeds

	" next, find first match (forwards & don't wrap or move cursor)
	let l:end = search(l:pat, 'Wn')

	" NOTE: if l:end is 0, then search() failed; otherwise, if l:end is not
	"       equal to line('.'), then the search succeeded.
	" FORMER: l:end is 0; we want this to match until the end-of-buffer if it
	"         fails to find a match for same reason as mentioned above;
	"         again, modify code if you do not like this); therefore, keep
	"         0--see "NOTE:" below inside the if block comment
	" LATTER: l:end is not 0, so the search() must have succeeded, which means
	"         that l:end will match a different line than line('.')

	if (l:end !=# 0)
		" if l:end is 0, then the search() failed; if we subtract 1, then it
		" will effectively do "norm! -1G" which is definitely not what is
		" desired for probably every circumstance; therefore, only subtract one
		" if the search() succeeded since this means that it will match at least
		" one line too far down
		" NOTE: exec "norm! 0G" still goes to end-of-buffer just like "norm! G",
		"       so it's ok if l:end is kept as 0. As mentioned above, this means
		"       that it will match until end of buffer, but that is what I want
		"       anyway (change code if you don't want)
		let l:end -= 1
	endif

	" finally, select from l:start to l:end
	execute 'normal! '.l:start.'G0V'.l:end.'G$o'

	" restore magic
	let &magic = l:magic
endfunction

D vim/.vim/autoload/jumphome.vim => vim/.vim/autoload/jumphome.vim +0 -10
@@ 1,10 0,0 @@
" The argument `str' is the text to replace with. This should be the same as
" whatever the mapping is (is there a way to do this automatically)?
function! jumphome#jump(str)
  let cmdline = getcmdline()
  if match(cmdline[0:1], '\(e[ d]\|sp\|vs\)') == 0
    call feedkeys("\<C-\>e'" . split(cmdline)[0] . " " . a:str . "'\<CR>")
  else
    return a:str
  endif
endfunction

M vim/.vim/autoload/scratch.vim => vim/.vim/autoload/scratch.vim +1 -3
@@ 4,9 4,7 @@ function! scratch#open(command, ...)
  put =lines
  let b:lines = lines
  nnoremap <silent> <buffer> q <C-W>q
  nnoremap <silent> <buffer> R :%d_<Bar>pu =b:lines<Bar>%g/^\s*$/d<Bar>0<CR>
  nnoremap <silent> <buffer> <CR> gf<C-W>o
  if a:0 > 0
  if a:0
    execute 'vglobal/' . a:1 . '/delete'
  endif
  silent %substitute/\%^\_s*\n\|\_s*\%$

M vim/.vim/autoload/vim.vim => vim/.vim/autoload/vim.vim +25 -16
@@ 1,21 1,30 @@
let s:cachedir = ''
let s:datadir = ''

function! vim#cachedir()
  let n = has('nvim') ? 'n' : ''
  if exists('$XDG_CACHE_HOME')
    return $XDG_CACHE_HOME . '/' . n . 'vim'
  elseif has('unix')
    return $HOME . '/.cache/' . n . 'vim'
  else
    return . '/vimfiles/cache'
  endif
    if empty(s:cachedir)
        let n = has('nvim') ? 'n' : ''
        if exists('$XDG_CACHE_HOME')
            let s:cachedir = $XDG_CACHE_HOME . '/' . n . 'vim'
        elseif has('unix')
            let s:cachedir = $HOME . '/.cache/' . n . 'vim'
        else
            let s:cachedir = $HOME . '/vimfiles/cache'
        endif
    endif
    return s:cachedir
endfunction

function! vim#datadir()
  let n = has('nvim') ? 'n' : ''
  if exists('$XDG_DATA_HOME')
    return $XDG_DATA_HOME . '/' . n . 'vim'
  elseif has('unix')
    return $HOME . '/.local/share/' . n . 'vim'
  else
    return . '/vimfiles/cache'
  endif
    if empty(s:datadir)
        let n = has('nvim') ? 'n' : ''
        if exists('$XDG_DATA_HOME')
            let s:datadir = $XDG_DATA_HOME . '/' . n . 'vim'
        elseif has('unix')
            let s:datadir = $HOME . '/.local/share/' . n . 'vim'
        else
            let s:datadir = $HOME . '/vimfiles/cache'
        endif
    endif
    return s:datadir
endfunction

D vim/.vim/coc-settings.json => vim/.vim/coc-settings.json +0 -15
@@ 1,15 0,0 @@
{
  "coc.preferences.diagnostic.displayByAle": true,
  "languageserver": {
    "cquery": {
      "command": "cquery",
      "args": ["--log-file=/tmp/cquery/cquery.log"],
      "revealOutputChannelOn": "never",
      "filetypes": ["c", "cpp"],
      "rootPatterns": ["compile_commands.json", ".git/"],
      "initializationOptions": {
        "cacheDirectory": "/tmp/cquery/cache"
      }
    }
  }
}

D vim/.vim/plugin/binary.vim => vim/.vim/plugin/binary.vim +0 -16
@@ 1,16 0,0 @@
" Improved editing of binary files
" This makes vim a slightly more tolerable hex editor, although there are
" still better options out there
" Most of the magic happens in the xxd filetype plugin, not here
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-24

augroup plugin.binary
  autocmd!
  autocmd BufReadPost  * if &bin | exe '%!xxd' | set ft=xxd | endif
  autocmd BufWritePre  * if &bin | exe '%!xxd -r' | endif
  autocmd BufWritePost * if &bin | exe '%!xxd' | set nomod | endif
augroup END

" Delete the augroup if not in binary mode
au VimEnter * if !&binary | exe 'au! plugin.binary' | endif

D vim/.vim/plugin/coc.vim => vim/.vim/plugin/coc.vim +0 -11
@@ 1,11 0,0 @@
" coc configuration
" This file is executed BEFORE coc.nvim is loaded
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-02-25

" Only load coc when using nvim
if !has('nvim')
  finish
endif

silent! packadd coc.nvim

D vim/.vim/plugin/indent_text_object.vim => vim/.vim/plugin/indent_text_object.vim +0 -5
@@ 1,5 0,0 @@
" Source: https://vimways.org/2018/transactions-pending/
xnoremap <silent> ii :<C-U>call indent_text_object#in()<CR>
onoremap <silent> ii :<C-U>call indent_text_object#in()<CR>
xnoremap <silent> ai :<C-U>call indent_text_object#around()<CR>
onoremap <silent> ai :<C-U>call indent_text_object#around()<CR>

D vim/.vim/plugin/jumphome.vim => vim/.vim/plugin/jumphome.vim +0 -12
@@ 1,12 0,0 @@
" Easily jump to home directory on the command line
" When using any of the edit commands (:edit, :sp, :vs), typing ~/ anywhere in
" the file path will immediately change the path to the user's home directory
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-03-05

if exists('g:loaded_jumphome')
  finish
endif
let g:loaded_jumphome = 1

cnoremap <expr> ~/ jumphome#jump('~/')

D vim/.vim/plugin/slime.vim => vim/.vim/plugin/slime.vim +0 -23
@@ 1,23 0,0 @@
" Configuration for vim-slime
" This file is executed BEFORE vim-slime is loaded
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-19

let s:cpo_save = &cpo
set cpo&vim

if exists("$TMUX")
  let g:slime_target = "tmux"
  let g:slime_paste_file = tempname()
  let g:slime_default_config = {
        \ "socket_name": split($TMUX, ",")[0],
        \ "target_pane": "{right-of}"
        \ }
elseif has('nvim')
  let g:slime_target = "neovim"
else
  let g:slime_target = "vimterminal"
endif

let &cpo = s:cpo_save
unlet s:cpo_save

D vim/.vim/plugin/vimwiki/convert.py => vim/.vim/plugin/vimwiki/convert.py +0 -119
@@ 1,119 0,0 @@
#!/usr/bin/env python3

import re
import shutil
import subprocess
import sys
import tempfile
from os import path
from urllib.parse import urlparse


def convert(
    force,
    syntax,
    extension,
    output_dir,
    input_file,
    css_file,
    template_path,
    template_default,
    template_ext,
    root_path,
    custom_args,
):
    if shutil.which("pandoc") is None:
        print("Error: pandoc not found", file=sys.stderr)
        sys.exit(1)

    if syntax != "markdown":
        print("Error: Unsupported syntax", file=sys.stderr)
        sys.exit(1)

    input_file_name = path.splitext(path.basename(input_file))[0]
    output_file = path.join(output_dir, input_file_name) + path.extsep + "html"

    with open(input_file, "r", encoding="utf8") as f:
        lines = re.sub(r"\[([^]]+)\]\((.+)\)", repl, f.read())

    # Extract page title from text, if possible. Otherwise just use the name of
    # the input file
    title = extract_title(lines) or input_file_name.title()

    # Build path to template file
    template = path.join(template_path, template_default + path.extsep + template_ext)

    # Build the command string
    command = [
        "pandoc",
        "--section-divs",
        "--template={}".format(template) if path.isfile(template) else "",
        "--standalone",
        "--katex",
        "--metadata",
        "pagetitle={}".format(title),
        custom_args if custom_args != "-" else "",
        "--from=markdown",
        "--to=html",
        "--output",
        output_file,
        "-",
    ]

    # Prune empty elements from command list
    command = list(filter(None, command))

    # Run command
    subprocess.run(command, check=True, encoding="utf8", input=lines)


def repl(match):
    link = match.group(2)
    url = urlparse(link)
    if not url.scheme and not url.netloc:
        # Link is not a URL
        basename, ext = path.splitext(match.group(2))
        if not ext or ext.lower() == "md":
            # Link is (probably) a path to another Vimwiki file
            link = basename + path.extsep + "html"
    return "[{}]({})".format(match.group(1), link)


def extract_title(text):
    """Try to extract the page title from metadata in the file contents. The
    file metadata can be in YAML form such as

    ---
    title: My title
    ---

    anywhere in the file or

    % title

    or

    % Multi-line
      title

    or

    # title

    at the beginning. All of these caveats are why the following regex is so
    complicated.
    """
    match = re.match(
        r"(?:^% (.+?)\n^[^ ]|"
        r"\n*^# ([^\n]+)$|"
        r"(?:.*^\s*\n|)^-{3}\ntitle: ([^\n]+)\n.*^(?:-{3}|\.{3})$)",
        text,
        re.MULTILINE | re.DOTALL,
    )

    if match:
        return match.group(1) or match.group(2) or match.group(3)


if __name__ == "__main__":
    convert(*sys.argv[1:])

D vim/.vim/plugin/vimwiki/vimwiki.vim => vim/.vim/plugin/vimwiki/vimwiki.vim +0 -54
@@ 1,54 0,0 @@
" vimwiki configuration
" This file is executed BEFORE vimwiki is loaded
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-03-12

let s:cpo_save = &cpo
set cpo&vim

" Machine specific wiki paths
" This file should be located at ~/.vim/wikis.vim (or ~/vimfiles/wikis.vim on
" Windows)
runtime wikis.vim

let g:vimwiki_global_ext = 0
let g:vimwiki_hl_headers = 0
let g:vimwiki_dir_link = 'index'
let g:vimwiki_conceal_pre = 1

" Extend wikis with default values
if !empty(get(g:, 'vimwiki_list', []))
  function! s:extend(wiki)
    if get(a:wiki, 'syntax') ==# 'markdown'
      " Settings for markdown wikis
      call extend(a:wiki, {
            \ 'ext': '.md',
            \ 'custom_wiki2html': $VIMHOME . '/plugin/vimwiki/convert.py',
            \ 'custom_wiki2html_args':
            \   get(g:, 'vimwiki_html_header_numbering') ? '-N' : '',
            \ 'list_margin': 0,
            \ }, 'keep')
    else
      " Settings for wiki-style wikis
      call extend(a:wiki, {
            \ 'auto_toc': 1,
            \ }, 'keep')
    endif

    " Settings for all wikis
    call extend(a:wiki, {
          \ 'path_html': simplify(a:wiki.path . '/html'),
          \ 'template_path': $HOME . '/.config/pandoc/templates/',
          \ 'template_ext': 'html',
          \ 'template_default': 'default',
          \ 'links_space_char': '_',
          \ }, 'keep')

    return a:wiki
  endfunction

  call map(filter(g:vimwiki_list, '!empty(v:val.path)'), 's:extend(v:val)')
endif

let &cpo = s:cpo_save
unlet s:cpo_save

D vim/.vim/snips/cpp.snippets => vim/.vim/snips/cpp.snippets +0 -5
@@ 1,5 0,0 @@
extends c

snippet cout "Print to console" b
std::cout << ${1:${VISUAL}} << std::endl;
endsnippet

D vim/.vim/snips/pyrex.snippets => vim/.vim/snips/pyrex.snippets +0 -1
@@ 1,1 0,0 @@
extends python

D vim/.vim/snips/python.snippets => vim/.vim/snips/python.snippets +0 -718
@@ 1,718 0,0 @@
priority -50

###########################################################################
#                            TEXTMATE SNIPPETS                            #
###########################################################################

#! header
snippet #! "Shebang header for python scripts" b
#!/usr/bin/env python
# -*- coding: utf-8 -*-
$0
endsnippet

snippet ifmain "ifmain" b
if __name__ == `!p snip.rv = get_quoting_style(snip)`__main__`!p snip.rv = get_quoting_style(snip)`:
	${1:${VISUAL:main()}}
endsnippet

snippet with "with" b
with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}:
	${3:${VISUAL:pass}}
$0
endsnippet

snippet for "for loop" b
for ${1:item} in ${2:iterable}:
	${3:${VISUAL:pass}}
endsnippet

snippet pdb "Insert breakpoint" b
import pdb; pdb.set_trace()
endsnippet

##########
# COMMON #
##########

# The smart def and smart class snippets use a global option called
# "g:ultisnips_python_style" which, if set to "doxygen" will use doxygen
# style comments in docstrings.

global !p

NORMAL  = 0x1
DOXYGEN = 0x2
SPHINX  = 0x3
GOOGLE  = 0x4
NUMPY   = 0x5
JEDI    = 0x6

SINGLE_QUOTES = "'"
DOUBLE_QUOTES = '"'


class Arg(object):
	def __init__(self, arg):
		self.arg = arg
		self.name = arg.split('=')[0].strip()

	def __str__(self):
		return self.name

	def __unicode__(self):
		return self.name

	def is_kwarg(self):
		return '=' in self.arg


def get_args(arglist):
	args = [Arg(arg) for arg in arglist.split(',') if arg]
	args = [arg for arg in args if arg.name != 'self']

	return args


def get_quoting_style(snip):
	style = snip.opt("g:ultisnips_python_quoting_style", "double")
	if style == 'single':
		return SINGLE_QUOTES
	return DOUBLE_QUOTES

def triple_quotes(snip):
	style = snip.opt("g:ultisnips_python_triple_quoting_style")
	if not style:
		return get_quoting_style(snip) * 3
	return (SINGLE_QUOTES if style == 'single' else DOUBLE_QUOTES) * 3

def triple_quotes_handle_trailing(snip, quoting_style):
	"""
	Generate triple quoted strings and handle any trailing quote char,
	which might be there from some autoclose/autopair plugin,
	i.e. when expanding ``"|"``.
	"""
	if not snip.c:
		# Do this only once, otherwise the following error would happen:
		# RuntimeError: The snippets content did not converge: …
		_, col = vim.current.window.cursor
		line = vim.current.line

		# Handle already existing quote chars after the trigger.
		_ret = quoting_style * 3
		while True:
			try:
				nextc = line[col]
			except IndexError:
				break
			if nextc == quoting_style and len(_ret):
				_ret = _ret[1:]
				col = col+1
			else:
				break
		snip.rv = _ret
	else:
		snip.rv = snip.c

def get_style(snip):
	style = snip.opt("g:ultisnips_python_style", "normal")

	if    style == "doxygen": return DOXYGEN
	elif  style == "sphinx": return SPHINX
	elif  style == "google": return GOOGLE
	elif  style == "numpy": return NUMPY
	elif  style == "jedi": return JEDI
	else: return NORMAL


def format_arg(arg, style):
	if style == DOXYGEN:
		return "@param %s TODO" % arg
	elif style == SPHINX:
		return ":param %s: TODO" % arg
	elif style == NORMAL:
		return ":%s: TODO" % arg
	elif style == GOOGLE:
		return "%s (TODO): TODO" % arg
	elif style == JEDI:
		return ":type %s: TODO" % arg
	elif style == NUMPY:
		return "%s : TODO" % arg


def format_return(style):
	if style == DOXYGEN:
		return "@return: TODO"
	elif style in (NORMAL, SPHINX, JEDI):
		return ":returns: TODO"
	elif style == GOOGLE:
		return "Returns: TODO"


def write_docstring_args(args, snip):
	if not args:
		snip.rv += ' {0}'.format(triple_quotes(snip))
		return

	snip.rv += '\n' + snip.mkline('', indent='')

	style = get_style(snip)

	if style == GOOGLE:
		write_google_docstring_args(args, snip)
	elif style == NUMPY:
		write_numpy_docstring_args(args, snip)
	else:
		for arg in args:
			snip += format_arg(arg, style)


def write_google_docstring_args(args, snip):
	kwargs = [arg for arg in args if arg.is_kwarg()]
	args = [arg for arg in args if not arg.is_kwarg()]

	if args:
		snip += "Args:"
		snip.shift()
		for arg in args:
			snip += format_arg(arg, GOOGLE)
		snip.unshift()
		snip.rv += '\n' + snip.mkline('', indent='')

	if kwargs:
		snip += "Kwargs:"
		snip.shift()
		for kwarg in kwargs:
			snip += format_arg(kwarg, GOOGLE)
		snip.unshift()
		snip.rv += '\n' + snip.mkline('', indent='')


def write_numpy_docstring_args(args, snip):
	if args:
		snip += "Parameters"
		snip += "----------"

	kwargs = [arg for arg in args if arg.is_kwarg()]
	args = [arg for arg in args if not arg.is_kwarg()]

	if args:
		for arg in args:
			snip += format_arg(arg, NUMPY)
	if kwargs:
		for kwarg in kwargs:
			snip += format_arg(kwarg, NUMPY) + ', optional'
	snip.rv += '\n' + snip.mkline('', indent='')


def write_init_body(args, parents, snip):
	parents = [p.strip() for p in parents.split(",")]
	parents = [p for p in parents if p != 'object']

	for p in parents:
		snip += p + ".__init__(self)"

	if parents:
		snip.rv += '\n' + snip.mkline('', indent='')

	for arg in args:
		snip += "self._%s = %s" % (arg, arg)


def write_slots_args(args, snip):
	quote = get_quoting_style(snip)
	arg_format = quote + '_%s' + quote
	args = [arg_format % arg for arg in args]
	snip += '__slots__ = (%s,)' % ', '.join(args)


def write_function_docstring(t, snip):
	"""
	Writes a function docstring with the current style.

	:param t: The values of the placeholders
	:param snip: UltiSnips.TextObjects.SnippetUtil object instance
	"""
	snip.rv = ""
	snip >> 1

	args = get_args(t[2])
	if args:
		write_docstring_args(args, snip)

	style = get_style(snip)

	if style == NUMPY:
		snip += 'Returns'
		snip += '-------'
		snip += 'TODO'
	else:
		snip += format_return(style)
	snip.rv += '\n' + snip.mkline('', indent='')
	snip += triple_quotes(snip)

def get_dir_and_file_name(snip):
	return os.getcwd().split(os.sep)[-1] + '.' + snip.basename

endglobal

########################################
# Class & Special Method Name Snippets #
########################################

snippet class "class with docstrings" b
class ${1:MyClass}(${2:object}):

	`!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`

	def __init__(self$4):
		`!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined1.}`!p
snip.rv = ""
snip >> 2

args = get_args(t[4])

write_docstring_args(args, snip)
if args:
	snip.rv += '\n' + snip.mkline('', indent='')
	snip += '{0}'.format(triple_quotes(snip))

write_init_body(args, t[2], snip)
`
		$0
endsnippet


snippet slotclass "class with slots and docstrings" b
class ${1:MyClass}(${2:object}):

	`!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`
`!p
snip >> 1
args = get_args(t[4])
write_slots_args(args, snip)
`

	def __init__(self$4):
		`!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined.}`!p
snip.rv = ""
snip >> 2

args = get_args(t[4])

write_docstring_args(args, snip)
if args:
	snip.rv += '\n' + snip.mkline('', indent='')
	snip += triple_quotes(snip)

write_init_body(args, t[2], snip)
`
		$0
endsnippet


snippet contain "methods for emulating a container type" b
def __len__(self):
	${1:pass}

def __getitem__(self, key):
	${2:pass}

def __setitem__(self, key, value):
	${3:pass}

def __delitem__(self, key):
	${4:pass}

def __iter__(self):
	${5:pass}

def __reversed__(self):
	${6:pass}

def __contains__(self, item):
	${7:pass}
endsnippet


snippet context "context manager methods" b
def __enter__(self):
	${1:pass}

def __exit__(self, exc_type, exc_value, traceback):
	${2:pass}
endsnippet


snippet attr "methods for customizing attribute access" b
def __getattr__(self, name):
	${1:pass}

def __setattr__(self, name, value):
	${2:pass}

def __delattr__(self, name):
	${3:pass}
endsnippet


snippet desc "methods implementing descriptors" b
def __get__(self, instance, owner):
	${1:pass}

def __set__(self, instance, value):
	${2:pass}

def __delete__(self, instance):
	${3:pass}
endsnippet


snippet cmp "methods implementing rich comparison"
def __eq__(self, other):
	${1:pass}

def __ne__(self, other):
	${2:pass}

def __lt__(self, other):
	${3:pass}

def __le__(self, other):
	${4:pass}

def __gt__(self, other):
	${5:pass}

def __ge__(self, other):
	${6:pass}

def __cmp__(self, other):
	${7:pass}
endsnippet


snippet repr "methods implementing string representation"
def __repr__(self):
	${1:pass}

def __str__(self):
	${2:pass}

def __unicode__(self):
	${3:pass}
endsnippet


# note: reflected operands and augmented arithmeitc assignements have been
# intentionally ommited to reduce verbosity.
snippet numeric "methods for emulating a numeric type" b
def __add__(self, other):
	${1:pass}

def __sub__(self, other):
	${2:pass}

def __mul__(self, other):
	${3:pass}

def __div__(self, other):
	${4:pass}

def __truediv__(self, other):
	${5:pass}

def __floordiv__(self, other):
	${6:pass}


def __mod__(self, other):
	${7:pass}

def __divmod__(self, other):
	${8:pass}

def __pow__(self, other):
	${9:pass}


def __lshift__(self, other):
	${10:pass}

def __rshift__(self, other):
	${11:pass}

def __and__(self, other):
	${12:pass}

def __xor__(self, other):
	${13:pass}

def __or__(self, other):
	${14:pass}


def __neg__(self):
	${15:pass}

def __pos__(self):
	${16:pass}

def __abs__(self):
	${17:pass}

def __invert__(self):
	${18:pass}


def __complex__(self):
	${19:pass}

def __int__(self):
	${20:pass}

def __long__(self):
	${21:pass}

def __float__(self):
	${22:pass}


def __oct__(self):
	${22:pass}

def __hex__(self):
	${23:pass}


def __index__(self):
	${24:pass}

def __coerce__(self, other):
	${25:pass}
endsnippet

snippet deff
def ${1:fname}(`!p snip.rv = vim.eval('indent(".") ? "self" : ""')`$2):
	$0
endsnippet

snippet def "function with docstrings" b
def ${1:function}(`!p
if snip.indent:
	snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}):
	`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
write_function_docstring(t, snip) `
	${5:${VISUAL:pass}}
endsnippet


snippet defc "class method with docstrings" b
@classmethod
def ${1:function}(`!p
if snip.indent:
	snip.rv = 'cls' + (", " if len(t[2]) else "")`${2:arg1}):
	`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
write_function_docstring(t, snip) `
	${5:${VISUAL:pass}}
endsnippet


snippet defs "static method with docstrings" b
@staticmethod
def ${1:function}(${2:arg1}):
	`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
write_function_docstring(t, snip) `
	${5:${VISUAL:pass}}
endsnippet


# doesn't expand when there is a word in front
snippet /(^|(?<=\W))\./ "self." r
self.
endsnippet

snippet from "from module import name" b
from ${1:module} import ${2:Stuff}
endsnippet


##############
# PROPERTIES #
##############
snippet roprop "Read Only Property" b
@property
def ${1:name}(self):
	${2:return self._$1}$0
endsnippet

snippet rwprop "Read write property" b
def ${1:name}():
	`!p snip.rv = triple_quotes(snip) if t[2] else ''
`${2:TODO: Docstring for $1.}`!p
if t[2]:
	snip >> 1

	style = get_style(snip)
	snip.rv += '\n' + snip.mkline('', indent='')
	snip += format_return(style)
	snip.rv += '\n' + snip.mkline('', indent='')
	snip += triple_quotes(snip)
else:
	snip.rv = ""`
	def fget(self):
		return self._$1$0

	def fset(self, value):
		self._$1 = value
	return locals()

$1 = property(**$1(), doc=$1.__doc__)
endsnippet


####################
# If / Else / Elif #
####################
snippet if "If" b
if ${1:condition}:
	${2:${VISUAL:pass}}
endsnippet

snippet ife "If / Else" b
if ${1:condition}:
	${2:${VISUAL:pass}}
else:
	${3:pass}
endsnippet

snippet ifee "If / Elif / Else" b
if ${1:condition}:
	${2:${VISUAL:pass}}
elif ${3:condition}:
	${4:pass}
else:
	${5:pass}
endsnippet


##########################
# Try / Except / Finally #
##########################
snippet try "Try / Except" b
try:
	${1:${VISUAL:pass}}
except ${2:Exception} as ${3:e}:
	${4:raise $3}
endsnippet

snippet trye "Try / Except / Else" b
try:
	${1:${VISUAL:pass}}
except ${2:Exception} as ${3:e}:
	${4:raise $3}
else:
	${5:pass}
endsnippet

snippet tryf "Try / Except / Finally" b
try:
	${1:${VISUAL:pass}}
except ${2:Exception} as ${3:e}:
	${4:raise $3}
finally:
	${5:pass}
endsnippet

snippet tryef "Try / Except / Else / Finally" b
try:
	${1:${VISUAL:pass}}
except${2: ${3:Exception} as ${4:e}}:
	${5:raise}
else:
	${6:pass}
finally:
	${7:pass}
endsnippet


######################
# Assertions & Tests #
######################

snippet ae "Assert equal" b
self.assertEqual(${1:${VISUAL:first}}, ${2:second})
endsnippet

snippet at "Assert True" b
self.assertTrue(${1:${VISUAL:expression}})
endsnippet

snippet af "Assert False" b
self.assertFalse(${1:${VISUAL:expression}})
endsnippet

snippet aae "Assert almost equal" b
self.assertAlmostEqual(${1:${VISUAL:first}}, ${2:second})
endsnippet

snippet ar "Assert raises" b
self.assertRaises(${1:exception}, ${2:${VISUAL:func}}${3/.+/, /}${3:arguments})
endsnippet

snippet an "Assert is None" b
self.assertIsNone(${1:${VISUAL:expression}})
endsnippet

snippet ann "Assert is not None" b
self.assertIsNotNone(${1:${VISUAL:expression}})
endsnippet

snippet testcase "pyunit testcase" b
class Test${1:Class}(${2:unittest.TestCase}):

	`!p snip.rv = triple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = triple_quotes(snip)`

	def setUp(self):
		${4:pass}

	def tearDown(self):
		${5:pass}

	def test_${6:name}(self):
		${7:${VISUAL:pass}}
endsnippet

snippet " "triple quoted string (double quotes)" b
"""
${1:${VISUAL:doc}}
`!p triple_quotes_handle_trailing(snip, '"')`
endsnippet

snippet ' "triple quoted string (single quotes)" b
'''
${1:${VISUAL:doc}}
`!p triple_quotes_handle_trailing(snip, "'")`
endsnippet

snippet doc "doc block (triple quotes)"
`!p snip.rv = triple_quotes(snip)`
${1:${VISUAL:doc}}
`!p snip.rv = triple_quotes(snip)`
endsnippet

snippet pmdoc "pocoo style module doc string" b
# -*- coding: utf-8 -*-
"""
	`!p snip.rv = get_dir_and_file_name(snip)`
	`!p snip.rv = '~' * len(get_dir_and_file_name(snip))`

	${1:DESCRIPTION}

	:copyright: (c) `date +%Y` by ${2:YOUR_NAME}.
	:license: ${3:LICENSE_NAME}, see LICENSE for more details.
"""
$0
endsnippet

# vim:ft=snippets:

D vim/.vim/snips/sh.snippets => vim/.vim/snips/sh.snippets +0 -36
@@ 1,36 0,0 @@
global !p
import re

def create_options_case_body(t, snip):
	snip.rv = ""
	snip >> 2
	opts = re.findall(r"[A-Za-z]:{0,2}", t[1])
	for opt in opts:
		snip.rv += snip.mkline("-" + opt[0] + ")")
		snip >> 1
		if len(opt) > 1:
			snip += "PARAM_" + str.upper(opt[0]) + "=\"$2\""
			snip += "shift 2"
		else:
			snip += "shift"
		snip += ";;"
		snip << 1
		snip.rv += "\n"

endglobal

snippet opts "Command line option parser" b
OPTS="$(getopt -- "${1:a:bc}" "$@")"

eval set -- "$OPTS"

while true; do
	case \$1 in
`!p create_options_case_body(t, snip)`
		--)
			shift
			break
			;;
	esac
done
endsnippet

D vim/.vim/snips/vhdl.snippets => vim/.vim/snips/vhdl.snippets +0 -3
@@ 1,3 0,0 @@
snippet debug "Mark a signal for debug"
attribute MARK_DEBUG of ${VISUAL:1} : signal is "true";
endsnippet

M vim/.vim/vimrc => vim/.vim/vimrc +24 -73
@@ 46,6 46,21 @@ if !has('nvim')
  let &t_SR = "\e[4 q"
  " Block in normal mode
  let &t_EI = "\e[2 q"

  let s:datadir = vim#datadir()
  let &backupdir = s:datadir . '/backup//' . ',' . &backupdir
  let &undodir = s:datadir . '/undo//' . ',' . &undodir
  let &directory = s:datadir . '/swap//' . ',' . &directory

  " Create directories if they don't exist
  if exists('*mkdir')
    for opt in [&backupdir, &undodir, &directory]
      let dir = simplify(split(opt, ',')[0])
      if !isdirectory(dir)
        call mkdir(dir, 'p')
      endif
    endfor
  endif
endif
" }}}



@@ 94,8 109,6 @@ highlight link TrailingWhitespace Error
" }}}

" Settings {{{
set backup
set completeopt^=menuone
set confirm
set cursorline
set expandtab


@@ 113,9 126,6 @@ set showmatch
set sidescrolloff=5
set smartcase
set softtabstop=4
set splitbelow
set splitright
set nostartofline
set noswapfile
silent! set tagcase=match
set tags^=./.git/tags;


@@ 168,50 178,18 @@ setglobal isfname+=@-@
set grepformat^=%f:%l:%c:%m
if executable('rg')
  " Use rg over grep
  set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --glob\ '!.git'
  set grepprg=rg\ --vimgrep\ --smart-case
elseif executable('ag')
  " Use ag over grep
  set grepprg=ag\ --vimgrep\ --smart-case\ --hidden\ --ignore\ '.git'
  set grepprg=ag\ --vimgrep\ --smart-case
elseif executable('grep')
  set grepprg=grep\ --line-number\ --recursive\ -I\ $*\ *
else
  set grepprg=internal
endif

" GUI settings
if has('gui_running')
  set lines=60
  set columns=180
  if has('win32')
    set guioptions-=t
  endif
endif

" Keep data files in a single location (nvim does this by default)
if !has('nvim')
  let s:datadir = vim#datadir()
  let &backupdir = s:datadir . '/backup//' . ',' . &backupdir
  let &undodir = s:datadir . '/undo//' . ',' . &undodir
  let &directory = s:datadir . '/swap//' . ',' . &directory

  " Create directories if they don't exist
  if exists('*mkdir')
    for opt in [&backupdir, &undodir, &directory]
      let dir = simplify(split(opt, ',')[0])
      if !isdirectory(dir)
        call mkdir(dir, 'p')
      endif
    endfor
  endif
endif

if filereadable(vim#cachedir() . '/tags')
  let &tags .= ',' . vim#cachedir() . '/tags'
endif

" Set dictionary if it exists
if empty(&dictionary) && filereadable('/usr/share/dict/words')
  set dictionary+=/usr/share/dict/words
if filereadable($VIMHOME . '/tags')
  let &tags .= ',' . $VIMHOME . '/tags'
endif

" Enable histogram diff


@@ 236,15 214,6 @@ inoremap <CR> <C-]><C-G>u<CR>
" Auto close braces in insert mode
inoremap {<CR> {<CR>}<Esc>ko

" Insert current date with <C-\>d
inoremap <silent> <C-\>d <C-R>=strftime('%Y-%m-%d')<CR>

" Insert current filename with <C-\>f
inoremap <silent> <C-\>f <C-R>=expand('%:t')<CR>

" Insert full path to file with <C-\>F
inoremap <silent> <C-\>F <C-R>=expand('%:p')<CR>

" Copy line above/below (similar to <C-Y>/<C-E> but works on the whole line)
inoremap <expr> <C-G><C-Y> repeat('<C-Y>', len(getline(line('.')-1))-col('.')+1)
inoremap <expr> <C-G><C-E> repeat('<C-E>', len(getline(line('.')-1))-col('.')+1)


@@ 264,14 233,8 @@ nnoremap Y y$
" Switch to previous buffer
nnoremap <BS> <C-^>

" Navigate through wrapped lines individually
nnoremap gj j
nnoremap gk k
nnoremap <expr> j v:count ? 'j' : 'gj'
nnoremap <expr> k v:count ? 'k' : 'gk'

" Map Q to gq
noremap Q gqap
noremap Q gq

" Write file with <Space>w
nnoremap <Space>w :w<CR>


@@ 328,20 291,13 @@ nnoremap <Space>gq mzHmygggqG`yzt`z
" Modify contents of a register
nnoremap yr :<C-\>e'let @' . v:register . ' = ' . string(getreg(v:register))<CR><C-F>

" Show marks
nnoremap <Space>m :marks<CR>:norm! `

" Show only user placed marks (A-Z and a-z)
let s:alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
execute 'nnoremap <Space>M :marks ' . s:alphabet . '<CR>'
unlet s:alphabet

" Allow [[ and friends to work when opening brace is not in the first column
noremap <silent> [[ ?{<CR>w99[{:let @/ = ''<CR>
noremap <silent> ][ /}<CR>b99]}:let @/ = ''<CR>
noremap <silent> ]] j0?{<CR>w99[{%/{<CR>:let @/ = ''<CR>
noremap <silent> [] k$/}<CR>b99]}%?}<CR>:let @/ = ''<CR>

" Unimpaired style mappings
for s:ch in ['a', 'b', 'l', 'q', 't']
    let s:up = toupper(s:ch)
    exe 'nnoremap <expr> [' . s:ch . ' bracket#left(''' . s:ch . ''')'


@@ 351,8 307,8 @@ for s:ch in ['a', 'b', 'l', 'q', 't']
endfor
unlet s:ch s:up

nnoremap [e :.move --<CR>
nnoremap ]e :.move +<CR>
nnoremap <expr> [e ":\<C-U>.move --" . v:count1 . "\<CR>"
nnoremap <expr> ]e ":\<C-U>.move +" . v:count1 . "\<CR>"

nnoremap [<Space> :<C-U>put! =repeat(nr2char(10), v:count1)<CR><CR>:']+1<CR>
nnoremap ]<Space> :<C-U>put =repeat(nr2char(10), v:count1)<CR><CR>:'[-1<CR>


@@ 389,8 345,6 @@ endif
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>

cnoremap <C-X><C-E> <C-F>

if has('nvim') && &wildoptions =~# 'pum'
  cnoremap <expr> <C-J> pumvisible() ? "\<Down>\<Tab>" : "\<C-J>"
  cnoremap <expr> <C-K> pumvisible() ? "\<Up>\<Tab>" : "\<C-K>"


@@ 465,10 419,7 @@ autocmd Syntax * call s:highlight_trailing_whitespace()
" Enable omnicompletion from syntax if no other option available
" See :h ft-syntax-omni
if exists('+omnifunc')
  autocmd FileType *
        \ if &omnifunc == '' |
        \   setlocal omnifunc=syntaxcomplete#Complete |
        \ endif
  autocmd FileType * if &omnifunc == '' | setlocal omnifunc=syntaxcomplete#Complete | endif
endif

augroup END