From 17a673b28599d80e2e7e702a0f06c799e2981307 Mon Sep 17 00:00:00 2001 From: Matthew Broadway Date: Sat, 19 Jan 2019 12:45:36 +0000 Subject: [PATCH 1/2] better neovim (specifically neovim-qt) support --- plugin/autoswap.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugin/autoswap.vim b/plugin/autoswap.vim index 9542f69..b86abbb 100644 --- a/plugin/autoswap.vim +++ b/plugin/autoswap.vim @@ -57,7 +57,7 @@ function! AS_HandleSwapfile (filename, swapname) if (strlen(active_window) > 0) call AS_DelayedMsg('Switched to existing session in another window') call AS_SwitchToActiveWindow(active_window) - let v:swapchoice = 'q' + call Exit() " Otherwise, if swapfile is older than file itself, just get rid of it... elseif getftime(v:swapname) < getftime(a:filename) @@ -73,6 +73,15 @@ function! AS_HandleSwapfile (filename, swapname) endfunction +function! Exit() + if has("nvim") && exists("*GuiClose") + let v:swapchoice = 'o' + autocmd BufEnter * call GuiClose() | qall! + else + let v:swapchoice = 'q' + endif +endfunction + " Print a message after the autocommand completes " (so you can see it, but don't have to hit to continue)... " From 419af0388fd1d3f8c1aa1d05524a9c56090bc154 Mon Sep 17 00:00:00 2001 From: Matthew Broadway Date: Sat, 19 Jan 2019 22:51:00 +0000 Subject: [PATCH 2/2] fixed behaviour when multiple buffers or windows are open --- plugin/autoswap.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin/autoswap.vim b/plugin/autoswap.vim index b86abbb..6ba1789 100644 --- a/plugin/autoswap.vim +++ b/plugin/autoswap.vim @@ -75,8 +75,14 @@ endfunction function! Exit() if has("nvim") && exists("*GuiClose") - let v:swapchoice = 'o' - autocmd BufEnter * call GuiClose() | qall! + let l:num_buffers = len(getbufinfo({'buflisted':1})) + let l:num_windows = winnr('$') + if l:num_buffers == 1 && l:num_windows == 1 + let v:swapchoice = 'o' + autocmd BufEnter * call GuiClose() | q + else + let v:swapchoice = 'q' + endif else let v:swapchoice = 'q' endif