From a5f349096f54146ab5cc3d1b13d0396c8471b55c Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 20:36:58 +0800 Subject: [PATCH] Fix shell config --- autoload/SpaceVim/layers/core.vim | 3 +++ autoload/SpaceVim/layers/unite.vim | 17 ++++++++++++++++- autoload/SpaceVim/plugins/projectmanager.vim | 8 ++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index 895da6868..ea20c0888 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -44,6 +44,9 @@ function! SpaceVim#layers#core#config() abort 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')) + " project manager + call SpaceVim#mapping#space#def('nnoremap', ['p', '!'], 'Grepper', 'fuzzy search for text in current project', 1) + endfunction function! s:gotodef() abort diff --git a/autoload/SpaceVim/layers/unite.vim b/autoload/SpaceVim/layers/unite.vim index a48f1905b..ea4a6bf80 100644 --- a/autoload/SpaceVim/layers/unite.vim +++ b/autoload/SpaceVim/layers/unite.vim @@ -82,7 +82,10 @@ endfunction function! SpaceVim#layers#unite#config() abort call SpaceVim#mapping#space#def('nnoremap', ['!'], 'call call(' \ . string(s:_function('s:run_shell_cmd')) . ', [])', - \ 'shell cmd', 1) + \ 'shell cmd(current dir)', 1) + call SpaceVim#mapping#space#def('nnoremap', ['p', '!'], 'call call(' + \ . string(s:_function('s:run_shell_cmd_project')) . ', [])', + \ 'shell cmd(project root)', 1) endfunction function! s:run_shell_cmd() abort @@ -92,6 +95,18 @@ function! s:run_shell_cmd() abort endif endfunction +function! s:run_shell_cmd_project() abort + let cmd = input('Please input shell command:', '', 'customlist,SpaceVim#plugins#bashcomplete#complete') + if !empty(cmd) + call unite#start([['output/shellcmd', cmd]], { + \ 'log': 1, + \ 'wrap': 1, + \ 'start_insert':0, + \ 'cwd' : SpaceVim#plugins#projectmanager#current_root(), + \ }) + endif +endfunction + " function() wrapper if v:version > 703 || v:version == 703 && has('patch1170') function! s:_function(fstr) abort diff --git a/autoload/SpaceVim/plugins/projectmanager.vim b/autoload/SpaceVim/plugins/projectmanager.vim index c64d6347d..ac57e95e2 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -32,6 +32,14 @@ function! SpaceVim#plugins#projectmanager#current_() return get(b:, '_spacevim_project_name', '') endfunction +function! SpaceVim#plugins#projectmanager#current_root() abort + try + Rooter + catch + endtry + return getcwd() +endfunction + let s:BUFFER = SpaceVim#api#import('vim#buffer') function! SpaceVim#plugins#projectmanager#kill_project() abort