> So, to understand correctly, if the user has g:no_plugin_maps set to 1, then
> the mappings won't be created? That's fine with me, if users have
> g:no_plugin_maps set,
> then the issue is out of the plugin author's hands, and that's fine.
You need to write such a check in your plugin; it isn't performed automatically.
> I want to provide these users with a reasonable default set of mappings,
> as well as avoid annoying them with constant messages about mappings
> that conflict.
Brett's suggestion seems to handle the annoyance avoidance. My plugin
doesn't avoid annoyance, but I think I'm okay with that as it's pretty
easy to disable the mappings if they conflict.
I have a series of mappings created using the following. The main
point here is that you should probably check to see if someone has
created custom maps to your functionality, using <Plug> mappings as
previously suggested.
function! s:CreateMapping(shortcut, expansion, display)
let lhs = VCSCommandGetOption('VCSCommandMapPrefix',
'<Leader>c') . a:shortcut
if !hasmapto(a:expansion)
try
execute 'nmap <silent> <unique>' lhs a:expansion
catch /^Vim(.*):E227:/
if(&verbose != 0)
echohl WarningMsg|echomsg 'VCSCommand:
mapping ''' . lhs . ''' already exists, refusing to overwrite. The
mapping for ' . a:display . ' will not be available.'|echohl None
endif
endtry
endif
endfunction
let s:defaultMappings = [
\['a', 'VCSAdd'],
...
\['v', 'VCSVimDiff']
\]
if !VCSCommandGetOption('VCSCommandDisableMappings', 0)
for [shortcut, vcsFunction] in
VCSCommandGetOption('VCSCommandMappings', s:defaultMappings)
call s:CreateMapping(shortcut, '<Plug>' . vcsFunction,
'''' . vcsFunction . '''')
endfor
endif
Thank you,
bob
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment