allow plugins to override the default mappings
This commit is contained in:
parent
aa831e242b
commit
f9a933991d
@ -1060,6 +1060,9 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()*
|
||||
"callback" - the function the new mapping will be bound to
|
||||
"quickhelpText" - the text that will appear in the quickhelp (see
|
||||
|NERDTree-?|)
|
||||
"override" - if 1 then this new mapping will override whatever previous
|
||||
mapping was defined for the key/scope combo. Useful for overriding the
|
||||
default mappings.
|
||||
|
||||
Additionally, a "scope" argument may be supplied. This constrains the
|
||||
mapping so that it is only activated if the cursor is on a certain object.
|
||||
|
@ -134,8 +134,14 @@ endfunction
|
||||
|
||||
"FUNCTION: KeyMap.Create(options) {{{1
|
||||
function! s:KeyMap.Create(options)
|
||||
let newKeyMap = copy(self)
|
||||
let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options))
|
||||
|
||||
"dont override other mappings unless the 'override' option is given
|
||||
if get(opts, 'override', 0) == 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope']))
|
||||
return
|
||||
end
|
||||
|
||||
let newKeyMap = copy(self)
|
||||
let newKeyMap.key = opts['key']
|
||||
let newKeyMap.quickhelpText = opts['quickhelpText']
|
||||
let newKeyMap.callback = opts['callback']
|
||||
|
Loading…
Reference in New Issue
Block a user