From c7e16fad0358470d58b4b4e36eef471218bac0b7 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 17 Apr 2017 00:20:51 +0800 Subject: [PATCH 01/17] Add space prefix mapping --- autoload/SpaceVim.vim | 1 + autoload/SpaceVim/mapping/guide.vim | 4 +++- autoload/SpaceVim/mapping/leader.vim | 2 ++ autoload/SpaceVim/mapping/space.vim | 7 +++++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 autoload/SpaceVim/mapping/space.vim diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 0f601af4b..2a191785a 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -414,6 +414,7 @@ function! SpaceVim#end() abort call SpaceVim#mapping#guide#register_prefix_descriptions('', 'g:leaderGuide_map') endif call SpaceVim#mapping#leader#defindglobalMappings() + call SpaceVim#mapping#space#init() if g:spacevim_simple_mode let g:spacevim_plugin_groups = ['core'] else diff --git a/autoload/SpaceVim/mapping/guide.vim b/autoload/SpaceVim/mapping/guide.vim index 03c001af8..39c055e85 100644 --- a/autoload/SpaceVim/mapping/guide.vim +++ b/autoload/SpaceVim/mapping/guide.vim @@ -394,7 +394,7 @@ function! s:updateStatusline() abort hi! LeaderGuiderName cterm=bold gui=bold guifg=#282828 guibg=#fe8019 hi! LeaderGuiderSep2 cterm=bold gui=bold guifg=#fe8019 guibg=#3c3836 hi! LeaderGuiderFill guifg=#7c6f64 guibg=#3c3836 - exe 'setlocal statusline=%#LeaderGuiderPrompt#\ Leader\ Guide:\ ' . + exe 'setlocal statusline=%#LeaderGuiderPrompt#\ Mapping\ Guide:\ ' . \ '%#LeaderGuiderSep1#' . \ '%#LeaderGuiderName#' . \ SpaceVim#mapping#leader#getName(s:prefix_key) @@ -514,6 +514,8 @@ endif call SpaceVim#mapping#guide#register_prefix_descriptions('\', \ 'g:_spacevim_mappings') +call SpaceVim#mapping#guide#register_prefix_descriptions(' ', + \ 'g:_spacevim_mappings_space') call SpaceVim#mapping#guide#register_prefix_descriptions( \ g:spacevim_unite_leader, \ 'g:_spacevim_mappings_unite') diff --git a/autoload/SpaceVim/mapping/leader.vim b/autoload/SpaceVim/mapping/leader.vim index 72c923ecd..4846ac86c 100644 --- a/autoload/SpaceVim/mapping/leader.vim +++ b/autoload/SpaceVim/mapping/leader.vim @@ -287,6 +287,8 @@ function! SpaceVim#mapping#leader#getName(key) abort return '[unite]' elseif a:key == g:spacevim_denite_leader return '[denite]' + elseif a:key == ' ' + return '[SPC]' else return '' endif diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim new file mode 100644 index 000000000..96d779163 --- /dev/null +++ b/autoload/SpaceVim/mapping/space.vim @@ -0,0 +1,7 @@ +function! SpaceVim#mapping#space#init() abort + nnoremap [SPC] :LeaderGuide " " + nmap [SPC] + let g:_spacevim_mappings_space = {} + let g:_spacevim_mappings_space.t = {'name' : 'Toggle editor visuals'} + nnoremap [SPC]tn :set nu! +endfunction From f10b80b00e074e177827eafe0ae07f1ce4a1863d Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 17 Apr 2017 20:24:31 +0800 Subject: [PATCH 02/17] Add highlight for groupname in guide --- syntax/leaderGuide.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/syntax/leaderGuide.vim b/syntax/leaderGuide.vim index 0653f522c..f30655fa4 100644 --- a/syntax/leaderGuide.vim +++ b/syntax/leaderGuide.vim @@ -7,9 +7,13 @@ syn region LeaderGuideKeys start="\["hs=e+1 end="\]\s"he=s-1 \ contained syn region LeaderGuideBrackets start="\(^\|\s\+\)\[" end="\]\s\+" \ contains=LeaderGuideKeys keepend +syn match LeaderGuideGroupName /+\w\+/ contained syn region LeaderGuideDesc start="^" end="$" - \ contains=LeaderGuideBrackets + \ contains=LeaderGuideBrackets,LeaderGuideGroupName hi def link LeaderGuideDesc Identifier hi def link LeaderGuideKeys Type hi def link LeaderGuideBrackets Delimiter +hi def link LeaderGuideGroupName GruvboxPurpleBold + + From 75cffccad60233475f2386006e879c1479d00c29 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 17 Apr 2017 20:40:13 +0800 Subject: [PATCH 03/17] Improve space mapping --- autoload/SpaceVim/autocmds.vim | 1 + autoload/SpaceVim/layers/git.vim | 2 +- autoload/SpaceVim/mapping/space.vim | 3 ++- syntax/leaderGuide.vim | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/autoload/SpaceVim/autocmds.vim b/autoload/SpaceVim/autocmds.vim index 999acc0b2..ac51477e6 100644 --- a/autoload/SpaceVim/autocmds.vim +++ b/autoload/SpaceVim/autocmds.vim @@ -103,6 +103,7 @@ endfunction function! s:fix_gruvbox() abort hi VertSplit guibg=#282828 guifg=#181A1F + hi SpaceVimLeaderGuiderGroupName cterm=bold ctermfg=175 gui=bold guifg=#d3869b endfunction " vim:set et sw=2: diff --git a/autoload/SpaceVim/layers/git.vim b/autoload/SpaceVim/layers/git.vim index 5d3266dde..55f139e75 100644 --- a/autoload/SpaceVim/layers/git.vim +++ b/autoload/SpaceVim/layers/git.vim @@ -23,7 +23,7 @@ function! SpaceVim#layers#git#config() abort nnoremap gp :Gina push nnoremap ga :Gina add % nnoremap gA :Gina add . - let g:_spacevim_mappings.g = {'name' : 'git function', + let g:_spacevim_mappings.g = {'name' : '+git function', \ 'd' : ['Gina diff', 'git diff'], \ 's' : ['Gina status', 'git status'], \ 'c' : ['Gina commit', 'git commit'], diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 96d779163..5197dcddd 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -2,6 +2,7 @@ function! SpaceVim#mapping#space#init() abort nnoremap [SPC] :LeaderGuide " " nmap [SPC] let g:_spacevim_mappings_space = {} - let g:_spacevim_mappings_space.t = {'name' : 'Toggle editor visuals'} + let g:_spacevim_mappings_space.t = {'name' : '+Toggle editor visuals'} nnoremap [SPC]tn :set nu! + let g:_spacevim_mappings_space.t.n = ['set nu!', 'toggle line number'] endfunction diff --git a/syntax/leaderGuide.vim b/syntax/leaderGuide.vim index f30655fa4..0dd3c1e5f 100644 --- a/syntax/leaderGuide.vim +++ b/syntax/leaderGuide.vim @@ -7,13 +7,13 @@ syn region LeaderGuideKeys start="\["hs=e+1 end="\]\s"he=s-1 \ contained syn region LeaderGuideBrackets start="\(^\|\s\+\)\[" end="\]\s\+" \ contains=LeaderGuideKeys keepend -syn match LeaderGuideGroupName /+\w\+/ contained +syn match LeaderGuideGroupName /+[^\[^\]]\+/ contained syn region LeaderGuideDesc start="^" end="$" \ contains=LeaderGuideBrackets,LeaderGuideGroupName hi def link LeaderGuideDesc Identifier hi def link LeaderGuideKeys Type hi def link LeaderGuideBrackets Delimiter -hi def link LeaderGuideGroupName GruvboxPurpleBold +hi def link LeaderGuideGroupName SpaceVimLeaderGuiderGroupName From a381ad8cc26c2d5c91c494fa104d49293f51cd21 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 17 Apr 2017 21:07:39 +0800 Subject: [PATCH 04/17] Add windows mapping --- autoload/SpaceVim/mapping/space.vim | 21 +++++++++++++++++++++ config/plugins/vim-airline.vim | 11 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 5197dcddd..5454ac369 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -6,3 +6,24 @@ function! SpaceVim#mapping#space#init() abort nnoremap [SPC]tn :set nu! let g:_spacevim_mappings_space.t.n = ['set nu!', 'toggle line number'] endfunction + +function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort + if a:is_cmd + let cmd = ':' . a:cmd . '' + let lcmd = a:cmd + else + let cmd = a:cmd + let feedkey_m = a:m =~# 'nore' ? 'n' : 'm' + if a:cmd =~? '^' + let lcmd = 'call feedkeys("\' . a:cmd . '", "' . feedkey_m . '")' + else + let lcmd = 'call feedkeys("' . a:cmd . '", "' . feedkey_m . '")' + endif + endif + exe a:m . ' [SPC]' . join(a:keys) . ' ' . cmd + if len(a:keys) == 2 + let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]] = [lcmd, a:desc] + elseif len(a:keys) == 1 + let g:_spacevim_mappings_space[a:keys[0]] = [lcmd, a:desc] + endif +endfunction diff --git a/config/plugins/vim-airline.vim b/config/plugins/vim-airline.vim index 977b8258f..313df60f3 100644 --- a/config/plugins/vim-airline.vim +++ b/config/plugins/vim-airline.vim @@ -49,6 +49,17 @@ call SpaceVim#mapping#def('nmap', '8', 'AirlineSelectTab8', 'Switc call SpaceVim#mapping#def('nmap', '9', 'AirlineSelectTab9', 'Switch to airline tab 9', '', 'window 9') call SpaceVim#mapping#def('nmap', '-', 'AirlineSelectPrevTab', 'Switch to previous airline tag', '', 'window previous') call SpaceVim#mapping#def('nmap', '+', 'AirlineSelectNextTab', 'Switch to next airline tag', '', 'window next') +call SpaceVim#mapping#space#def('nmap', [1], 'AirlineSelectTab1', 'window 1', 0) +call SpaceVim#mapping#space#def('nmap', [2], 'AirlineSelectTab2', 'window 2', 0) +call SpaceVim#mapping#space#def('nmap', [3], 'AirlineSelectTab3', 'window 3', 0) +call SpaceVim#mapping#space#def('nmap', [4], 'AirlineSelectTab4', 'window 4', 0) +call SpaceVim#mapping#space#def('nmap', [5], 'AirlineSelectTab5', 'window 5', 0) +call SpaceVim#mapping#space#def('nmap', [6], 'AirlineSelectTab6', 'window 6', 0) +call SpaceVim#mapping#space#def('nmap', [7], 'AirlineSelectTab7', 'window 7', 0) +call SpaceVim#mapping#space#def('nmap', [8], 'AirlineSelectTab8', 'window 8', 0) +call SpaceVim#mapping#space#def('nmap', [9], 'AirlineSelectTab9', 'window 9', 0) +call SpaceVim#mapping#space#def('nmap', ['-'], 'AirlineSelectPrevTab', 'window previous', 0) +call SpaceVim#mapping#space#def('nmap', ['+'], 'AirlineSelectNextTab', 'window next', 0) if !exists('g:airline_symbols') let g:airline_symbols = {} endif From bec852e1e080d7e5cdee82d91947981e02b4ea17 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 17 Apr 2017 21:41:06 +0800 Subject: [PATCH 05/17] Add vim calendar --- autoload/SpaceVim/layers/tools.vim | 1 + autoload/SpaceVim/mapping/space.vim | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/tools.vim b/autoload/SpaceVim/layers/tools.vim index 408e20e51..efb76e189 100644 --- a/autoload/SpaceVim/layers/tools.vim +++ b/autoload/SpaceVim/layers/tools.vim @@ -46,6 +46,7 @@ function! SpaceVim#layers#tools#plugins() abort endfunction function! SpaceVim#layers#tools#config() abort + call SpaceVim#mapping#space#def('nnoremap', ['a', 'c'], 'Calendar', 'vim calendar', 1) nmap mm BookmarkToggle nmap mi BookmarkAnnotate nmap ma BookmarkShowAll diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 5454ac369..5c22753a6 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -3,6 +3,10 @@ function! SpaceVim#mapping#space#init() abort nmap [SPC] let g:_spacevim_mappings_space = {} let g:_spacevim_mappings_space.t = {'name' : '+Toggle editor visuals'} + let g:_spacevim_mappings_space.a = {'name' : '+Applications'} + let g:_spacevim_mappings_space.b = {'name' : '+Buffers'} + let g:_spacevim_mappings_space.e = {'name' : '+Errors'} + let g:_spacevim_mappings_space.B = {'name' : '+Global-uffers'} nnoremap [SPC]tn :set nu! let g:_spacevim_mappings_space.t.n = ['set nu!', 'toggle line number'] endfunction @@ -20,7 +24,7 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort let lcmd = 'call feedkeys("' . a:cmd . '", "' . feedkey_m . '")' endif endif - exe a:m . ' [SPC]' . join(a:keys) . ' ' . cmd + exe a:m . ' [SPC]' . join(a:keys, '') . ' ' . cmd if len(a:keys) == 2 let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]] = [lcmd, a:desc] elseif len(a:keys) == 1 From d46d6424b9c10fbd1d0ae5b83556c8d5ef47c8ee Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 17 Apr 2017 21:56:58 +0800 Subject: [PATCH 06/17] Add fancy start screen --- config/plugins/vim-startify.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/plugins/vim-startify.vim b/config/plugins/vim-startify.vim index 20cab1b65..8247d7ae0 100644 --- a/config/plugins/vim-startify.vim +++ b/config/plugins/vim-startify.vim @@ -58,4 +58,6 @@ augroup startify_map autocmd FileType startify set scrolloff=0 augroup END +call SpaceVim#mapping#space#def('nnoremap', ['a','s'], 'Startify', 'fancy start screen',1) + " vim:set et sw=2: From 1f16e7b9aa7e8f9ad1297037deba83d04ce7cccd Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 17 Apr 2017 23:41:01 +0800 Subject: [PATCH 07/17] Add errors mappings --- autoload/SpaceVim/autocmds.vim | 8 +++++++- autoload/SpaceVim/layers/checkers.vim | 8 ++++++++ autoload/SpaceVim/mapping/space.vim | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/autocmds.vim b/autoload/SpaceVim/autocmds.vim index ac51477e6..941ad02d8 100644 --- a/autoload/SpaceVim/autocmds.vim +++ b/autoload/SpaceVim/autocmds.vim @@ -102,7 +102,13 @@ function! s:generate_doc() abort endfunction function! s:fix_gruvbox() abort - hi VertSplit guibg=#282828 guifg=#181A1F + if &background ==# 'dark' + hi VertSplit guibg=#282828 guifg=#181A1F + hi EndOfBuffer guibg=#282828 guifg=#282828 + else + hi VertSplit guibg=#fbf1c7 guifg=#e7e9e1 + hi EndOfBuffer guibg=#fbf1c7 guifg=#fbf1c7 + endif hi SpaceVimLeaderGuiderGroupName cterm=bold ctermfg=175 gui=bold guifg=#d3869b endfunction diff --git a/autoload/SpaceVim/layers/checkers.vim b/autoload/SpaceVim/layers/checkers.vim index 60a83d7aa..da56e860c 100644 --- a/autoload/SpaceVim/layers/checkers.vim +++ b/autoload/SpaceVim/layers/checkers.vim @@ -14,3 +14,11 @@ function! SpaceVim#layers#checkers#plugins() abort return plugins endfunction + + +function! SpaceVim#layers#checkers#config() abort + call SpaceVim#mapping#space#def('nnoremap', ['e', '.'], 'lopen', 'error-transient-state', 1) + call SpaceVim#mapping#space#def('nnoremap', ['e', 'n'], 'lnext', 'next-error', 1) + call SpaceVim#mapping#space#def('nnoremap', ['e', 'p'], 'lprevious', 'previous-error', 1) + call SpaceVim#mapping#space#def('nnoremap', ['e', 'N'], 'lNext', 'previous-error', 1) +endfunction diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 5c22753a6..ebd3017b6 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -5,6 +5,12 @@ function! SpaceVim#mapping#space#init() abort let g:_spacevim_mappings_space.t = {'name' : '+Toggle editor visuals'} let g:_spacevim_mappings_space.a = {'name' : '+Applications'} let g:_spacevim_mappings_space.b = {'name' : '+Buffers'} + nnoremap [SPC]bn :bnext + let g:_spacevim_mappings_space.b.n = ['bnext', 'next buffer'] + nnoremap [SPC]bp :bp + nnoremap [SPC]bN :bN + let g:_spacevim_mappings_space.b.p = ['bp', 'previous buffer'] + let g:_spacevim_mappings_space.b.N = ['bN', 'previous buffer'] let g:_spacevim_mappings_space.e = {'name' : '+Errors'} let g:_spacevim_mappings_space.B = {'name' : '+Global-uffers'} nnoremap [SPC]tn :set nu! From c51a60d58626149fb1d211647442a03dfacd0782 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 17 Apr 2017 23:52:59 +0800 Subject: [PATCH 08/17] Add shell cmd mapping --- autoload/SpaceVim/default.vim | 1 + autoload/SpaceVim/layers/default.vim | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/default.vim b/autoload/SpaceVim/default.vim index a4cd48c51..1dd319690 100644 --- a/autoload/SpaceVim/default.vim +++ b/autoload/SpaceVim/default.vim @@ -132,6 +132,7 @@ function! SpaceVim#default#SetPlugins() abort call add(g:spacevim_plugin_groups, 'misc') call add(g:spacevim_plugin_groups, 'core') + call add(g:spacevim_plugin_groups, 'default') call add(g:spacevim_plugin_groups, 'unite') call add(g:spacevim_plugin_groups, 'github') if has('python3') diff --git a/autoload/SpaceVim/layers/default.vim b/autoload/SpaceVim/layers/default.vim index 2c3eca768..de63899fe 100644 --- a/autoload/SpaceVim/layers/default.vim +++ b/autoload/SpaceVim/layers/default.vim @@ -9,5 +9,9 @@ function! SpaceVim#layers#default#plugins() abort endfunction function! SpaceVim#layers#default#config() abort - + if has('nvim') + call SpaceVim#mapping#space#def('nnoremap', ['!'], 'te', 'shell cmd', 1) + else + call SpaceVim#mapping#space#def('nnoremap', ['!'], ':!', 'shell cmd', 0) + endif endfunction From ed6d162dda2a1460c3be500dcda1c3895a28d9c8 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 18 Apr 2017 00:01:34 +0800 Subject: [PATCH 09/17] Use unite shellcmd output --- autoload/SpaceVim/layers/default.vim | 5 ----- autoload/SpaceVim/layers/unite.vim | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/autoload/SpaceVim/layers/default.vim b/autoload/SpaceVim/layers/default.vim index de63899fe..45457d31c 100644 --- a/autoload/SpaceVim/layers/default.vim +++ b/autoload/SpaceVim/layers/default.vim @@ -9,9 +9,4 @@ function! SpaceVim#layers#default#plugins() abort endfunction function! SpaceVim#layers#default#config() abort - if has('nvim') - call SpaceVim#mapping#space#def('nnoremap', ['!'], 'te', 'shell cmd', 1) - else - call SpaceVim#mapping#space#def('nnoremap', ['!'], ':!', 'shell cmd', 0) - endif endfunction diff --git a/autoload/SpaceVim/layers/unite.vim b/autoload/SpaceVim/layers/unite.vim index b2d7f3963..9f9109379 100644 --- a/autoload/SpaceVim/layers/unite.vim +++ b/autoload/SpaceVim/layers/unite.vim @@ -78,4 +78,5 @@ function! SpaceVim#layers#unite#plugins() abort endfunction function! SpaceVim#layers#unite#config() abort + call SpaceVim#mapping#space#def('nnoremap', ['!'], 'Unite output/shellcmd -start-insert', 'shell cmd', 1) endfunction From fd3a26beff5b8817d6c2f169a6ba1c3b2dc11c82 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 18 Apr 2017 21:39:09 +0800 Subject: [PATCH 10/17] Add flag for space mapping --- autoload/SpaceVim/mapping/space.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index ebd3017b6..d9743e529 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -1,4 +1,7 @@ function! SpaceVim#mapping#space#init() abort + if s:has_map_to_spc() + return + endif nnoremap [SPC] :LeaderGuide " " nmap [SPC] let g:_spacevim_mappings_space = {} @@ -18,6 +21,9 @@ function! SpaceVim#mapping#space#init() abort endfunction function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort + if s:has_map_to_spc() + return + endif if a:is_cmd let cmd = ':' . a:cmd . '' let lcmd = a:cmd @@ -37,3 +43,10 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort let g:_spacevim_mappings_space[a:keys[0]] = [lcmd, a:desc] endif endfunction + +function! s:has_map_to_spc() abort + if !exists('s:flag') + let s:flag = !empty(maparg('', '',0,1)) + endif + return s:flag +endfunction From 2f7fda525f2e36c444aa387bb57cd18e7744bca1 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 18 Apr 2017 22:04:56 +0800 Subject: [PATCH 11/17] Add SPC? mapping --- autoload/SpaceVim/mapping.vim | 9 +++++++++ autoload/SpaceVim/mapping/space.vim | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/autoload/SpaceVim/mapping.vim b/autoload/SpaceVim/mapping.vim index 77f5d4951..4059b5785 100644 --- a/autoload/SpaceVim/mapping.vim +++ b/autoload/SpaceVim/mapping.vim @@ -207,7 +207,16 @@ function! SpaceVim#mapping#close_term_buffer(...) abort endif endif endif +endfunction +function! SpaceVim#mapping#menu(desc, key, cmd) abort + let description = '➤ ' + \. a:desc + \. repeat(' ', 80 - len(a:desc) - len(a:key)) + \. a:key + call add(g:unite_source_menu_menus.CustomKeyMaps.command_candidates, + \ [description , + \ a:cmd]) endfunction " vim:set et sw=2 cc=80: diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index d9743e529..ef6e86031 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -5,19 +5,24 @@ function! SpaceVim#mapping#space#init() abort nnoremap [SPC] :LeaderGuide " " nmap [SPC] let g:_spacevim_mappings_space = {} + let g:_spacevim_mappings_space['?'] = ['Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings'] let g:_spacevim_mappings_space.t = {'name' : '+Toggle editor visuals'} let g:_spacevim_mappings_space.a = {'name' : '+Applications'} let g:_spacevim_mappings_space.b = {'name' : '+Buffers'} nnoremap [SPC]bn :bnext let g:_spacevim_mappings_space.b.n = ['bnext', 'next buffer'] + call SpaceVim#mapping#menu('Open next buffer', '[SPC]bn', 'bp') nnoremap [SPC]bp :bp nnoremap [SPC]bN :bN let g:_spacevim_mappings_space.b.p = ['bp', 'previous buffer'] + call SpaceVim#mapping#menu('Open previous buffer', '[SPC]bp', 'bp') let g:_spacevim_mappings_space.b.N = ['bN', 'previous buffer'] + call SpaceVim#mapping#menu('Open previous buffer', '[SPC]bN', 'bp') let g:_spacevim_mappings_space.e = {'name' : '+Errors'} let g:_spacevim_mappings_space.B = {'name' : '+Global-uffers'} nnoremap [SPC]tn :set nu! let g:_spacevim_mappings_space.t.n = ['set nu!', 'toggle line number'] + call SpaceVim#mapping#menu('toggle line number', '[SPC]tn', 'set nu!') endfunction function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort @@ -42,6 +47,7 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort elseif len(a:keys) == 1 let g:_spacevim_mappings_space[a:keys[0]] = [lcmd, a:desc] endif + call SpaceVim#mapping#menu(a:desc, '[SPC]' . join(a:keys, ''), lcmd) endfunction function! s:has_map_to_spc() abort From 39fe17058bd86faa4c78eb1a043aa2b7a44618af Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 18 Apr 2017 22:31:49 +0800 Subject: [PATCH 12/17] Add +files group mappings --- autoload/SpaceVim/layers/default.vim | 2 ++ autoload/SpaceVim/mapping/space.vim | 1 + 2 files changed, 3 insertions(+) diff --git a/autoload/SpaceVim/layers/default.vim b/autoload/SpaceVim/layers/default.vim index 45457d31c..d807e27d9 100644 --- a/autoload/SpaceVim/layers/default.vim +++ b/autoload/SpaceVim/layers/default.vim @@ -9,4 +9,6 @@ function! SpaceVim#layers#default#plugins() abort endfunction function! SpaceVim#layers#default#config() abort + call SpaceVim#mapping#space#def('nnoremap', ['f', 's'], 'write', 'save buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 'S'], 'wall', 'save all buffer', 1) endfunction diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index ef6e86031..4e6a92b58 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -9,6 +9,7 @@ function! SpaceVim#mapping#space#init() abort let g:_spacevim_mappings_space.t = {'name' : '+Toggle editor visuals'} let g:_spacevim_mappings_space.a = {'name' : '+Applications'} let g:_spacevim_mappings_space.b = {'name' : '+Buffers'} + let g:_spacevim_mappings_space.f = {'name' : '+Files'} nnoremap [SPC]bn :bnext let g:_spacevim_mappings_space.b.n = ['bnext', 'next buffer'] call SpaceVim#mapping#menu('Open next buffer', '[SPC]bn', 'bp') From 32d52c4db5a1d9ff5ec13c3a037f4a43ef348ea9 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 18 Apr 2017 22:57:38 +0800 Subject: [PATCH 13/17] Fix leader mapping --- autoload/SpaceVim/mapping/guide.vim | 13 +++++++++---- autoload/SpaceVim/mapping/space.vim | 5 +---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/autoload/SpaceVim/mapping/guide.vim b/autoload/SpaceVim/mapping/guide.vim index 39c055e85..80875b030 100644 --- a/autoload/SpaceVim/mapping/guide.vim +++ b/autoload/SpaceVim/mapping/guide.vim @@ -512,10 +512,15 @@ if !exists("g:leaderGuide_displayfunc") let g:leaderGuide_displayfunc = [function("s:leaderGuide_display")] endif -call SpaceVim#mapping#guide#register_prefix_descriptions('\', - \ 'g:_spacevim_mappings') -call SpaceVim#mapping#guide#register_prefix_descriptions(' ', - \ 'g:_spacevim_mappings_space') +if get(g:, 'mapleader', '\') == ' ' + call SpaceVim#mapping#guide#register_prefix_descriptions(' ', + \ 'g:_spacevim_mappings') +else + call SpaceVim#mapping#guide#register_prefix_descriptions('\', + \ 'g:_spacevim_mappings') + call SpaceVim#mapping#guide#register_prefix_descriptions(' ', + \ 'g:_spacevim_mappings_space') +endif call SpaceVim#mapping#guide#register_prefix_descriptions( \ g:spacevim_unite_leader, \ 'g:_spacevim_mappings_unite') diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 4e6a92b58..f14718273 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -52,8 +52,5 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort endfunction function! s:has_map_to_spc() abort - if !exists('s:flag') - let s:flag = !empty(maparg('', '',0,1)) - endif - return s:flag + return get(g:, 'mapleader', '\') == ' ' endfunction From c354ee5232673c47ffe189557cf99833f6e91f63 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 18 Apr 2017 23:55:34 +0800 Subject: [PATCH 14/17] Add toggle theme mapping --- autoload/SpaceVim/layers/colorscheme.vim | 26 ++++++++++++++++++++++++ autoload/SpaceVim/layers/ui.vim | 20 ++++++++++++++++++ autoload/SpaceVim/mapping/space.vim | 3 ++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/colorscheme.vim b/autoload/SpaceVim/layers/colorscheme.vim index 348b9b76c..9d989f645 100644 --- a/autoload/SpaceVim/layers/colorscheme.vim +++ b/autoload/SpaceVim/layers/colorscheme.vim @@ -173,3 +173,29 @@ function! SpaceVim#layers#colorscheme#plugins() abort \ ['jacoborus/tender'], \ ] endfunction + +let s:cs = ['gruvbox', 'molokai', 'onedark', 'jellybeans'] +let s:Number = SpaceVim#api#import('data#number') +function! SpaceVim#layers#colorscheme#config() abort + call SpaceVim#mapping#space#def('nnoremap', ['T', 'n'], + \ 'call call(' . string(s:_function('s:cycle_spacevim_theme')) + \ . ', [])', 'cycle-spacevim-theme', 1) +endfunction +" function() wrapper +if v:version > 703 || v:version == 703 && has('patch1170') + function! s:_function(fstr) abort + return function(a:fstr) + endfunction +else + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + let s:_s = '' . s:_SID() . '_' + function! s:_function(fstr) abort + return function(substitute(a:fstr, 's:', s:_s, 'g')) + endfunction +endif +function! s:cycle_spacevim_theme() abort + let id = s:Number.random(0, len(s:cs)) + exe 'colorscheme ' . s:cs[id] +endfunction diff --git a/autoload/SpaceVim/layers/ui.vim b/autoload/SpaceVim/layers/ui.vim index a13611bb6..0633feda4 100644 --- a/autoload/SpaceVim/layers/ui.vim +++ b/autoload/SpaceVim/layers/ui.vim @@ -22,4 +22,24 @@ function! SpaceVim#layers#ui#config() abort let g:signify_disable_by_default = 0 let g:signify_line_highlight = 0 noremap :TagbarToggle + " Ui toggles + call SpaceVim#mapping#space#def('nnoremap', ['T', 'F'], '', 'fullscreen-frame', 0) + call SpaceVim#mapping#space#def('nnoremap', ['T', 'm'], 'call call(' . string(s:_function('s:toggle_menu_bar')) . ', [])', 'menu-bar', 1) +endfunction +" function() wrapper +if v:version > 703 || v:version == 703 && has('patch1170') + function! s:_function(fstr) abort + return function(a:fstr) + endfunction +else + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + let s:_s = '' . s:_SID() . '_' + function! s:_function(fstr) abort + return function(substitute(a:fstr, 's:', s:_s, 'g')) + endfunction +endif +function! s:toggle_menu_bar() abort + echom 1 endfunction diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index f14718273..e8a58aeeb 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -6,7 +6,8 @@ function! SpaceVim#mapping#space#init() abort nmap [SPC] let g:_spacevim_mappings_space = {} let g:_spacevim_mappings_space['?'] = ['Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings'] - let g:_spacevim_mappings_space.t = {'name' : '+Toggle editor visuals'} + let g:_spacevim_mappings_space.t = {'name' : '+Toggles'} + let g:_spacevim_mappings_space.T = {'name' : '+UI toggles/themes'} let g:_spacevim_mappings_space.a = {'name' : '+Applications'} let g:_spacevim_mappings_space.b = {'name' : '+Buffers'} let g:_spacevim_mappings_space.f = {'name' : '+Files'} From cfca2923d4f36296a333115412b910aeacf37542 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 19 Apr 2017 00:01:51 +0800 Subject: [PATCH 15/17] Add [SPC]Ts for colorschemes --- autoload/SpaceVim/layers/colorscheme.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoload/SpaceVim/layers/colorscheme.vim b/autoload/SpaceVim/layers/colorscheme.vim index 9d989f645..e7e72c65e 100644 --- a/autoload/SpaceVim/layers/colorscheme.vim +++ b/autoload/SpaceVim/layers/colorscheme.vim @@ -176,11 +176,15 @@ endfunction let s:cs = ['gruvbox', 'molokai', 'onedark', 'jellybeans'] let s:Number = SpaceVim#api#import('data#number') + function! SpaceVim#layers#colorscheme#config() abort call SpaceVim#mapping#space#def('nnoremap', ['T', 'n'], \ 'call call(' . string(s:_function('s:cycle_spacevim_theme')) \ . ', [])', 'cycle-spacevim-theme', 1) + call SpaceVim#mapping#space#def('nnoremap', ['T', 's'], 'Unite colorscheme', 'unite-colorschemes', 1) endfunction + + " function() wrapper if v:version > 703 || v:version == 703 && has('patch1170') function! s:_function(fstr) abort From 91199f6cc621113616711a33ee401ddacb4decff Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 19 Apr 2017 00:11:05 +0800 Subject: [PATCH 16/17] Remame desc of [SPC]/ --- autoload/SpaceVim/layers/incsearch.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/SpaceVim/layers/incsearch.vim b/autoload/SpaceVim/layers/incsearch.vim index 40fdf54a4..ce5d07417 100644 --- a/autoload/SpaceVim/layers/incsearch.vim +++ b/autoload/SpaceVim/layers/incsearch.vim @@ -66,4 +66,5 @@ function! SpaceVim#layers#incsearch#config() abort endfunction noremap / incsearch#go(config_easyfuzzymotion()) + call SpaceVim#mapping#space#def('nnoremap', ['/',], 'call feedkeys("\/", "m")', 'incsearch-fuzzy', 1) endfunction From 1f9cf1033e37b6ee437f5af90801a911d4647fce Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 19 Apr 2017 00:19:26 +0800 Subject: [PATCH 17/17] Update pic in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f5d89e2cf..4d331a789 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ to select the layers they need. It got inspired by [spacemacs](https://github.co please star it on github. It's a great way of getting feedback and gives me the kick to put more time into development. -![2017-02-26_1365x739](https://cloud.githubusercontent.com/assets/13142418/23339920/590f2e9a-fc67-11e6-99ec-794f79ba0902.png) +![2017-04-19-00 17 33](https://cloud.githubusercontent.com/assets/13142418/25141441/220b3a54-2496-11e7-9462-fcfdccb7aad8.png) If you are new to vim, you should learning about Vim in general, read [vim-galore](https://github.com/mhinz/vim-galore).