mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-25 03:02:21 +08:00
Add more custom functions (#3260)
- Spacevim#custom#LangSPC - SpaceVim#custom#LangSPCGroupName
This commit is contained in:
parent
c4a4d55128
commit
f8e828e9dd
@ -783,13 +783,13 @@ let g:spacevim_filemanager = 'vimfiler'
|
|||||||
" @section filetree_direction, options-filetree_direction
|
" @section filetree_direction, options-filetree_direction
|
||||||
" @parentsection options
|
" @parentsection options
|
||||||
" Config the direction of file tree. Default is 'right'. you can also set to
|
" Config the direction of file tree. Default is 'right'. you can also set to
|
||||||
" 'left'.
|
" 'left'.
|
||||||
"
|
"
|
||||||
" NOTE: if it is 'left', the tagbar will be move to right.
|
" NOTE: if it is 'left', the tagbar will be move to right.
|
||||||
|
|
||||||
""
|
""
|
||||||
" Config the direction of file tree. Default is 'right'. you can also set to
|
" Config the direction of file tree. Default is 'right'. you can also set to
|
||||||
" 'left'.
|
" 'left'.
|
||||||
"
|
"
|
||||||
" NOTE: if it is 'left', the tagbar will be move to right.
|
" NOTE: if it is 'left', the tagbar will be move to right.
|
||||||
let g:spacevim_filetree_direction = 'right'
|
let g:spacevim_filetree_direction = 'right'
|
||||||
@ -831,7 +831,7 @@ let g:spacevim_checkinstall = 1
|
|||||||
""
|
""
|
||||||
" @section vimcompatible, options-vimcompatible
|
" @section vimcompatible, options-vimcompatible
|
||||||
" @parentsection options
|
" @parentsection options
|
||||||
" Enable/Disable vimcompatible mode, by default it is false.
|
" Enable/Disable vimcompatible mode, by default it is false.
|
||||||
" to enable vimcompatible mode, just add:
|
" to enable vimcompatible mode, just add:
|
||||||
" >
|
" >
|
||||||
" vimcompatible = true
|
" vimcompatible = true
|
||||||
@ -850,7 +850,7 @@ let g:spacevim_checkinstall = 1
|
|||||||
" <
|
" <
|
||||||
|
|
||||||
""
|
""
|
||||||
" Enable/Disable vimcompatible mode, by default it is false.
|
" Enable/Disable vimcompatible mode, by default it is false.
|
||||||
" to enable vimcompatible mode, just add:
|
" to enable vimcompatible mode, just add:
|
||||||
" >
|
" >
|
||||||
" let g:spacevim_vimcompatible = 1
|
" let g:spacevim_vimcompatible = 1
|
||||||
@ -1217,6 +1217,8 @@ let g:spacevim_wildignore
|
|||||||
let g:_spacevim_mappings = {}
|
let g:_spacevim_mappings = {}
|
||||||
let g:_spacevim_mappings_space_custom = []
|
let g:_spacevim_mappings_space_custom = []
|
||||||
let g:_spacevim_mappings_space_custom_group_name = []
|
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_neobundle_installed = 0
|
||||||
let g:_spacevim_dein_installed = 0
|
let g:_spacevim_dein_installed = 0
|
||||||
let g:_spacevim_vim_plug_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])
|
call add(g:_spacevim_mappings_space_custom_group_name, [a:keys, a:name])
|
||||||
endfunction
|
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
|
function! SpaceVim#custom#apply(config, type) abort
|
||||||
" the type can be local or global
|
" the type can be local or global
|
||||||
|
@ -51,7 +51,7 @@ function! SpaceVim#mapping#space#init() abort
|
|||||||
let g:_spacevim_mappings_space.w['<Tab>'] = ['wincmd w', 'alternate-window']
|
let g:_spacevim_mappings_space.w['<Tab>'] = ['wincmd w', 'alternate-window']
|
||||||
nnoremap <silent> [SPC]w<tab> :wincmd w<cr>
|
nnoremap <silent> [SPC]w<tab> :wincmd w<cr>
|
||||||
call SpaceVim#mapping#menu('alternate-window', '[SPC]w<Tab>', 'wincmd w')
|
call SpaceVim#mapping#menu('alternate-window', '[SPC]w<Tab>', 'wincmd w')
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '+'],
|
call SpaceVim#mapping#space#def('nnoremap', ['w', '+'],
|
||||||
\ 'call call('
|
\ 'call call('
|
||||||
\ . string(function('s:windows_layout_toggle'))
|
\ . string(function('s:windows_layout_toggle'))
|
||||||
\ . ', [])', 'windows-layout-toggle', 1)
|
\ . ', [])', 'windows-layout-toggle', 1)
|
||||||
@ -209,7 +209,7 @@ function! SpaceVim#mapping#space#init() abort
|
|||||||
\ ]
|
\ ]
|
||||||
\ , 1)
|
\ , 1)
|
||||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'M'],
|
call SpaceVim#mapping#space#def('nnoremap', ['w', 'M'],
|
||||||
\ "execute eval(\"winnr('$')<=2 ? 'wincmd x' : 'ChooseWinSwap'\")",
|
\ "execute eval(\"winnr('$')<=2 ? 'wincmd x' : 'ChooseWinSwap'\")",
|
||||||
\ ['swap window',
|
\ ['swap window',
|
||||||
\ [
|
\ [
|
||||||
@ -558,8 +558,8 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd, ...) abort
|
|||||||
endif
|
endif
|
||||||
let is_visual = a:0 > 0 ? a:1 : 0
|
let is_visual = a:0 > 0 ? a:1 : 0
|
||||||
if a:is_cmd
|
if a:is_cmd
|
||||||
let cmd = ':<C-u>' . a:cmd . '<CR>'
|
let cmd = ':<C-u>' . a:cmd . '<CR>'
|
||||||
let xcmd = ':' . a:cmd . '<CR>'
|
let xcmd = ':' . a:cmd . '<CR>'
|
||||||
let lcmd = a:cmd
|
let lcmd = a:cmd
|
||||||
else
|
else
|
||||||
let cmd = a:cmd
|
let cmd = a:cmd
|
||||||
@ -615,7 +615,7 @@ function! s:windows_layout_toggle() abort
|
|||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
echom "Can't toggle window layout when the number of windows isn't two."
|
echom "Can't toggle window layout when the number of windows isn't two."
|
||||||
echohl None
|
echohl None
|
||||||
else
|
else
|
||||||
if winnr() == 1
|
if winnr() == 1
|
||||||
let b = winbufnr(2)
|
let b = winbufnr(2)
|
||||||
else
|
else
|
||||||
@ -636,12 +636,29 @@ endfunction
|
|||||||
|
|
||||||
let s:language_specified_mappings = {}
|
let s:language_specified_mappings = {}
|
||||||
function! SpaceVim#mapping#space#refrashLSPC() abort
|
function! SpaceVim#mapping#space#refrashLSPC() abort
|
||||||
|
" Predefined mappings
|
||||||
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
|
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
|
||||||
if !empty(&filetype) && has_key(s:language_specified_mappings, &filetype)
|
if !empty(&filetype) && has_key(s:language_specified_mappings, &filetype)
|
||||||
call call(s:language_specified_mappings[&filetype], [])
|
call call(s:language_specified_mappings[&filetype], [])
|
||||||
let b:spacevim_lang_specified_mappings = g:_spacevim_mappings_space.l
|
let b:spacevim_lang_specified_mappings = g:_spacevim_mappings_space.l
|
||||||
endif
|
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
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#mapping#space#regesit_lang_mappings(ft, func) abort
|
function! SpaceVim#mapping#space#regesit_lang_mappings(ft, func) abort
|
||||||
@ -654,7 +671,7 @@ function! SpaceVim#mapping#space#langSPC(m, keys, cmd, desc, is_cmd, ...) abort
|
|||||||
endif
|
endif
|
||||||
let is_visual = a:0 > 0 ? a:1 : 0
|
let is_visual = a:0 > 0 ? a:1 : 0
|
||||||
if a:is_cmd
|
if a:is_cmd
|
||||||
let cmd = ':<C-u>' . a:cmd . '<CR>'
|
let cmd = ':<C-u>' . a:cmd . '<CR>'
|
||||||
let lcmd = a:cmd
|
let lcmd = a:cmd
|
||||||
else
|
else
|
||||||
let cmd = a:cmd
|
let cmd = a:cmd
|
||||||
@ -706,7 +723,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:windows_transient_state() abort
|
function! s:windows_transient_state() abort
|
||||||
|
|
||||||
let state = SpaceVim#api#import('transient_state')
|
let state = SpaceVim#api#import('transient_state')
|
||||||
call state.set_title('Buffer Selection Transient State')
|
call state.set_title('Buffer Selection Transient State')
|
||||||
call state.defind_keys(
|
call state.defind_keys(
|
||||||
\ {
|
\ {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user