diff --git a/autoload/SpaceVim/api/vim/key.vim b/autoload/SpaceVim/api/vim/key.vim index 6153c54e9..c0c737b5f 100644 --- a/autoload/SpaceVim/api/vim/key.vim +++ b/autoload/SpaceVim/api/vim/key.vim @@ -10,6 +10,12 @@ function! s:self.nr2name(nr) abort if type(a:nr) == 0 if a:nr == 32 return 'SPC' + elseif a:nr == 4 + return '' + elseif a:nr == 9 + return '' + elseif a:nr == 27 + return '' else return nr2char(a:nr) endif diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index 3805bb56f..96b6ef451 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -222,6 +222,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort \ . '%#SpaceVim_statusline_c# %{SpaceVim#plugins#flygrep#lineNr()}' elseif &filetype ==# 'TransientState' return '%#SpaceVim_statusline_a# Transient State %#SpaceVim_statusline_a_SpaceVim_statusline_b#' + elseif &filetype ==# 'HelpDescribe' + return '%#SpaceVim_statusline_a# HelpDescribe %#SpaceVim_statusline_a_SpaceVim_statusline_b#' endif if a:0 > 0 return s:active() diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 53cbadb57..8473c555e 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -63,7 +63,13 @@ function! SpaceVim#mapping#space#init() abort 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 g:_spacevim_mappings_space.b.n = ['bnext', '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,', + \ ] + \ ] call SpaceVim#mapping#menu('Open next buffer', '[SPC]bn', 'bp') nnoremap [SPC]bp :bp let g:_spacevim_mappings_space.b.p = ['bp', 'previous buffer'] @@ -260,13 +266,29 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd, ...) abort endif endif if len(a:keys) == 2 - let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]] = [lcmd, a:desc] + if type(a:desc) == 1 + let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]] = [lcmd, a:desc] + else + let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]] = [lcmd, a:desc[0], a:desc[1]] + endif elseif len(a:keys) == 3 - let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]][a:keys[2]] = [lcmd, a:desc] + if type(a:desc) == 1 + let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]][a:keys[2]] = [lcmd, a:desc] + else + let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]][a:keys[2]] = [lcmd, a:desc[0], a:desc[1]] + endif elseif len(a:keys) == 1 - let g:_spacevim_mappings_space[a:keys[0]] = [lcmd, a:desc] + if type(a:desc) == 1 + let g:_spacevim_mappings_space[a:keys[0]] = [lcmd, a:desc] + else + let g:_spacevim_mappings_space[a:keys[0]] = [lcmd, a:desc[0], a:desc[1]] + endif + endif + if type(a:desc) == 1 + call SpaceVim#mapping#menu(a:desc, '[SPC]' . join(a:keys, ''), lcmd) + else + call SpaceVim#mapping#menu(a:desc[0], '[SPC]' . join(a:keys, ''), lcmd) endif - call SpaceVim#mapping#menu(a:desc, '[SPC]' . join(a:keys, ''), lcmd) call extend(g:_spacevim_mappings_prefixs['[SPC]'], get(g:, '_spacevim_mappings_space', {})) endfunction diff --git a/autoload/SpaceVim/plugins/help.vim b/autoload/SpaceVim/plugins/help.vim index 14126cb37..032ae557e 100644 --- a/autoload/SpaceVim/plugins/help.vim +++ b/autoload/SpaceVim/plugins/help.vim @@ -26,6 +26,7 @@ function! SpaceVim#plugins#help#describe_key() let root = root[name] if type(root) == 3 if len(root) == 3 + redraw! call s:open_describe_buffer(root[-1]) else call s:build_mpt(['can not find describe for ', join(keys, ' - ')]) @@ -36,7 +37,9 @@ function! SpaceVim#plugins#help#describe_key() endif else redraw! + echohl Comment echo join(keys, ' - ') . ' is undfinded' + echohl NONE let definded = 0 endif endwhile @@ -44,14 +47,23 @@ endfunction function! s:build_mpt(mpt) abort redraw! + echohl Comment if type(a:mpt) == 1 echo a:mpt elseif type(a:mpt) == 3 echo join(a:mpt) endif + echohl NONE endfunction function! s:open_describe_buffer(desc) abort - + noautocmd botright split __help_describe__ + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber nocursorline + set filetype=HelpDescribe + call setline(1, a:desc) + let lines = &lines * 30 / 100 + if lines < winheight(0) + exe 'resize ' . lines + endif endfunction