2016-03-27 05:39:03 -04:00
|
|
|
" ___vital___
|
|
|
|
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
|
|
|
|
" Do not mofidify the code nor insert new lines before '" ___vital___'
|
|
|
|
if v:version > 703 || v:version == 703 && has('patch1170')
|
|
|
|
function! vital#_easymotion#Over#Commandline#Modules#KeyMapping#import() abort
|
|
|
|
return map({'_vital_depends': '', 'make_emacs': '', 'make_vim_cmdline_mapping': '', '_vital_loaded': ''}, 'function("s:" . v:key)')
|
|
|
|
endfunction
|
|
|
|
else
|
|
|
|
function! s:_SID() abort
|
|
|
|
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
|
|
|
|
endfunction
|
|
|
|
execute join(['function! vital#_easymotion#Over#Commandline#Modules#KeyMapping#import() abort', printf("return map({'_vital_depends': '', 'make_emacs': '', 'make_vim_cmdline_mapping': '', '_vital_loaded': ''}, \"function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
|
|
|
|
delfunction s:_SID
|
|
|
|
endif
|
|
|
|
" ___vital___
|
2014-02-04 23:32:29 -05:00
|
|
|
scriptencoding utf-8
|
|
|
|
let s:save_cpo = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
|
2014-11-23 12:07:19 -05:00
|
|
|
|
|
|
|
function! s:_vital_loaded(V)
|
2015-02-23 11:19:17 -05:00
|
|
|
let s:Keymapping = a:V.import("Palette.Keymapping")
|
2014-11-23 12:07:19 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
function! s:_vital_depends()
|
|
|
|
return [
|
2015-02-23 11:19:17 -05:00
|
|
|
\ "Palette.Keymapping",
|
2014-11-23 12:07:19 -05:00
|
|
|
\ ]
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2014-02-04 23:32:29 -05:00
|
|
|
let s:emacs = {
|
|
|
|
\ "name" : "KeyMapping_emacs_like"
|
|
|
|
\}
|
|
|
|
|
|
|
|
function! s:emacs.keymapping(cmdline)
|
|
|
|
return {
|
|
|
|
\ "\<C-f>" : {
|
|
|
|
\ "key" : "\<Right>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
|
|
|
\ "\<C-b>" : {
|
|
|
|
\ "key" : "\<Left>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
|
|
|
\ "\<C-n>" : {
|
|
|
|
\ "key" : "\<Down>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
|
|
|
\ "\<C-p>" : {
|
|
|
|
\ "key" : "\<Up>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
|
|
|
\ "\<C-a>" : {
|
|
|
|
\ "key" : "\<Home>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
|
|
|
\ "\<C-e>" : {
|
|
|
|
\ "key" : "\<End>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
|
|
|
\ "\<C-d>" : {
|
|
|
|
\ "key" : "\<Del>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
|
|
|
\ "\<A-d>" : {
|
|
|
|
\ "key" : "\<C-w>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
2014-11-23 12:07:19 -05:00
|
|
|
\ "\<A-b>" : {
|
|
|
|
\ "key" : "\<S-Left>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
|
|
|
\ "\<A-f>" : {
|
|
|
|
\ "key" : "\<S-Right>",
|
|
|
|
\ "noremap" : 1,
|
|
|
|
\ "lock" : 1,
|
|
|
|
\ },
|
2014-02-04 23:32:29 -05:00
|
|
|
\ }
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
function! s:make_emacs()
|
|
|
|
return deepcopy(s:emacs)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2014-11-23 12:07:19 -05:00
|
|
|
let s:vim_cmdline_mapping = {
|
|
|
|
\ "name" : "KeyMapping_vim_cmdline_mapping",
|
|
|
|
\ "_cmaps" : {}
|
|
|
|
\}
|
|
|
|
|
2015-06-28 10:01:55 -04:00
|
|
|
function! s:_convert_sid(rhs, sid) abort
|
|
|
|
return substitute(a:rhs, '<SID>', '<SNR>' . a:sid . '_', 'g')
|
|
|
|
endfunction
|
|
|
|
|
2014-11-23 12:07:19 -05:00
|
|
|
function! s:_auto_cmap()
|
|
|
|
let cmaps = {}
|
2015-02-23 11:19:17 -05:00
|
|
|
let cmap_info = s:Keymapping.rhs_key_list("c", 0, 1)
|
|
|
|
" vital-over currently doesn't support <buffer> mappings
|
|
|
|
for c in filter(cmap_info, "v:val['buffer'] ==# 0")
|
|
|
|
let cmaps[s:Keymapping.escape_special_key(c['lhs'])] = {
|
2014-11-23 12:07:19 -05:00
|
|
|
\ 'noremap' : c['noremap'],
|
2015-06-28 10:01:55 -04:00
|
|
|
\ 'key' : s:Keymapping.escape_special_key(s:_convert_sid(c['rhs'], c['sid'])),
|
2015-02-23 11:19:17 -05:00
|
|
|
\ 'expr' : s:Keymapping.escape_special_key(c['expr']),
|
2014-11-23 12:07:19 -05:00
|
|
|
\ }
|
|
|
|
endfor
|
|
|
|
return cmaps
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
function! s:vim_cmdline_mapping.on_enter(cmdline)
|
|
|
|
let self._cmaps = s:_auto_cmap()
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
function! s:vim_cmdline_mapping.keymapping(cmdline)
|
|
|
|
return self._cmaps
|
|
|
|
endfunction
|
|
|
|
|
2015-02-23 11:19:17 -05:00
|
|
|
|
2014-11-23 12:07:19 -05:00
|
|
|
function! s:make_vim_cmdline_mapping()
|
|
|
|
return deepcopy(s:vim_cmdline_mapping)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2014-02-04 23:32:29 -05:00
|
|
|
|
|
|
|
let &cpo = s:save_cpo
|
|
|
|
unlet s:save_cpo
|