vimrc.d/dein_early_setup.vim

This file holds setup that is required for lazy loading to function correctly with dein.vim, but which can’t be stored within the plugin configuration as it would break caching.

ale maps

Use my custom maps:

if v:version >= 800 && has('signs')
    call keymaps#mnemonic_map('ale', #{local: v:true})

    for [s:key, s:cmd] in [
    \   ['br',     'reset_buffer'],
    \   ['bt',     'toggle_buffer'],
    \   ['d',      'detail'],
    \   ['f',      'fix'],
    \   ['gd',     'go_to_definition'],
    \   ['gt',     'go_to_type_definition'],
    \   ['l',      'lint'],
    \   ['r',      'reset'],
    \   ['t',      'toggle'],
    \   ['vgd',    'go_to_definition_in_vsplit'],
    \   ['vgt',    'go_to_type_definition_in_vsplit'],
    \   ['<Home>', 'first'],
    \   ['<End>',  'last'],
    \   ['<Down>', 'next_wrap'],
    \   ['<Up>',   'previous_wrap'],
    \ ]
        execute printf('nmap <silent> [ale]%s <Plug>(ale_%s)', s:key, s:cmd)
    endfor
    nnoremap [ale]i <Cmd>call ale#debugging#Info()<CR>
endif

Note

You can, of course, simply use the normal location list bindings for movement too.

calendar-vim maps

Use my custom maps:

const g:calendar_no_mappings = v:true

call keymaps#mnemonic_map('Calendar')

for [s:key, s:cmd] in [
\   ['v', ''],
\   ['h', 'H'],
\   ['f', 'T'],
\   ['r', 'VR'],
\ ]
    execute printf('nnoremap [Calendar]%s <Cmd>Calendar%s<CR>',
    \              s:key, s:cmd)
endfor

committia.vim filetype

We lazy load on filetype definition for my normal workflow with clientserver, but want to forcibly load on vim being called from git commit:

if plugins#dein#has_exec('git')
    if get(v:argv, 0, '') =~# '/.git/COMMIT_EDITMSG$'
        call dein#source('committia.vim')
    endif
endif

dwm.vim maps

Use my custom maps:

const g:dwm_map_keys = v:false

call keymaps#mnemonic_map('dwm')

Configure maps to match, to some degree, my window manager’s configuration:

for [s:key, s:cmd] in [
\   ['n',       'New'],
\   ['c',       'Close'],
\   ['f',       'Focus'],
\   ['<Left>',  'RotateCounterclockwise'],
\   ['<Right>', 'RotateClockwise'],
\   ['<Up>',    'New'],
\   ['<Down>',  'Close'],
\   ['+',       'GrowMaster'],
\   ['-',       'ShrinkMaster'],
\ ]
    execute printf('nmap [dwm]%s <Plug>DWM%s', s:key, s:cmd)
endfor

Tip

Imagine <Up> increases window count, and <Down>… well, yeah.

fzf.vim maps

Configure convenience mappings for common command usage:

if plugins#dein#has_exec('fzf')
    let g:fzf_commands = ['Buffers', 'Colors', 'Commands', 'Files',
    \   'History', 'Lines', 'Maps', 'Marks', 'Windows']
    if plugins#dein#has_exec('ag')
        let g:fzf_commands += ['Ag', ]
    endif
    if plugins#dein#has_exec('git')
        let g:fzf_commands += ['GFiles', ]
    endif
    if has('insert_expand')
        let g:fzf_commands += ['Snippets', ]
    endif
    call keymaps#mnemonic_map('fzf', #{key: '`'})
    for s:cmd in g:fzf_commands
        execute printf('nnoremap [fzf]%s <Cmd>FZF%s<CR>',
        \              tolower(s:cmd[0]), s:cmd)
    endfor
endif

Tip

I use grave as my binding for fzf commands to reflect my use of <Mod4-`> to open a drop down terminal in my window manager. The pattern here and throughout these configuration files is extremely useful as a way to remember bindings.

git-messenger.vim maps

Use my custom maps:

if has('signs') && plugins#dein#has_exec('git')
    let g:git_messenger_no_default_mappings = v:true

    call keymaps#mnemonic_map('messenger')

    for [s:key, s:cmd] in [
    \   ['o',          ''],
    \   ['c',          '-close'],
    \   ['i',          '-into-popup'],
    \   ['<Down>',     '-scroll-down-1'],
    \   ['<Up>',       '-scroll-up-1'],
    \   ['<PageDown>', '-scroll-down-page'],
    \   ['<PageUp>',   '-scroll-up-page'],
    \ ]
        execute printf(
        \   'nmap <silent> [messenger]%s <Plug>(git-messenger%s)',
        \   s:key, s:cmd)
    endfor
endif

nerdtree maps

Use my custom maps:

call keymaps#mnemonic_map('nerdtree')

for [s:key, s:cmd] in [
\   ['O', 'VCS'],
\   ['T', 'ToggleVCS'],
\   ['c', 'Close'],
\   ['f', 'Focus'],
\   ['o', ''],
\   ['t', 'Toggle'],
\ ]
    execute printf('nnoremap [nerdtree]%s <Cmd>NERDTree%s<CR>',
    \              s:key, s:cmd)
endfor

sideways.vim maps

Use my custom maps:

call keymaps#mnemonic_map('sideways', #{local: v:true})

for s:key in ['Left', 'Right']
    execute printf('nnoremap [sideways]<%s> <Cmd>Sideways%s<CR>', s:key,
    \              s:key)
    execute printf(
    \   'nnoremap [sideways]<S-%s> <Cmd>SidewaysJump%s<CR>', s:key, s:key)
endfor

switch.vim maps

Use <C-M-T> to flip word under cursor to match my old True/False map memory:

for [s:mode, s:cmd_prefix] in [
\   ['i', '<C-O>'],
\   ['n', ''],
\   ['v', '<ESC>'],
\ ]
    execute printf('%snoremap <C-M-T> %s:Switch<CR>', s:mode, s:cmd_prefix)
endfor

unicode.vim maps

:UnicodeName output is far more useful than vim’s ga, and in my opinion it is also easier to read.

Command

Output

:ascii

<> 61486, Hex f02e, Octal 170056

:UnicodeName

'' U+F02E Dec:61486 Private Use Zone &#xF02E; /\%uf02e "\uf02e"

So, we’ll override the ga mapping:

nmap ga <Plug>(UnicodeGA)

Tip

If for some reason you want the default ga output :ascii still does that.

vim-bufmru maps

Use my custom maps:

call keymaps#mnemonic_map('bufmru')

nnoremap [bufmru]l       <Cmd>BufMRU<CR>
nnoremap [bufmru]<Left>  <Cmd>BufMRUPrev<CR>
nnoremap [bufmru]<Right> <Cmd>BufMRUNext<CR>

Tip

Imagine <Left> and <Right> are moving across a timeline of used buffers.

vim-editqf maps

Add custom maps in to my quickfix map hierarchy:

nmap [quickfix]a <Plug>QFAddNote
nmap [quickfix]A <Plug>QFAddPatternNote
nnoremap [location]a <Cmd>LocAddNote<CR>
nnoremap [location]A <Cmd>LocAddNotePattern<CR>

vim-fugitive maps

Add map to change directory to git project root using vim-projectionist:

if plugins#dein#has_exec('git')
    nnoremap <C-p> <Cmd>Gcd<CR>
endif

Note

I never use <C-p> or <C-n> for navigation, as vim generally offers far more useful navigation, and anyway you can still move up with k.

vim-gitgutter maps

Use my custom maps:

if has('signs') && plugins#dein#has_exec('git')
    call keymaps#mnemonic_map('gitgutter')
    let g:gitgutter_map_keys = v:false

    for [s:key, s:cmd] in [
    \   ['<Down>',  'NextHunk'],
    \   ['<Up>',    'PrevHunk'],
    \   ['<Space>', 'Toggle'],
    \   ['f',       'Fold'],
    \   ['p',       'PreviewHunk'],
    \   ['q',       'QuickFix'],
    \ ]
        execute printf(
        \   'nnoremap [gitgutter]%s <Cmd>GitGutter%s<CR>',
        \   s:key, s:cmd
        \ )
    endfor
endif

vim-ledger maps

Use my custom maps:

call keymaps#mnemonic_map('Ledger', #{buffer: v:true, key: 'L',
\                                     local: v:true})

for [s:key, s:cmd] in [
\   ['a', ':LedgerAlign'],
\   ['d', 'align_amount_at_cursor()'],
\   ['n', 'entry()'],
\   ['s', 'transaction_state_toggle(line("."), " *?!")'],
\   ['t', 'transaction_date_set(".", "auxiliary")'],
\ ]
    if s:cmd[0] !=# ':'
        let s:cmd = 'call ledger#' .. s:cmd
    else
        let s:cmd = s:cmd[1:]
    endif

    execute printf(
    \   'autocmd Filetype ledger nnoremap [Ledger]%s <Cmd>%s<CR>',
    \   s:key, s:cmd)
endfor

vim-mundo maps

Use my custom maps:

if has('pythonx') && v:version >= 703
    nnoremap <LocalLeader># <Cmd>MundoToggle<CR>
endif

vim-quick-radon maps

Configure my custom maps:

if plugins#dein#has_exec('radon')
    call keymaps#mnemonic_map('radon', #{key: 'p', local: v:true})
endif

Note

<Leader>r is free globally, but jedi-vim uses it in my Python files.

vim-vebugger maps

Use my custom maps:

call keymaps#mnemonic_map('vebugger', #{local: v:true})
const g:vebugger_leader='[vebugger]'

wordnet.vim maps

Use my custom maps:

if plugins#dein#has_exec('wn')
    call keymaps#mnemonic_map('wordnet')

    for [s:key, s:cmd] in [
    \   ['o', 'WordNetOverviews(expand("<cword>"))'],
    \   ['c', 'plugins#wordnet_vim#close_win()'],
    \ ]
        execute printf('nnoremap [wordnet]%s <Cmd>call %s<CR>',
        \              s:key, s:cmd)
    endfor
endif