Skip to content

Commit 3720d28

Browse files
committed
Don't clobber user text objects
References vim-ruby#46.
1 parent 8aa9cee commit 3720d28

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

ftplugin/ruby.vim

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,25 @@ if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
125125
xnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b','v')<CR>
126126
xnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','','v')<CR>
127127
128-
onoremap <silent> <buffer> im :<C-U>call <SID>wrap_i('[m',']M')<CR>
129-
onoremap <silent> <buffer> am :<C-U>call <SID>wrap_a('[m',']M')<CR>
130-
onoremap <silent> <buffer> ic :<C-U>call <SID>wrap_i('[[','][')<CR>
131-
onoremap <silent> <buffer> ac :<C-U>call <SID>wrap_a('[[','][')<CR>
132-
133128
let b:undo_ftplugin = b:undo_ftplugin
134129
\."| sil! exe 'unmap <buffer> [[' | sil! exe 'unmap <buffer> ]]' | sil! exe 'unmap <buffer> []' | sil! exe 'unmap <buffer> ]['"
135130
\."| sil! exe 'unmap <buffer> [m' | sil! exe 'unmap <buffer> ]m' | sil! exe 'unmap <buffer> [M' | sil! exe 'unmap <buffer> ]M'"
136131
\."! sil! exe 'ounmap <buffer> im'| sil! exe 'ounmap <buffer> am'| sil! exe 'ounmap <buffer> ic'| sil! exe 'ounmap <buffer> ac'"
137132

133+
if maparg('im','n') == ''
134+
onoremap <silent> <buffer> im :<C-U>call <SID>wrap_i('[m',']M')<CR>
135+
onoremap <silent> <buffer> am :<C-U>call <SID>wrap_a('[m',']M')<CR>
136+
let b:undo_ftplugin = b:undo_ftplugin
137+
\."! sil! exe 'ounmap <buffer> im' | sil! exe 'ounmap <buffer> am'"
138+
endif
139+
140+
if maparg('ic','n') == ''
141+
onoremap <silent> <buffer> ic :<C-U>call <SID>wrap_i('[[','][')<CR>
142+
onoremap <silent> <buffer> ac :<C-U>call <SID>wrap_a('[[','][')<CR>
143+
let b:undo_ftplugin = b:undo_ftplugin
144+
\."| sil! exe 'ounmap <buffer> ic' | sil! exe 'ounmap <buffer> ac'"
145+
endif
146+
138147
if maparg("\<C-]>",'n') == ''
139148
nnoremap <silent> <buffer> <C-]> :<C-U>exe v:count1."tag <C-R>=RubyCursorIdentifier()<CR>"<CR>
140149
nnoremap <silent> <buffer> g<C-]> :<C-U>exe "tjump <C-R>=RubyCursorIdentifier()<CR>"<CR>

0 commit comments

Comments
 (0)