From 4005a767dcd0d8e97e91ef4df6542087bce53a90 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 26 Aug 2017 21:45:38 +0800 Subject: [PATCH] Add help desc --- autoload/SpaceVim/layers/default.vim | 212 ++++++++++++++------------- autoload/SpaceVim/mapping/space.vim | 26 +++- syntax/HelpDescribe.vim | 8 + 3 files changed, 140 insertions(+), 106 deletions(-) create mode 100644 syntax/HelpDescribe.vim diff --git a/autoload/SpaceVim/layers/default.vim b/autoload/SpaceVim/layers/default.vim index 8103aaa9d..c8761dadd 100644 --- a/autoload/SpaceVim/layers/default.vim +++ b/autoload/SpaceVim/layers/default.vim @@ -2,12 +2,15 @@ " @section Default, default " @parentsection layers +let s:filename = expand(':~') + function! SpaceVim#layers#default#plugins() abort let plugins = [] return plugins endfunction +let s:lnum = expand('') + 3 function! SpaceVim#layers#default#config() abort " Unimpaired bindings " Quickly add empty lines @@ -47,7 +50,20 @@ function! SpaceVim#layers#default#config() abort " Select last paste nnoremap gp '`['.strpart(getregtype(), 0, 1).'`]' - call SpaceVim#mapping#space#def('nnoremap', ['f', 'f'], "exe 'CtrlP ' . fnamemodify(bufname('%'), ':h')", 'Find files in the directory of the current buffer', 1) + let lnum = expand('') + s:lnum - 1 + call SpaceVim#mapping#space#def('nnoremap', ['f', 'f'], + \ "exe 'CtrlP ' . fnamemodify(bufname('%'), ':h')", + \ ['Find files in the directory of the current buffer', + \ [ + \ '[SPC f f] is to find files in the directory of the current buffer', + \ 'vim with +python3 support will use denite', + \ 'vim with +python support will use leaderf', + \ 'otherwise will use ctrlp', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ] + \ , 1) 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) call SpaceVim#mapping#space#def('nnoremap', ['f', 'W'], 'write !sudo tee % >/dev/null', 'save buffer with sudo', 1) @@ -286,7 +302,7 @@ function! s:delete_current_buffer_file() abort endif endif redraw! - + endfunction function! s:swap_buffer_with_nth_win(nr) abort @@ -317,102 +333,102 @@ function! s:buffer_transient_state() abort call state.set_title('Buffer Selection Transient State') call state.defind_keys( \ { - \ 'layout' : 'vertical split', - \ 'left' : [ - \ { - \ 'key' : { - \ 'name' : 'C-1..C-9', - \ 'pos' : [[1,4], [6,9]], - \ 'handles' : [ - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ], - \ }, - \ 'desc' : 'goto nth window', - \ 'func' : '', - \ 'cmd' : '', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : { - \ 'name' : '1..9', - \ 'pos' : [[1,2], [4,5]], - \ 'handles' : [ - \ ['1' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [1])'], - \ ['2' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [2])'], - \ ['3' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [3])'], - \ ['4' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [4])'], - \ ['5' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [5])'], - \ ['6' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [6])'], - \ ['7' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [7])'], - \ ['8' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [8])'], - \ ['9' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [9])'], - \ ], - \ }, - \ 'desc' : 'move buffer to nth window', - \ 'func' : '', - \ 'cmd' : '', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : { - \ 'name' : 'M-1..M-9', - \ 'pos' : [[1,4], [6,9]], - \ 'handles' : [ - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [1])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [2])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [3])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [4])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [5])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [6])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [7])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [8])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [9])'], - \ ], - \ }, - \ 'desc' : 'swap buffer with nth window', - \ 'func' : '', - \ 'cmd' : '', - \ 'exit' : 0, - \ }, - \ ], - \ 'right' : [ - \ { - \ 'key' : 'n', - \ 'desc' : 'next buffer', - \ 'func' : '', - \ 'cmd' : 'bnext', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : ['N', 'p'], - \ 'desc' : 'previous buffer', - \ 'func' : '', - \ 'cmd' : 'bp', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : 'd', - \ 'desc' : 'kill buffer', - \ 'func' : '', - \ 'cmd' : 'call SpaceVim#mapping#close_current_buffer()', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : 'q', - \ 'desc' : 'quit', - \ 'func' : '', - \ 'cmd' : '', - \ 'exit' : 1, - \ }, - \ ], + \ 'layout' : 'vertical split', + \ 'left' : [ + \ { + \ 'key' : { + \ 'name' : 'C-1..C-9', + \ 'pos' : [[1,4], [6,9]], + \ 'handles' : [ + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ], + \ }, + \ 'desc' : 'goto nth window', + \ 'func' : '', + \ 'cmd' : '', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : { + \ 'name' : '1..9', + \ 'pos' : [[1,2], [4,5]], + \ 'handles' : [ + \ ['1' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [1])'], + \ ['2' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [2])'], + \ ['3' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [3])'], + \ ['4' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [4])'], + \ ['5' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [5])'], + \ ['6' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [6])'], + \ ['7' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [7])'], + \ ['8' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [8])'], + \ ['9' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [9])'], + \ ], + \ }, + \ 'desc' : 'move buffer to nth window', + \ 'func' : '', + \ 'cmd' : '', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : { + \ 'name' : 'M-1..M-9', + \ 'pos' : [[1,4], [6,9]], + \ 'handles' : [ + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [1])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [2])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [3])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [4])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [5])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [6])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [7])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [8])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [9])'], + \ ], + \ }, + \ 'desc' : 'swap buffer with nth window', + \ 'func' : '', + \ 'cmd' : '', + \ 'exit' : 0, + \ }, + \ ], + \ 'right' : [ + \ { + \ 'key' : 'n', + \ 'desc' : 'next buffer', + \ 'func' : '', + \ 'cmd' : 'bnext', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : ['N', 'p'], + \ 'desc' : 'previous buffer', + \ 'func' : '', + \ 'cmd' : 'bp', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : 'd', + \ 'desc' : 'kill buffer', + \ 'func' : '', + \ 'cmd' : 'call SpaceVim#mapping#close_current_buffer()', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : 'q', + \ 'desc' : 'quit', + \ 'func' : '', + \ 'cmd' : '', + \ 'exit' : 1, + \ }, + \ ], \ } \ ) call state.open() diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index d45665316..58ba5fe86 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -1,3 +1,4 @@ +let s:file = expand(':~') function! SpaceVim#mapping#space#init() abort if s:has_map_to_spc() return @@ -63,19 +64,28 @@ function! SpaceVim#mapping#space#init() abort call SpaceVim#mapping#space#def('nnoremap', ['w', 'W'], 'ChooseWin', 'select window', 1) call SpaceVim#mapping#space#def('nnoremap', ['w', 'u'], 'call SpaceVim#plugins#windowsmanager#UndoQuitWin()', 'undo quieted window', 1) call SpaceVim#mapping#space#def('nnoremap', ['w', 'U'], 'call SpaceVim#plugins#windowsmanager#RedoQuitWin()', 'redo quieted window', 1) - nnoremap [SPC]bn :bnext - let g:_spacevim_mappings_space.b.n = ['bnext', 'next buffer', + let s:lnum = expand('') + 3 + call SpaceVim#mapping#space#def('nnoremap', ['b', 'n'], 'bnext', ['next buffer', \ [ - \ 'SPC b n is running :bnext, jump to next buffer', + \ '[SPC b n] is running :bnext, jump to next buffer', \ 'which is a vim build in command', \ 'It is bound to SPC b n, ] b,', + \ '', + \ 'Definition: ' . s:file . ':' . s:lnum, \ ] \ ] - call SpaceVim#mapping#menu('Open next buffer', '[SPC]bn', 'bp') - nnoremap [SPC]bp :bp - let g:_spacevim_mappings_space.b.p = ['bp', 'previous buffer'] - call SpaceVim#mapping#menu('Open previous buffer', '[SPC]bp', 'bp') - + \ , 1) + let s:lnum = expand('') + 3 + call SpaceVim#mapping#space#def('nnoremap', ['b', 'p'], 'bp', ['previous buffer', + \ [ + \ 'SPC b p is running :bp, jump to previous buffer', + \ 'which is a vim build in command', + \ 'It is bound to SPC b p, [ b,', + \ '', + \ 'Definition: ' . s:file . ':' . s:lnum, + \ ] + \ ] + \ , 1) " " Comments sections " diff --git a/syntax/HelpDescribe.vim b/syntax/HelpDescribe.vim new file mode 100644 index 000000000..69482ad9c --- /dev/null +++ b/syntax/HelpDescribe.vim @@ -0,0 +1,8 @@ +if exists("b:current_syntax") + finish +endif +let b:current_syntax = "HelpDescribe" +syntax case ignore +syn match FileName /[^:]*:\d\+:/ + +hi def link FileName Comment