When multiple buffers are opened, either through nvim-tree or using another tool(telescope) issuing :bd or :bw will cause all buffers to be closed when the option nvim_tree_auto_close is enabled.
I expect that nvim will only close on closing the last buffer in nvim with the option nvim_tree_auto_close enabled.
NVIM v0.5.0-dev+nightly
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210121-85331-1hor993/build/config -I/tmp/neovim-20210121-85331-1hor993/src -I/usr/local/include -I/tmp/neovim-20210121-85331-1hor993/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210121-85331-1hor993/build/src/nvim/auto -I/tmp/neovim-20210121-85331-1hor993/build/include
Compiled by jared@Jareds-Work-Macbook-34
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-d68026c/share/nvim"
Run :checkhealth for more info
well this issue has already been discussed before, auto_close is based on window layout, maybe adding a buffer_auto_close would help in this scenario.
Wow, that was quick. Ok, I personally would love this feature as I sometimes have multiple buffers opened while I'm working. super annoying when you want to clean up and then closing one buffer closes the session.
How hard would it be to implement?
I would say this is kind of a bug as the normal behaviour when one doesn't have nvim-tree open and has multiple buffers opened is that the :bc command only closes that buffer.
i understand. This would not be hard to implement, i'll add that when i have some time
Thank you @kyazdani42 I'm looking forward to it!
I've tried something but this feature actually makes no sense to me because i don't use buffers like this.
@akinsho if i remember correctly, you also asked for something like that long ago ?
I'm not sure when to close nvim here, i've tried multiple approaches but none made sense to me.
@kyazdani42 I don't actually really understand/remember this issue well. I vaguely recall discussing something like this a while ago because I think at least before it used to use the :q command or something so would close vim completely. If that is still the case that would explain why this is happening i.e. having multiple buffers open but closing nvim tree closes nvim. I think the command should use :bd | b#, i.e. delete the tree buffer then go to the alternate buffer.
Here's a famous solution for how nerd tree handles it. I might not have fully understood what the desired out come is tbh is it to make sure this doesn't trigger closing vim unless there are still buffers open
hmm @kyazdani42 I can imagine that more older users of vim might not use buffer or imagine them in the way I do. I'm a user coming from vscode so I have the expectation that buffers act like tabs would in vscode. I think what makes the expectation worse is that in conjunction with airline-show-buffers, open buffers are visible.
I would still say though, I want to be able to peek into another file but then close that file buffer once I'm done with it. Currently, this behaviour would close vim.
Is there a more canonical vim way that you would handle multiple open file cleanups?
why don't you disable the nvim_tree_auto_close option then ?
I'll try to find a way to properly handle closing when last buffer is closed but it seems hard to do because you cannot close the last empty buffer.
@akinsho i must say the NerdTree solution looks the same as the NvimTree solution but written in vim :)
So I've read through a couple of but tickets and I don't see one that fully fits my issue. I can open nvim-tree without any issues. When I open a file it will open the file and add a tab at the top of the buffer (screen, window, whatever you want to call it).
The issue I'm having is that the "Tabs" are open but NeoVim doesn't see them like that. I can use my mouse cursor to close the tab. But, if I try and use any of the ":tab..." commands I get messages stating that the tabs don't exist. I have my Tab key on my keyboard set to cycle the tabs and that works fine. I just cannot close them without using my mouse.
If I try to quit using ":q" then it will just exit out of NeoVim completely even though there were three or four "tabs" open.
@courtross2010 I'm not entirely sure the issue you are describing relates to this plugin are you maybe mistaking a vim tab for a buffer, the :tab commands only operate on tab not buffers(buffers are what contain the files and are what other editors call their tabs)? in either case I don't think management of buffers or tabs relates to nvim-tree.
@kyazdani42 disabling the feature while removing the vim auto quit issue still leaves an odd "situation" IMO.
I feel like the issue is that opening preview or files in a split aren't opening those files in the separate window. I'm not sure if this my config at fault but also perhaps this is out of the scope of your plugin.
I personally would like to see the tree at all times if I want to. I guess this would eliminate that UX possibility. As I said, I'm coming from a VS code world, so sometimes being able to quickly glance at the project tree is nice. Again I'm newish to vim so maybe my expectation is a bit warped from misunderstanding. This plugin seems to exhibit the behaviour I am expecting. Maybe my issue is then not related to your plugin.
@akinsho You are correct. I was thinking it was a tab but it was a buffer. Using ":ls" I can see a list of buffers and using ":bd" will close the current buffer I'm on. Sorry for the newbie question. I'm still learning this application.
So thank you for your quick comment, that got me pointed in the right direction. Sorry to derail your train of thought. :)
@kyazdani42 and all Contributors. So far I'm loving this plugin. Thank you for taking time out of your lives to create things that make other peoples lives better.
thanks for the kind words :)
@rieger-jared I believe the feature you are asking for is definitely out of the scope of this plugin, im planning some refactorings to make it easier to script from this plugin allowing people to easily extend to their needs :)
So I find that after installing this plugin my expected behaviour is achieved. Thanks, @kyazdani42 for the quick replies. If it's ok, I think I'll close this issue as after researching it's not in the scope of your plugin. Thanks again for the work.
Most helpful comment
i understand. This would not be hard to implement, i'll add that when i have some time