diff options
| author | jdhao <jdhao@hotmail.com> | 2022-03-29 21:41:44 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2022-03-29 21:41:44 +0800 |
| commit | e9ffd6c39d597694823c7718d53ebec8d9ce44b2 (patch) | |
| tree | b20f7eccac673a7c3e00616cc1d116710ec557f4 /core/autocommands.vim | |
| parent | 988cf54f2692cdbf9c12f17bec77c066a9b4d717 (diff) | |
[fix] quit does not work for 2 windows
If current buf in remaning two or more windows are filetypes in the quit
list, we should also quit nvim also.
Diffstat (limited to 'core/autocommands.vim')
| -rw-r--r-- | core/autocommands.vim | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/core/autocommands.vim b/core/autocommands.vim index 78c0d13..c055c49 100644 --- a/core/autocommands.vim +++ b/core/autocommands.vim @@ -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 |
