1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:40:06 +08:00

Merge branch 'mapping' into dev

This commit is contained in:
wsdjeg 2017-04-03 21:42:48 +08:00
commit 4a49c367a2
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,27 @@
function! SpaceVim#api#vim#compatible#get() abort
return map({
\ 'execute' : '',
\ },
\ "function('s:' . v:key)"
\ )
endfunction
function! s:execute(cmd, ...) abort
if a:0 == 0
let s = 'silent'
else
let s = a:1
endif
redir => output
if s ==# 'silent'
silent execute a:cmd
elseif s ==# 'silent!'
silent! execute a:cmd
else
execute a:cmd
endif
redir END
return output
endfunction
" vim:set et sw=2 cc=80:

View File

@ -0,0 +1,35 @@
let s:VIM = SpaceVim#api#import('vim#compatible')
function! SpaceVim#api#vim#mapping#get() abort
return map({
\ 'map' : '',
\ },
\ "function('s:' . v:key)"
\ )
endfunction
function! s:map(...) abort
if a:0 == 1
return s:parser(s:VIM.execute(':map ' . a:1))
endif
return []
endfunction
function! s:parser(rst) abort
let mappings = split(a:rst, "\n")
let mappings = map(mappings, 'split(v:val)')
let rst = []
for mapping in mappings
if len(mapping) >= 3
let mode = mapping[0]
let key = mapping[1]
let m = maparg(key, mode, 0, 1)
if !empty(m)
call add(rst, m)
endif
endif
endfor
return rst
endfunction
" vim:set et sw=2 cc=80: