-
Notifications
You must be signed in to change notification settings - Fork 255
How to quit Neovim if Neotree is the last remaining window? #137
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
Comments
I've done it with this but it'd be cleaner to have a built-in option IMO: autocmd WinEnter * if winnr('$') == 1 && getbufvar(winbufnr(winnr()), "&filetype") == "neo-tree" | q | endif |
actually I guess what I want is to quit if Neo-tree is the last window, not just buffer. the above doesn't do that. |
I think this autocmd does what you want:
I'm sure this can be added as an option as well. |
@cseickel hm, that's close. It doesn't work if I open Neo-tree before any files. but if I open files, then open Neo-tree, it works. |
OK, I can see how to do this right. It should be easy so I'll add it soon. |
@cseickel I'm getting the following error when I set the new option:
|
Sorry about that, it's fixed in main, this issue will close when it is released to v1.x |
This is still not working for me. I've set the option in config, but Neo-tree still remains open for me when it's the last window. |
It is working for me right now. One thing that may affect you is that the setting only applies if the last window was opened as a sidebar. Can you share your config and an example of what steps will recreate the issue? |
My Neo-tree config, installed with packer: return {
'nvim-neo-tree/neo-tree.nvim',
requires = { 'MunifTanjim/nui.nvim' },
config = function()
require('neo-tree').setup({
close_if_last_window = true,
popup_border_style = 'rounded',
enable_git_status = true,
enable_diagnostics = true,
default_component_configs = {
indent = {
indent_size = 2,
padding = 1, -- extra padding on left hand side
with_markers = true,
indent_marker = '│',
last_indent_marker = '└',
highlight = 'NeoTreeIndentMarker',
},
icon = {
folder_closed = '',
folder_open = '',
default = '',
},
},
filesystem = {
follow_current_file = true,
use_libuv_file_watcher = true,
filters = {
show_hidden = true,
respect_gitignore = true,
},
window = {
position = 'right',
mappings = {
f = 'none',
},
},
},
})
end,
} To reproduce:
|
I'm just guessing because it always works for me, but I added a filter when counting windows to exclude floating windows, and maybe that will fix the issue for you. Let me know if this helps. |
Works for me on branch |
Hi, just switched from nvim-tree, really impressed so far.
The one thing I'm not seeing that nvim-tree had built in is an option to quit Neovim if the only remaining buffer is the Neotree buffer?
The text was updated successfully, but these errors were encountered: