From 48cdcfee48acffea0ff674af02b08689dc4feef4 Mon Sep 17 00:00:00 2001 From: Shidong Wang Date: Sat, 15 Feb 2020 20:50:25 +0800 Subject: [PATCH] Improve g f in plugin manager open the terminal only when the plugin's directory exists. close #3349 --- autoload/SpaceVim/plugins/manager.vim | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/autoload/SpaceVim/plugins/manager.vim b/autoload/SpaceVim/plugins/manager.vim index 126bf8fe1..8dfc8420e 100644 --- a/autoload/SpaceVim/plugins/manager.vim +++ b/autoload/SpaceVim/plugins/manager.vim @@ -644,9 +644,6 @@ function! s:open_plugin_dir() abort let line = line('.') - 3 let plugin = filter(copy(s:ui_buf), 's:ui_buf[v:key] == line') if !empty(plugin) - exe 'topleft split' - enew - exe 'resize ' . &lines * 30 / 100 let shell = empty($SHELL) ? SpaceVim#api#import('system').isWindows ? 'cmd.exe' : 'bash' : $SHELL let path = '' if g:spacevim_plugin_manager ==# 'dein' @@ -655,12 +652,25 @@ function! s:open_plugin_dir() abort let path = neobundle#get(keys(plugin)[0]).path elseif g:spacevim_plugin_manager ==# 'vim-plug' endif - if has('nvim') && exists('*termopen') - call termopen(shell, {'cwd' : path}) - elseif exists('*term_start') - call term_start(shell, {'curwin' : 1, 'term_finish' : 'close', 'cwd' : path}) + if isdirectory(path) + topleft new + exe 'resize ' . &lines * 30 / 100 + if has('nvim') && exists('*termopen') + call termopen(shell, {'cwd' : path}) + elseif exists('*term_start') + call term_start(shell, {'curwin' : 1, 'term_finish' : 'close', 'cwd' : path}) + elseif exists(':VimShell') + exe 'VimShell ' . path + else + close + echohl WarningMsg + echo 'Do not support terminal!' + echohl None + endif else - exe 'VimShell ' . path + echohl WarningMsg + echo 'Plugin(' . keys(plugin)[0] . ') has not been installed!' + echohl None endif endif endfunction