mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-18 01:38:57 +00:00
Prepend omaps with <ignore> (try to fix #199)
This forces vim to consider using omaps instead of incorrect normal ones when executing a macro. Taking this approach because it does not seem to cause any side-effects and still allows user customization of maps under the existing lhs/rhs.
This commit is contained in:
@@ -166,6 +166,8 @@ endfunction
|
||||
|
||||
" }}}1
|
||||
|
||||
let s:ignore_key = len(expand("\<ignore>")) > 0 ? '<ignore>' : ''
|
||||
|
||||
function! s:init_default_mappings()
|
||||
if !get(g:,'matchup_mappings_enabled', 1) | return | endif
|
||||
|
||||
@@ -176,6 +178,13 @@ function! s:init_default_mappings()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:omap(mode, lhs, rhs, ...) " issues/199
|
||||
if !hasmapto(a:rhs, a:mode)
|
||||
\ && ((a:0 > 0) || (maparg(a:lhs, a:mode) ==# ''))
|
||||
silent execute a:mode . 'map <silent> ' a:lhs s:ignore_key . a:rhs
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if s:old_style_ops
|
||||
call s:init_oldstyle_ops()
|
||||
endif
|
||||
@@ -198,8 +207,8 @@ function! s:init_default_mappings()
|
||||
call s:map('x', 'z%', '<plug>(matchup-z%)')
|
||||
|
||||
if !s:old_style_ops
|
||||
call s:map('o', '%', '<plug>(matchup-%)')
|
||||
call s:map('o', 'g%', '<plug>(matchup-g%)')
|
||||
call s:omap('o', '%', '<plug>(matchup-%)')
|
||||
call s:omap('o', 'g%', '<plug>(matchup-g%)')
|
||||
call s:map('o', ']%', '<plug>(matchup-]%)')
|
||||
call s:map('o', '[%', '<plug>(matchup-[%)')
|
||||
call s:map('o', 'z%', '<plug>(matchup-z%)')
|
||||
|
||||
Reference in New Issue
Block a user