diff --git a/README.md b/README.md index 3dd504d4c..bbac83aef 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ curl -sLf https://spacevim.org/install.sh | bash -s -- -h - Neovim-centric - [Modular configuration](#modular-configuration) +- [multiple leader mode](#multiple-leader-mode) - Lazy-load 90% of plugins with [dein.vim] - Robust, yet light weight - [Unite centric work-flow](#unite-centric-work-flow) @@ -96,16 +97,19 @@ curl -sLf https://spacevim.org/install.sh | bash -s -- -h here is an example: ```viml -" here are some basic customizations, please refer to the top of the vimrc file for all possible options +" here are some basic customizations, please refer to the top of the vimrc +" file for all possible options let g:spacevim_default_indent = 3 let g:spacevim_max_column = 80 let g:spacevim_colorscheme = 'my_awesome_colorscheme' let g:spacevim_plugin_manager = 'dein' " neobundle or dein or vim-plug " change the default directory where all miscellaneous persistent files go -let g:spacevim_cache_dir = "/some/place/else" +" by default it is ~/.cache/vimfiles +let g:spacevim_plugin_bundle_dir = "/some/place/else" -" by default, language specific plugins are not loaded. this can be changed with the following: +" by default, language specific plugins are not loaded. this can be changed +" with the following: let g:spacevim_plugin_groups_exclude = ['ruby', 'python'] " if there are groups you want always loaded, you can use this: @@ -114,7 +118,8 @@ let g:spacevim_plugin_groups_include = ['go'] " alternatively, you can set this variable to load exactly what you want let g:spacevim_plugin_groups = ['core', 'web'] -" if there is a particular plugin you don't like, you can define this variable to disable them entirely +" if there is a particular plugin you don't like, you can define this +" variable to disable them entirely let g:spacevim_disabled_plugins=['vim-foo', 'vim-bar'] " if you want to add some custom plugins, use this options. let g:spacevim_custom_plugins = [ @@ -127,6 +132,17 @@ set wildignore+=\*/node_modules/\* set guifont=Wingdings:h10 ``` +#### multiple leader mode +##### global origin vim leader, default : `\` +vim's origin global leader can be used in all the mode. +##### local origin vim leader, default : `,` +vim's origin local leader can be used in all the mode. +##### windows function leader, default : `s` +windows function leader can only be used in normal mode. +for the list of mappings see the [link](#window-management) +##### unite work flow leader, default : `f` +unite work flow leader can only be used in normal mode. unite leader need unite groups. + #### Unite centric work-flow - List all the plugins has been installed, fuzzy find what you want, default action is open the github website of current plugin. default key is `lp` diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 58c10b5b6..cb19c68cd 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -36,6 +36,17 @@ let g:spacevim_enable_guicolors = 1 " let g:spacevim_enable_googlesuggest = 1 " < let g:spacevim_enable_googlesuggest = 0 +"" +" Windows function leader of SpaceVim, default is `s`, set to empty to disable +" this feature, or you can set to other char. +" > +" let g:spacevim_windows_leader = '' +" < +let g:spacevim_windows_leader = 's' +"" +" Unite work flow leader of SpaceVim, default is `f`, set to empty to disable +" this feature, or you can set to other char. +let g:spacevim_unite_leader = 'f' let g:spacevim_neobundle_installed = 0 let g:spacevim_dein_installed = 0 let g:spacevim_vim_plug_installed = 0 @@ -121,7 +132,7 @@ let g:spacevim_plugin_groups_exclude = [] "" -" groups of plugins should be loaded. +" groups of plugins should be loaded. " " example: > " let g:spacevim_plugin_groups = ['core', 'lang'] @@ -230,6 +241,12 @@ function! SpaceVim#Layer(layer) abort endfunction function! SpaceVim#end() abort + if !empty(g:spacevim_windows_leader) + call SpaceVim#mapping#leader#defindWindowsLeader(g:spacevim_windows_leader) + endif + if !empty(g:spacevim_unite_leader) + call SpaceVim#mapping#leader#defindUniteLeader(g:spacevim_unite_leader) + endif if g:spacevim_simple_mode let g:spacevim_plugin_groups = ['core'] else diff --git a/autoload/SpaceVim/default.vim b/autoload/SpaceVim/default.vim index 6bd9a89d3..1d430f84a 100644 --- a/autoload/SpaceVim/default.vim +++ b/autoload/SpaceVim/default.vim @@ -347,22 +347,8 @@ function! SpaceVim#default#SetMappings() abort \ ':call zvim#util#CopyToClipboard(3)', \ 'Yank the github link of current selection to X11 clipboard', \ 'call zvim#util#CopyToClipboard(3)') - " Window prefix - call zvim#util#defineMap('nnoremap', '[Window]', '' , 'Defind window prefix' ,'normal [Window]') - call zvim#util#defineMap('nmap' , 's' , '[Window]', 'Use s as window prefix' ,'normal s') - call zvim#util#defineMap('nnoremap ', '', ':wincmd w', 'Switch to next window or tab','wincmd w') call zvim#util#defineMap('nnoremap ', '', ':wincmd p', 'Switch to previous window or tab','wincmd p') - call zvim#util#defineMap('nnoremap ', '[Window]p', ':vsplit:wincmd w', - \'vsplit vertically,switch to next window','vsplit | wincmd w') - call zvim#util#defineMap('nnoremap ', '[Window]v', ':split', 'split window','split') - call zvim#util#defineMap('nnoremap ', '[Window]g', ':vsplit', 'vsplit window','vsplit') - call zvim#util#defineMap('nnoremap ', '[Window]t', ':tabnew', 'Create new tab','tabnew') - call zvim#util#defineMap('nnoremap ', '[Window]o', ':only', 'Close other windows','only') - call zvim#util#defineMap('nnoremap ', '[Window]x', ':call zvim#util#BufferEmpty()', - \'Empty current buffer','call zvim#util#BufferEmpty()') - call zvim#util#defineMap('nnoremap ', '[Window]\', ':b#', 'Switch to the last buffer','b#') - call zvim#util#defineMap('nnoremap ', '[Window]q', ':close', 'Close current windows','close') call zvim#util#defineMap('nnoremap ', 'q', ':call zvim#util#SmartClose()', \ 'Smart close windows', \ 'call zvim#util#SmartClose()') diff --git a/autoload/SpaceVim/mapping/leader.vim b/autoload/SpaceVim/mapping/leader.vim new file mode 100644 index 000000000..0bdfc8f8c --- /dev/null +++ b/autoload/SpaceVim/mapping/leader.vim @@ -0,0 +1,46 @@ +function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort + if !empty(a:key) + call zvim#util#defineMap('nnoremap', '[Window]', '' , 'Defind window prefix' ,'normal [Window]') + call zvim#util#defineMap('nmap' , a:key, '[Window]', 'Use ' . a:key . ' as window prefix' ,'normal ' . a:key) + + call zvim#util#defineMap('nnoremap ', '[Window]p', ':vsplit:wincmd w', + \'vsplit vertically,switch to next window','vsplit | wincmd w') + call zvim#util#defineMap('nnoremap ', '[Window]v', ':split', 'split window','split') + call zvim#util#defineMap('nnoremap ', '[Window]g', ':vsplit', 'vsplit window','vsplit') + call zvim#util#defineMap('nnoremap ', '[Window]t', ':tabnew', 'Create new tab','tabnew') + call zvim#util#defineMap('nnoremap ', '[Window]o', ':only', 'Close other windows','only') + call zvim#util#defineMap('nnoremap ', '[Window]x', ':call zvim#util#BufferEmpty()', + \'Empty current buffer','call zvim#util#BufferEmpty()') + call zvim#util#defineMap('nnoremap ', '[Window]\', ':b#', 'Switch to the last buffer','b#') + call zvim#util#defineMap('nnoremap ', '[Window]q', ':close', 'Close current windows','close') + endif +endfunction + +function! SpaceVim#mapping#leader#defindUniteLeader(key) abort + if !empty(a:key) + " The prefix key. + nnoremap [unite] + exe 'nmap ' .a:key . ' [unite]' + nnoremap [unite]c :UniteWithCurrentDir + \ -buffer-name=files buffer bookmark file + nnoremap [unite]b :UniteWithBufferDir + \ -buffer-name=files -prompt=%\ buffer bookmark file + nnoremap [unite]r :Unite + \ -buffer-name=register register + nnoremap [unite]o :Unite -buffer-name=outline -start-insert -auto-preview -split outline + nnoremap [unite]s :Unite session + nnoremap [unite]n :Unite session/new + nnoremap [unite]fr + \ :Unite -buffer-name=resume resume + nnoremap [unite]ma + \ :Unite mapping + nnoremap [unite]me + \ :Unite output:message + nnoremap [unite]f :Unite source + nnoremap [unite]w + \ :Unite -buffer-name=files -no-split + \ jump_point file_point buffer_tab + \ file_rec:! file file/new + nnoremap [unite] :Unite -silent -ignorecase -winheight=17 -start-insert menu:CustomKeyMaps + endif +endfunction diff --git a/config/plugins/unite.vim b/config/plugins/unite.vim index 25ce22c70..215c4342b 100644 --- a/config/plugins/unite.vim +++ b/config/plugins/unite.vim @@ -229,30 +229,6 @@ nnoremap y :Unite -no-split -buffer-name=yank history/yank< " :Unite neobundle/search "for Unite menu{ nnoremap ug :Unite -silent -start-insert menu:git -" The prefix key. -nnoremap [unite] -nmap f [unite] -nnoremap [unite]c :UniteWithCurrentDir - \ -buffer-name=files buffer bookmark file -nnoremap [unite]b :UniteWithBufferDir - \ -buffer-name=files -prompt=%\ buffer bookmark file -nnoremap [unite]r :Unite - \ -buffer-name=register register -nnoremap [unite]o :Unite -buffer-name=outline -start-insert -auto-preview -split outline -nnoremap [unite]s :Unite session -nnoremap [unite]n :Unite session/new -nnoremap [unite]fr - \ :Unite -buffer-name=resume resume -nnoremap [unite]ma - \ :Unite mapping -nnoremap [unite]me - \ :Unite output:message -nnoremap [unite]f :Unite source -nnoremap [unite]w - \ :Unite -buffer-name=files -no-split - \ jump_point file_point buffer_tab - \ file_rec:! file file/new -nnoremap [unite] :Unite -silent -ignorecase -winheight=17 -start-insert menu:CustomKeyMaps nnoremap ls :Unite -silent -ignorecase -winheight=17 -start-insert menu:MyStarredrepos nnoremap lm :Unite -silent -ignorecase -winheight=17 -start-insert menu:MpvPlayer call zvim#util#loadMusics() diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 81a912951..29ff2832d 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -42,6 +42,17 @@ you can enable it by: let g:spacevim_enable_googlesuggest = 1 < + *g:spacevim_windows_leader* +Windows function leader of SpaceVim, default is `s`, set to empty to disable +this feature, or you can set to other char. +> + let g:spacevim_windows_leader = '' +< + + *g:spacevim_unite_leader* +Unite work flow leader of SpaceVim, default is `f`, set to empty to disable +this feature, or you can set to other char. + *g:spacevim_plugin_bundle_dir* Set the cache dir of plugins, by default, it is `~/.cache/vimfiles`. you can set it by: