diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index a093995f5..17877ea65 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -1,24 +1,56 @@ function! SpaceVim#layers#core#plugins() abort - return [ - \ ['Shougo/vimproc.vim', {'build' : ['make']}], - \ ['benizi/vim-automkdir'], - \ ['airblade/vim-rooter', {'merged' : 0}], - \ ] + return [ + \ ['Shougo/vimproc.vim', {'build' : ['make']}], + \ ['benizi/vim-automkdir'], + \ ['airblade/vim-rooter', {'merged' : 0}], + \ ] endfunction +let s:filename = expand(':~') +let s:lnum = expand('') + 3 function! SpaceVim#layers#core#config() abort - let g:rooter_silent_chdir = 1 - let g:vimproc#download_windows_dll = 1 - call SpaceVim#layers#load('core#banner') - call SpaceVim#layers#load('core#statusline') - call SpaceVim#layers#load('core#tabline') - call SpaceVim#mapping#space#def('nnoremap', ['p', 't'], 'Rooter', 'find-project-root', 1) - call SpaceVim#mapping#space#def('nnoremap', ['p', 'k'], 'call SpaceVim#plugins#projectmanager#kill_project()', 'kill all project buffers', 1) - call SpaceVim#mapping#space#def('nnoremap', ['p', 'f'], 'CtrlP', 'find files in current project', 1) - call SpaceVim#mapping#space#def('nnoremap', ['p', '/'], 'Grepper', 'fuzzy search for text in current project', 1) - call SpaceVim#mapping#space#def('nnoremap', ['q', 'q'], 'qa', 'prompt-kill-vim', 1) - call SpaceVim#mapping#space#def('nnoremap', ['q', 'Q'], 'qa!', 'kill-vim', 1) - call SpaceVim#mapping#space#def('nnoremap', ['q', 'R'], '', 'restart-vim(TODO)', 1) - call SpaceVim#mapping#space#def('nnoremap', ['q', 'r'], '', 'restart-vim-resume-layouts(TODO)', 1) - call SpaceVim#mapping#space#def('nnoremap', ['q', 't'], 'tabclose!', 'kill current tab', 1) + let g:rooter_silent_chdir = 1 + let g:vimproc#download_windows_dll = 1 + call SpaceVim#layers#load('core#banner') + call SpaceVim#layers#load('core#statusline') + call SpaceVim#layers#load('core#tabline') + call SpaceVim#mapping#space#def('nnoremap', ['p', 't'], 'Rooter', 'find-project-root', 1) + call SpaceVim#mapping#space#def('nnoremap', ['p', 'k'], 'call SpaceVim#plugins#projectmanager#kill_project()', 'kill all project buffers', 1) + let lnum = expand('') + s:lnum - 1 + if has('python3') + let cmd = 'Denite file_rec' + elseif has('python') + let cmd = "exe 'LeaderfFile" + else + let cmd = "exe 'CtrlP" + endif + call SpaceVim#mapping#space#def('nnoremap', ['p', 'f'], + \ cmd, + \ ['find files in current project', + \ [ + \ '[SPC p f] is to find files in the root of the current project', + \ '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', ['p', '/'], 'Grepper', 'fuzzy search for text in current project', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 'q'], 'qa', 'prompt-kill-vim', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 'Q'], 'qa!', 'kill-vim', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 'R'], '', 'restart-vim(TODO)', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 'r'], '', 'restart-vim-resume-layouts(TODO)', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 't'], 'tabclose!', 'kill current tab', 1) + call SpaceVim#mapping#gd#add('HelpDescribe', function('s:gotodef')) +endfunction + +function! s:gotodef() abort + let fname = get(b:, 'defind_file_name', '') + if !empty(fname) + close + exe 'edit ' . fname[0] + exe fname[1] + endif endfunction diff --git a/autoload/SpaceVim/plugins/help.vim b/autoload/SpaceVim/plugins/help.vim index 2a9d0461c..db5d690d2 100644 --- a/autoload/SpaceVim/plugins/help.vim +++ b/autoload/SpaceVim/plugins/help.vim @@ -62,6 +62,7 @@ function! s:open_describe_buffer(desc) abort setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber nocursorline set filetype=HelpDescribe call setline(1, a:desc) + let b:defind_file_name = split(a:desc[-1][12:], ':') let lines = &lines * 30 / 100 if lines < winheight(0) exe 'resize ' . lines