What about reworking the way users can customize plugin mappings?

How can you customize mappings today?

1) <leader>
  Example:
    inoremap <leader>foo

  problem: You have to set leader before you use a plugin

2) g:x setting
  Example:
    if !exists('g:my_plugin_map_prefix')
      let g:my_plugin_map_prefix = '\f'
    endif
    exec  'noremap '.g:my_plugin_map_prefix.'bar' :call ...

Did I miss something? Neither is friendly to users and plugin authors
How could it be improved?

First: You have to identify the mappings you want to change. Thus they
need an ID. Either plugin authors could assign such an id (2) - or an id
could be derived automatically (1) (eg from filename they are defined in):

Example (1): NAME.vim is taken as id
  " defined plugin/NAME.vim
  inormap <c-x><c-p> call ...

Example (2): id is provided by plugin author:
  inormap [a-string]<c-x><c-p> call ...


customization could look like this:

(1)
inoremap_lhs_map [NAME.vim]<c-x><c-p> \do_thing

(2)
inoremap_lhs_map [a-string]<c-x><c-p> \do_thing


Then plugin authors can choose what they think is best - and users can
overwrite - nobody has to add additional option lines.

Yes - I am aware that this could be implemented in VimL using
expand('<sfile>') and using commands... But I'd like to keep Vim startup
fast.

How do you feel about this?

Of course may be tiresome to redefine all mapping done by a plugin.
So eventually a functions could be provided remapping some mapping only:

set change_mappings=MyMapping

fun! MyMapping(file, lhs)
  let k = a:file.a:lhs
  if a:file = 'NAME.vim'
    return 'prefix'.a:lhs
  endif
  return a:lhs
endf

The you can remap many mappings easily.

Marc Weber

-- 
You received this message from the "vim_dev" 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

Raspunde prin e-mail lui