1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:50:04 +08:00

Improve g f in plugin manager

open the terminal only when the plugin's directory exists.

close #3349
This commit is contained in:
Shidong Wang 2020-02-15 20:50:25 +08:00
parent 04d05de80b
commit 48cdcfee48

View File

@ -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