Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Snacks.terminal gracefully handle :wqa #419

Closed
1 task done
tonymajestro opened this issue Jan 3, 2025 · 2 comments · Fixed by #646
Closed
1 task done

feature: Snacks.terminal gracefully handle :wqa #419

tonymajestro opened this issue Jan 3, 2025 · 2 comments · Fixed by #646
Labels
enhancement New feature or request

Comments

@tonymajestro
Copy link

tonymajestro commented Jan 3, 2025

Did you check the docs?

  • I have read all the snacks.nvim docs

Is your feature request related to a problem? Please describe.

I often have several buffers open and when I want to exit neovim, I use :wqa. However this causes issues when the snacks terminal buffers are still open, resulting in the following errors:

E948: Job still running
E676: No matching autocommands for buftype= buffer

It would be nice if the terminal plugin was able to suppress errors related to writing to the terminal buffers when neovim is trying to exit.

Repro steps

Config:

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"--single-branch",
		"https://github.com/folke/lazy.nvim.git",
		lazypath,
	})
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	-- do not remove the colorscheme!
	"folke/tokyonight.nvim",
	{
		"folke/snacks.nvim",
		opts = {
			terminal = {
				enabled = true,
			},
		},
	},
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.opt.termguicolors = true
vim.cmd([[colorscheme tokyonight]])
  • Open neovim with nvim -u repro.lua
  • Open snacks terminal with :lua snacks.terminal.toggle()
  • Hide snacks terminal with :lua snacks.terminal.toggle()
  • Try to quit neovim with :wqa

Describe the solution you'd like

It would be nice if the plugin could suppress errors related to writing to the terminal buffers when exiting neovim with :wqa

Describe alternatives you've considered

I have worked around this by first doing :wa (which does not seem to trigger any errors) followed by :q. However it would be nice to be able to quit with one command using :wqa

Additional context

No response

@tonymajestro tonymajestro added the enhancement New feature or request label Jan 3, 2025
@folke folke closed this as completed in 2abf208 Jan 20, 2025
folke pushed a commit that referenced this issue Jan 20, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.14.0](v2.13.0...v2.14.0)
(2025-01-20)


### Features

* **picker.buffer:** add filetype to bufname for buffers without name
([83baea0](83baea0))
* **picker.debug:** debug option to detect garbage collection leaks
([b59f4ff](b59f4ff))
* **picker.matcher:** new `opts.matcher.file_pos` which defaults to
`true` to support patterns like `file:line:col` or `file:line`. Closes
[#517](#517). Closes
[#496](#496). Closes
[#651](#651)
([5e00b0a](5e00b0a))
* **picker:** added `args` option for `files` and `grep`. Closes
[#621](#621)
([781b6f6](781b6f6))
* **picker:** added `undo` picker to navigate the undo tree. Closes
[#638](#638)
([5c45f1c](5c45f1c))
* **picker:** added support for item.resolve that gets called if needed
during list rendering / preview
([b0d3266](b0d3266))
* **terminal:** allow overriding default shell. Closes
[#450](#450)
([3146fd1](3146fd1))
* **terminal:** close terminals on `ExitPre`. Fixes
[#419](#419)
([2abf208](2abf208))


### Bug Fixes

* **dashboard:** added optional filter for recent files
([32cd343](32cd343))
* **debug.run:** schedule only nvim_buf_set_extmark in on_print
([#425](#425))
([81572b5](81572b5))
* **indent:** use correct hl based on indent. Fixes
[#422](#422)
([627af73](627af73))
* **input:** put the cursor right after the default prompt
([#549](#549))
([f904481](f904481))
* **notifier:** added `SnacksNotifierMinimal`. Closes
[#410](#410)
([daa575e](daa575e))
* **notifier:** win:close instead of win:hide
([f29f7a4](f29f7a4))
* **picker.buffers:** add buf number to text
([70106a7](70106a7))
* **picker.buffer:** unselect on delete. Fixes
[#653](#653)
([0ac5605](0ac5605))
* **picker.grep:** correctly insert args from pattern. See
[#601](#601)
([8601a8c](8601a8c))
* **picker.grep:** debug
([f0d51ce](f0d51ce))
* **picker.lsp.symbols:** only include filename for search with
workspace symbols
([eb0e5b7](eb0e5b7))
* **picker.lsp:** backward compat with Neovim 0.95
([3df2408](3df2408))
* **picker.lsp:** lazy resolve item lsp locations. Fixes
[#650](#650)
([d0a0046](d0a0046))
* **picker.preview:** disable relativenumber by default. Closes
[#664](#664)
([384b9a7](384b9a7))
* **picker.preview:** off-by-one for cmd output
([da5556a](da5556a))
* **picker.preview:** reset before notify
([e50f2e3](e50f2e3))
* **picker.undo:** disable number and signcolumn in preview
([40cea79](40cea79))
* **picker.util:** item.resolve for nil item
([2ff21b4](2ff21b4))
* **picker.util:** relax pattern for args
([6b7705c](6b7705c))
* **scope:** parse treesitter injections. Closes
[#430](#430)
([985ada3](985ada3))
* **statusline:** fix status line cache key
([#656](#656))
([af55934](af55934))
* **win:** always close created scratch buffers when win closes
([abd7e61](abd7e61))
* **zen:** properly handle close
([920a9d2](920a9d2))
* **zen:** sync cursor with parent window
([#547](#547))
([ba45c28](ba45c28)),
closes [#539](#539)


### Performance Improvements

* **picker:** fixed some issues with closed pickers not always being
garbage collected
([eebf44a](eebf44a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@tonymajestro
Copy link
Author

Thanks for looking into this!

@yutkat
Copy link

yutkat commented Feb 17, 2025

This problem was not fixed by the ExitPre fix.

This is a bug in the Neovim terminal, so I think a workaround exists, but it's difficult to solve.
neovim/neovim#14061
akinsho/toggleterm.nvim#155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants