2014-11-23 12:07:19 -05:00
|
|
|
scriptencoding utf-8
|
|
|
|
let s:save_cpo = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
|
|
|
|
|
2015-02-23 11:19:17 -05:00
|
|
|
|
|
|
|
function! s:_vital_loaded(V)
|
|
|
|
let s:V = a:V
|
|
|
|
let s:String = s:V.import("Over.String")
|
2014-11-23 12:07:19 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2015-02-23 11:19:17 -05:00
|
|
|
function! s:_vital_depends()
|
|
|
|
return [
|
|
|
|
\ "Over.String",
|
|
|
|
\ ]
|
2014-11-23 12:07:19 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2015-02-23 11:19:17 -05:00
|
|
|
function! s:as_key_config(config)
|
|
|
|
let base = {
|
|
|
|
\ "noremap" : 0,
|
|
|
|
\ "lock" : 0,
|
|
|
|
\ "expr" : 0,
|
|
|
|
\ }
|
|
|
|
return type(a:config) == type({}) ? extend(base, a:config)
|
|
|
|
\ : extend(base, {
|
|
|
|
\ "key" : a:config,
|
|
|
|
\ })
|
2014-11-23 12:07:19 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2015-02-23 11:19:17 -05:00
|
|
|
function! s:match_key(keymapping, key)
|
|
|
|
let keys = sort(keys(a:keymapping))
|
|
|
|
return get(filter(keys, 'stridx(a:key, v:val) == 0'), -1, '')
|
2014-11-23 12:07:19 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2015-02-23 11:19:17 -05:00
|
|
|
function! s:_safe_eval(expr, ...)
|
|
|
|
call extend(l:, get(a:, 1, {}))
|
|
|
|
let result = get(a:, 2, "")
|
|
|
|
try
|
|
|
|
let result = eval(a:expr)
|
|
|
|
catch
|
|
|
|
echohl ErrorMsg | echom v:exception | echohl None
|
|
|
|
endtry
|
|
|
|
return result
|
2014-11-23 12:07:19 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2015-02-23 11:19:17 -05:00
|
|
|
function! s:_get_key(conf)
|
|
|
|
" call extend(l:, a:conf)
|
|
|
|
let self = a:conf
|
|
|
|
return get(a:conf, "expr", 0) ? s:_safe_eval(a:conf.key, l:) : a:conf.key
|
2014-11-23 12:07:19 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2015-02-23 11:19:17 -05:00
|
|
|
function! s:unmapping(keymapping, key, ...)
|
|
|
|
let is_locking = get(a:, 1, 0)
|
|
|
|
let key = s:match_key(a:keymapping, a:key)
|
|
|
|
if key == ""
|
|
|
|
return s:String.length(a:key) <= 1 ? a:key : s:unmapping(a:keymapping, a:key[0], is_locking) . s:unmapping(a:keymapping, a:key[1:], is_locking)
|
|
|
|
endif
|
|
|
|
|
|
|
|
let map_conf = s:as_key_config(a:keymapping[key])
|
|
|
|
|
|
|
|
let next_input = s:unmapping(a:keymapping, a:key[len(key) : ], is_locking)
|
|
|
|
if map_conf.lock == 0 && is_locking
|
|
|
|
return key . next_input
|
|
|
|
elseif map_conf.lock
|
|
|
|
return s:unmapping(a:keymapping, s:_get_key(map_conf), is_locking) . next_input
|
|
|
|
else
|
|
|
|
return s:unmapping(a:keymapping, s:_get_key(map_conf), map_conf.noremap) . next_input
|
|
|
|
endif
|
2014-11-23 12:07:19 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2015-02-23 11:19:17 -05:00
|
|
|
|
2014-11-23 12:07:19 -05:00
|
|
|
let &cpo = s:save_cpo
|
|
|
|
unlet s:save_cpo
|
2016-03-22 08:55:42 -04:00
|
|
|
" ___Revitalizer___
|
|
|
|
" NOTE: below code is generated by :Revitalize.
|
|
|
|
" Do not mofidify the code nor append new lines
|
|
|
|
if v:version > 703 || v:version == 703 && has('patch1170')
|
|
|
|
function! s:___revitalizer_function___(fstr) abort
|
|
|
|
return function(a:fstr)
|
|
|
|
endfunction
|
|
|
|
else
|
|
|
|
function! s:___revitalizer_SID() abort
|
|
|
|
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze____revitalizer_SID$')
|
|
|
|
endfunction
|
|
|
|
let s:___revitalizer_sid = '<SNR>' . s:___revitalizer_SID() . '_'
|
|
|
|
function! s:___revitalizer_function___(fstr) abort
|
|
|
|
return function(substitute(a:fstr, 's:', s:___revitalizer_sid, 'g'))
|
|
|
|
endfunction
|
|
|
|
endif
|
|
|
|
|
2016-03-22 10:04:08 -04:00
|
|
|
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'as_key_config': s:___revitalizer_function___('s:as_key_config'),'match_key': s:___revitalizer_function___('s:match_key'),'unmapping': s:___revitalizer_function___('s:unmapping')}
|
2016-03-22 08:55:42 -04:00
|
|
|
|
|
|
|
unlet! s:___revitalizer_sid
|
|
|
|
delfunction s:___revitalizer_function___
|
|
|
|
|
|
|
|
function! vital#_easymotion#Over#Keymapping#import() abort
|
|
|
|
return s:___revitalizer_functions___
|
|
|
|
endfunction
|
|
|
|
" ___Revitalizer___
|