mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 22:30:04 +08:00
Add more custom functions (#3260)
- Spacevim#custom#LangSPC - SpaceVim#custom#LangSPCGroupName
This commit is contained in:
parent
c4a4d55128
commit
f8e828e9dd
@ -1217,6 +1217,8 @@ let g:spacevim_wildignore
|
||||
let g:_spacevim_mappings = {}
|
||||
let g:_spacevim_mappings_space_custom = []
|
||||
let g:_spacevim_mappings_space_custom_group_name = []
|
||||
let g:_spacevim_mappings_language_specified_space_custom = {}
|
||||
let g:_spacevim_mappings_language_specified_space_custom_group_name = {}
|
||||
let g:_spacevim_neobundle_installed = 0
|
||||
let g:_spacevim_dein_installed = 0
|
||||
let g:_spacevim_vim_plug_installed = 0
|
||||
|
@ -84,6 +84,19 @@ function! SpaceVim#custom#SPCGroupName(keys, name) abort
|
||||
call add(g:_spacevim_mappings_space_custom_group_name, [a:keys, a:name])
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#custom#LangSPC(ft, m, keys, cmd, desc, is_cmd) abort
|
||||
if !has_key(g:_spacevim_mappings_language_specified_space_custom, a:ft)
|
||||
let g:_spacevim_mappings_language_specified_space_custom[a:ft] = []
|
||||
endif
|
||||
call add(g:_spacevim_mappings_language_specified_space_custom[a:ft], [a:m, a:keys, a:cmd, a:desc, a:is_cmd])
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#custom#LangSPCGroupName(ft, keys, name) abort
|
||||
if !has_key(g:_spacevim_mappings_language_specified_space_custom_group_name, a:ft)
|
||||
let g:_spacevim_mappings_language_specified_space_custom_group_name[a:ft] = []
|
||||
endif
|
||||
call add(g:_spacevim_mappings_language_specified_space_custom_group_name[a:ft], [a:keys, a:name])
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#custom#apply(config, type) abort
|
||||
" the type can be local or global
|
||||
|
@ -636,12 +636,29 @@ endfunction
|
||||
|
||||
let s:language_specified_mappings = {}
|
||||
function! SpaceVim#mapping#space#refrashLSPC() abort
|
||||
" Predefined mappings
|
||||
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
|
||||
if !empty(&filetype) && has_key(s:language_specified_mappings, &filetype)
|
||||
call call(s:language_specified_mappings[&filetype], [])
|
||||
let b:spacevim_lang_specified_mappings = g:_spacevim_mappings_space.l
|
||||
endif
|
||||
|
||||
" Customized mappings
|
||||
if has_key(g:_spacevim_mappings_language_specified_space_custom_group_name, &filetype)
|
||||
for argv in g:_spacevim_mappings_language_specified_space_custom_group_name[&filetype]
|
||||
" Only support one layer of groups
|
||||
if !has_key(g:_spacevim_mappings_space.l, argv[0][0])
|
||||
let g:_spacevim_mappings_space.l[argv[0][0]] = {'name' : argv[1]}
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
if has_key(g:_spacevim_mappings_language_specified_space_custom, &filetype)
|
||||
for argv in g:_spacevim_mappings_language_specified_space_custom[&filetype]
|
||||
let argv = deepcopy(argv)
|
||||
let argv[1] = ['l'] + argv[1]
|
||||
call call('SpaceVim#mapping#space#langSPC', argv)
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#mapping#space#regesit_lang_mappings(ft, func) abort
|
||||
|
Loading…
Reference in New Issue
Block a user