Allow to configure lhs mappings to be used

Fixes https://github.com/tpope/vim-repeat/issues/19
This commit is contained in:
Daniel Hahler 2014-10-16 21:30:58 +02:00
parent 2a3c5f8e3c
commit 0a05f02d49

View file

@ -52,6 +52,23 @@ let g:loaded_repeat = 1
let g:repeat_tick = -1
let g:repeat_reg = ['', '']
if !exists('g:repeat_map_dot')
let g:repeat_map_dot = '.'
endif
if !exists('g:repeat_map_u')
let g:repeat_map_u = 'u'
endif
if !exists('g:repeat_map_U')
if maparg('U','n') ==# ''
let g:repeat_map_U = 'U'
else
let g:repeat_map_U = ''
endif
endif
if !exists('g:repeat_map_C_R')
let g:repeat_map_C_R = '<C-R>'
endif
" Special function to avoid spurious repeats in a related, naturally repeating
" mapping when your repeatable mapping doesn't increase b:changedtick.
function! repeat#invalidate()
@ -103,12 +120,18 @@ function! repeat#wrap(command,count)
endif
endfunction
nnoremap <silent> . :<C-U>call repeat#run(v:count)<CR>
nnoremap <silent> u :<C-U>call repeat#wrap('u',v:count)<CR>
if maparg('U','n') ==# ''
nnoremap <silent> U :<C-U>call repeat#wrap('U',v:count)<CR>
if len(g:repeat_map_dot)
exe 'nnoremap <silent> '.g:repeat_map_dot.' :<C-U>call repeat#run(v:count)<CR>'
endif
if len(g:repeat_map_u)
exe 'nnoremap <silent> '.g:repeat_map_u.' :<C-U>call repeat#wrap("u",v:count)<CR>'
endif
if len(g:repeat_map_U)
exe 'nnoremap <silent> '.g:repeat_map_U.' :<C-U>call repeat#wrap("U",v:count)<CR>'
endif
if len(g:repeat_map_u)
exe 'nnoremap <silent> '.g:repeat_map_C_R.' :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR>'
endif
nnoremap <silent> <C-R> :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR>
augroup repeatPlugin
autocmd!