1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 10:40:03 +08:00
This commit is contained in:
wsdjeg 2017-03-31 22:37:57 +08:00
parent 44ad1cb4fe
commit 1972bbe974
2 changed files with 27 additions and 1 deletions

View File

@ -181,4 +181,30 @@ function! SpaceVim#mapping#close_current_buffer() abort
endif
endfunction
function! SpaceVim#mapping#close_term_buffer(...) abort
let buffers = g:_spacevim_list_buffers
let abuf = str2nr(g:_spacevim_termclose_abuf)
let index = index(buffers, abuf)
let g:wsd = [index, abuf, buffers]
if index != -1
if index == 0
if len(buffers) > 1
exe 'b' . buffers[1]
exe 'bd!' . abuf
else
exe 'bd! ' . abuf
endif
elseif index > 0
if index + 1 == len(buffers)
exe 'b' . buffers[index - 1]
exe 'bd!' . abuf
else
exe 'b' . buffers[index + 1]
exe 'bd!' . abuf
endif
endif
endif
endfunction
" vim:set et sw=2 cc=80:

View File

@ -55,7 +55,7 @@ augroup Terminal
au!
au TermOpen * let g:last_terminal_job_id = b:terminal_job_id | IndentLinesDisable
au BufWinEnter term://* startinsert | IndentLinesDisable
au TermClose * exe expand('<abuf>').'bd!'
au TermClose * let g:_spacevim_termclose_abuf = expand('<abuf>') | call SpaceVim#mapping#close_term_buffer()
augroup END
augroup nvimrc_aucmd
autocmd!