From cc40bf717de6677fab30741c0431dc6673f8e6fd Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 28 Jul 2017 06:24:37 +0800 Subject: [PATCH] Fix SPC ' --- autoload/SpaceVim/layers/shell.vim | 24 +++++++++++++++++++++--- config/neovim.vim | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/autoload/SpaceVim/layers/shell.vim b/autoload/SpaceVim/layers/shell.vim index 523dba2be..1947b40c3 100644 --- a/autoload/SpaceVim/layers/shell.vim +++ b/autoload/SpaceVim/layers/shell.vim @@ -17,7 +17,7 @@ function! SpaceVim#layers#shell#plugins() abort return plugins endfunction -function! SpaceVim#layers#shell#config() +function! SpaceVim#layers#shell#config() abort call SpaceVim#mapping#space#def('nnoremap', ["'"], 'call call(' \ . string(function('s:open_default_shell')) . ', [])', @@ -25,14 +25,22 @@ function! SpaceVim#layers#shell#config() endfunction -function! SpaceVim#layers#shell#set_variable(var) +function! SpaceVim#layers#shell#set_variable(var) abort let s:default_shell = get(a:var, 'defaut_shell', 'terminal') let s:default_position = get(a:var, 'default_position', 'top') let s:default_height = get(a:var, 'default_height', 30) endfunction - +let s:shell_win_nr = 0 function! s:open_default_shell() abort + if s:shell_win_nr != 0 && getwinvar(s:shell_win_nr, '&buftype') ==# 'terminal' && &buftype !=# 'terminal' + exe s:shell_win_nr . 'wincmd w' + return + endif + if &buftype ==# 'terminal' + bwipeout! % + return + endif let cmd = s:default_position ==# 'top' ? \ 'topleft split' : \ s:default_position ==# 'bottom' ? @@ -44,4 +52,14 @@ function! s:open_default_shell() abort if lines < winheight(0) && (s:default_position ==# 'top' || s:default_position ==# 'bottom') exe 'resize ' . lines endif + if s:default_shell ==# 'terminal' + if exists(':te') + exe 'te' + let s:shell_win_nr = winnr() + else + echo ':terminal is not supported in this version' + endif + elseif s:default_shell ==# 'VimShell' + VimShell + endif endfunction diff --git a/config/neovim.vim b/config/neovim.vim index 198bdce60..302587ffe 100644 --- a/config/neovim.vim +++ b/config/neovim.vim @@ -71,7 +71,7 @@ let g:terminal_color_15 = '#ebdbb2' augroup Terminal au! au TermOpen * let g:last_terminal_job_id = b:terminal_job_id | IndentLinesDisable - au BufWinEnter term://* startinsert | IndentLinesDisable + au WinEnter,BufWinEnter term://* startinsert | IndentLinesDisable if has('timers') au TermClose * let g:_spacevim_termclose_abuf = expand('') | call timer_start(5, 'SpaceVim#mapping#close_term_buffer') else