1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Merge pull request #46 from jdhao/fix-quit-condition

[fix] quit does not work for 2 windows
This commit is contained in:
jdhao 2022-03-29 21:46:27 +08:00 committed by GitHub
commit 9f41333378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,10 +101,22 @@ augroup END
" Quit Nvim if we have only one window, and its filetype match our pattern.
function! s:quit_current_win() abort
let quit_filetypes = ['qf', 'vista']
let buftype = getbufvar(bufnr(), '&filetype')
if winnr('$') == 1 && index(quit_filetypes, buftype) != -1
quit
let l:quit_filetypes = ['qf', 'vista', 'NvimTree']
let l:should_quit = v:true
let l:tabwins = nvim_tabpage_list_wins(0)
for w in l:tabwins
let l:buf = nvim_win_get_buf(w)
let l:bf = getbufvar(l:buf, '&filetype')
if index(l:quit_filetypes, l:bf) == -1
let l:should_quit = v:false
endif
endfor
if l:should_quit
qall
endif
endfunction