Skip to content

Commit 0766058

Browse files
committed
Use mapcheck for more conservative mapping
1 parent 481284b commit 0766058

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

ftplugin/ruby.vim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,18 @@ let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< tags< kp<"
146146
\."| if exists('&ofu') && has('ruby') | setl ofu< | endif"
147147
\."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif"
148148

149-
function! s:silmap(mode, map) abort
149+
function! s:map(mode, flags, map) abort
150150
let from = matchstr(a:map, '\S\+')
151-
if empty(maparg(from, a:mode))
152-
exe a:mode.'noremap <silent><buffer><script>' a:map
153-
let b:undo_ftplugin .= '| '.a:mode.'unmap <buffer> '.from
151+
if empty(mapcheck(from, a:mode))
152+
exe a:mode.'map' '<buffer>'.(a:0 ? a:1 : '') a:map
153+
let b:undo_ftplugin .= '|sil! '.a:mode.'unmap <buffer> '.from
154154
endif
155155
endfunction
156156

157+
function! s:silmap(mode, map) abort
158+
call s:map(a:mode, '<silent><script>', a:map)
159+
endfunction
160+
157161
if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
158162
nnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b','n')<CR>
159163
nnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','','n')<CR>

0 commit comments

Comments
 (0)