Skip to content

Commit 66cf686

Browse files
committed
fix(nvim): make sure Snacks windows are closed when quitting neovim
1 parent b787b8e commit 66cf686

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • home/dot_config/exact_nvim/exact_lua/exact_user/exact_config/exact_autocmds

home/dot_config/exact_nvim/exact_lua/exact_user/exact_config/exact_autocmds/windows.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,23 @@ vim.api.nvim_create_autocmd('QuitPre', {
1414
'filetype',
1515
{ buf = vim.api.nvim_win_get_buf(w) }
1616
)
17+
1718
if filetype:match('snacks_') ~= nil then
1819
table.insert(snacks_windows, w)
1920
elseif vim.api.nvim_win_get_config(w).relative ~= '' then
2021
table.insert(floating_windows, w)
2122
end
2223
end
2324

24-
if 1 == #windows - #floating_windows - #snacks_windows then
25-
-- Should quit, so we close all Snacks windows.
25+
if #windows - #floating_windows - #snacks_windows == 1 then
26+
for _, picker in ipairs(require('snacks').picker.get()) do
27+
picker:close()
28+
end
29+
2630
for _, w in ipairs(snacks_windows) do
27-
vim.api.nvim_win_close(w, true)
31+
if vim.api.nvim_win_is_valid(w) then
32+
vim.api.nvim_win_close(w, true)
33+
end
2834
end
2935
end
3036
end,

0 commit comments

Comments
 (0)