Skip to content

Commit

Permalink
Allow to configure lhs mappings to be used
Browse files Browse the repository at this point in the history
Fixes #19
  • Loading branch information
blueyed committed Oct 16, 2014
1 parent 2a3c5f8 commit 483b9b1
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions autoload/repeat.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -103,12 +120,19 @@ 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)
echoerr 'nnoremap <silent> '.g:repeat_map_dot.' :<C-U>call repeat#run(v:count)<CR>'
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!
Expand Down

0 comments on commit 483b9b1

Please sign in to comment.