From 6db1ee74fcd6fac91febaae2fae5ab584d6eab92 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 31 Mar 2018 21:42:34 +0800 Subject: [PATCH] Fix SPC h i key binding --- autoload/SpaceVim/layers/core.vim | 5 ----- autoload/SpaceVim/layers/ctrlp.vim | 27 +++++++++++++++++++++++++++ autoload/SpaceVim/layers/denite.vim | 1 + autoload/SpaceVim/layers/unite.vim | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index 4c8c327a9..f9ebce658 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -86,11 +86,6 @@ function! SpaceVim#layers#core#config() abort call SpaceVim#mapping#space#def('nnoremap', ['f', 'W'], 'write !sudo tee % >/dev/null', 'save buffer with sudo', 1) " help mappings call SpaceVim#mapping#space#def('nnoremap', ['h', 'I'], 'call SpaceVim#issue#report()', 'Report an issue of SpaceVim', 1) - if has('python3') - call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'DeniteCursorWord help', 'get help with the symbol at point', 1) - else - call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'UniteWithCursorWord help', 'get help with the symbol at point', 1) - endif call SpaceVim#mapping#space#def('nnoremap', ['h', 'l'], 'SPLayer -l', 'lists all the layers available in SpaceVim', 1) call SpaceVim#mapping#space#def('nnoremap', ['h', 'm'], 'Unite manpage', 'search available man pages', 1) call SpaceVim#mapping#space#def('nnoremap', ['h', 'k'], 'LeaderGuide "[KEYs]"', 'show top-level bindings with mapping guide', 1) diff --git a/autoload/SpaceVim/layers/ctrlp.vim b/autoload/SpaceVim/layers/ctrlp.vim index 725ca58e6..520f6fa39 100644 --- a/autoload/SpaceVim/layers/ctrlp.vim +++ b/autoload/SpaceVim/layers/ctrlp.vim @@ -12,6 +12,7 @@ function! SpaceVim#layers#ctrlp#plugins() abort \ ['FelikZ/ctrlp-py-matcher'], \ ['mattn/ctrlp-register', {'on_cmd' : 'CtrlPRegister'}], \ ['DeaR/ctrlp-jumps', {'on_cmd' : 'CtrlPJump'}], + \ ['SpaceVim/vim-ctrlp-help', {'on_cmd' : 'CtrlPHelp'}], \ ] return plugins endfunction @@ -19,6 +20,9 @@ endfunction let s:filename = expand(':~') let s:lnum = expand('') + 2 function! SpaceVim#layers#ctrlp#config() abort + call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'call call(' + \ . string(s:_function('s:get_help_with_cursor_symbol')) . ', [])', + \ 'get help with the symbol at point', 1) let lnum = expand('') + s:lnum - 1 call SpaceVim#mapping#space#def('nnoremap', ['p', 'f'], \ 'CtrlP', @@ -49,6 +53,13 @@ function! SpaceVim#layers#ctrlp#config() abort \ , 1) endfunction +function! s:get_help_with_cursor_symbol() abort + let save_ctrlp_default_input = get(g:, 'ctrlp_default_input', '') + let g:ctrlp_default_input = expand('') + CtrlPHelp + let g:ctrlp_default_input = save_ctrlp_default_input +endfunction + let s:file = expand(':~') let s:unite_lnum = expand('') + 3 function! s:defind_fuzzy_finder() abort @@ -96,3 +107,19 @@ function! s:defind_fuzzy_finder() abort \ ] \ ] 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 diff --git a/autoload/SpaceVim/layers/denite.vim b/autoload/SpaceVim/layers/denite.vim index 3a5c4bd19..0009fb79a 100644 --- a/autoload/SpaceVim/layers/denite.vim +++ b/autoload/SpaceVim/layers/denite.vim @@ -50,6 +50,7 @@ function! SpaceVim#layers#denite#config() abort \ ] \ ] \ , 1) + call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'DeniteCursorWord help', 'get help with the symbol at point', 1) endfunction let s:file = expand(':~') diff --git a/autoload/SpaceVim/layers/unite.vim b/autoload/SpaceVim/layers/unite.vim index 5244021e0..17467d0bb 100644 --- a/autoload/SpaceVim/layers/unite.vim +++ b/autoload/SpaceVim/layers/unite.vim @@ -48,6 +48,7 @@ endfunction let s:filename = expand(':~') let s:lnum = expand('') + 2 function! SpaceVim#layers#unite#config() abort + call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'UniteWithCursorWord help', 'get help with the symbol at point', 1) if has('nvim') let cmd = 'Unite file_rec/neovim' else