diff options
author | j-james | 2021-05-28 04:49:03 +0000 |
---|---|---|
committer | Thomas Buckley-Houston | 2021-05-28 23:57:34 +0000 |
commit | 7b7e91cba36e3b63d4917186bdeb16e3c394f417 (patch) | |
tree | 3fbb209f25c3758e18df75e500804f9686cf950e /autoload | |
parent | f596f02da0e7546cae9babad11922b5c4af91381 (diff) |
Prompt when closing or quitting w/ unsaved changes
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/novim_mode.vim | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/autoload/novim_mode.vim b/autoload/novim_mode.vim index 9d09d58..2b66f03 100644 --- a/autoload/novim_mode.vim +++ b/autoload/novim_mode.vim @@ -291,11 +291,17 @@ function! novim_mode#ClosePane() " Close any quickfix lists on screen. exe "cclose" + let l:check = execute(":ls") if s:CountListedBuffers() > 1 " By default if the buffer is the only one on screen, closing it closes the " tab/window. So this little trick does a switch to the next buffer, " then closes the previous buffer. exe "bp\|bd #" + elseif l:check =~ "%a +" + let l:confirmed = confirm('There are unsaved changes. Close anyway?', "&Yes\n&No", 2) + if l:confirmed == 1 + quit! + endif else quit endif @@ -304,12 +310,15 @@ function! novim_mode#ClosePane() endif endfunction -" TODO: Mention any unsaved buffers function! novim_mode#ExitVim() - let l:confirmed = confirm('Do you really want to quit Vim?', "&Yes\n&No", 2) - if l:confirmed == 1 - quitall! - endif + let l:check = execute(":ls") + if l:check =~ "+" + let l:confirmed = confirm('There are unsaved changes. Quit anyway?', "&Yes\n&No", 2) + if l:confirmed == 1 + quitall! + endif + else + quitall endfunction function! novim_mode#GotoLine() |