-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
Auto-close not work #1005
Comments
doesn't work for me as well |
cannot reproduce, can you provide your configuration and the exact steps to reproduce ? |
cannot reproduce, can you share you complete nvim-tree configuration ? |
My full config nvim-tree inside lua/nvim-tree-config |
cannot reproduce with your config :/ are you sure you are on latest master ? |
@tin-pham what is your font? Auto close works for me now xD |
I used Operator Mono. I still have no luck 😞 |
so, i was mistaken xD... it didnt close by itself. Do u hvlave operator mono the latest version? @tin-pham |
I don't know, I installed it 3-4 month ago |
For a couple of day, now i have figured it out that NeoVim problem, i reinstall it again and now it worked. |
=)), it sooooo weird, after coding for a little while, it can't auto close again |
xD i hv nvim tree just in case |
For the past few releases, I've had the same problem. When I open a file in a new tab, or split, the tree stays open. It's annoying because i now have tab after tab that say, "Nvim Tree". This seems like a regression. |
@nobleach what you describe has nothing to do with this issue. Try setting Sorry people but i cannot reproduce this issue, i'll leave it open if someone wants to give a shot at fixing it. |
Then I'm very sorry, I'll open another issue as |
Are you calling, |
Nope, I'm only calling it once. I've been too busy to actually sit down and create a new issue. When it gets to be too big of an annoyance I'll start digging into what it can be. Just this past week nvim-tree started throwing errors when I switch to a new tab, switch back and try to close the tree.... so I'll probably need to check into that a bit as well. I'm really trying to avoid reporting issues as i get this is a project that is being worked on in someone's spare time.... and he's not getting paid to do so. |
After making changes you should recompile packer plugin specifications lol.mp4My config. |
I truly appreciate the time you took to put this together! Unfortunately, |
Ah.. you should do that then. But, note that if you're lazy loading the plugin then you'd need to set the global variables beforehand.. (before the plugin is loaded) naturally that you mean that you wouldn't be able to override it's behavior if your using the config key and it'll use defaults! The require part doesn't matter.. you can set it anywhere. -- Putting everything in config won't work.
use {
"kyazdani42/nvim-tree.lua",
cmd = { "NvimTreeToggle", "NvimTreeRefresh", "NvimTreeFocus" },
config = require "nvimtree",
} This works for me IMO use {
"kyazdani42/nvim-tree.lua",
cmd = { "NvimTreeToggle", "NvimTreeRefresh", "NvimTreeFocus" },
setup = require("configs.workflow.nvimtree").before,
config = require("configs.workflow.nvimtree").after,
wants = "nvim-notify",
} NOTE: This only applies if you're lazy loading. And I should mention this as well, I'm using |
@nobleach do not worry about opening a new issue if you have a bug or something you cannot manage to fix. Even if it is an opensource project on people free time, we chose whenever we have time for it, it's not like it's a burden 😄 |
i also meet this problem.And I find when I close the buffer first using :wq, I press q to close the tree, and then the origin buffer will reappear, which means i dont close the buffer completely or reopen the buffer? Need help |
When I use the following settings, this question seems to be solved. But another question appears. When I close one of the buffers(yes, I open many buffers, so there is not only the tree in a window), all of the buffers and tree are closed. use {
'kyazdani42/nvim-tree.lua',
requires = {
'kyazdani42/nvim-web-devicons', -- optional, for file icon
},
config = function() require'plugin-config.nvim-tree' end
} Here is my plugin-config/nvim-tree.lua require'nvim-tree'.setup {
auto_close = true,
git = {
enable = false
}
} Here is my directory structure ├── init.lua
├── lua
│ ├── basic.lua
│ ├── keybindings.lua
│ ├── lsp
│ │ ├── lua.lua
│ │ ├── nvim-cmp.lua
│ │ └── setup.lua
│ ├── plugin-config
│ │ ├── bufferline.lua
│ │ ├── nvim-tree.lua
│ │ └── nvim-treesitter.lua
│ └── plugins.lua
└── plugin
└── packer_compiled.lua |
Could you please raise a new bug report for this @lgds-01 ? It will get lost in this issue otherwise ;) |
We could put it in the Tips and Reminders section:
autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif
|
Where should you put this line ? |
in your configuration, where you want |
But this is not lua right? So what if I want to put it in a lua file ? |
You can call vim.api.nvim_create_autocmd('BufEnter', {
command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif",
nested = true,
}) |
This does not work for be but manually running Must be something to do with BufEnter. I suspect maybe caused by wilder.nvim? |
Still does not work for me on my setup. Pretty sure issue with wilder.nvim. Anyways. I propose we update readme as this method is cleaner and will fire less often.
|
This "solution" is very hacky and is unlikely to work in complex configurations. It relies on events with unpredictable ordering and nesting, which may be suppressed by other plugins/automation. Unfortunately, events are the only known means of implementing this close functionality. Of course I would be very happy if someone found a proper solution.
Does the FileType approach work more reliably? |
why auto-close feature was removed? I don't need tree every time I open the file. How can I disable this? |
I think the functionality you want is |
Thanks, this is really what I was looking for |
This is really bad. It can cause neovim to break if you accidentally quit without saving. After that you have to shut down the whole terminal to quit neovim. |
@YanzhaoW do not use it if you don't want to. |
This is getting silly. There is no solution here and we will not build one, nor support hacks to do it:
|
I wouldn't remove it from the readme since people might just ask how to do it again, but maybe adding more information about why we will not help people with this might be useful. |
It is not elegant, but you certainly do not have to close the terminal to close the Neovim. Just don't repeatedly type |
Done |
Here's a small change to make it work with unsaved files. Also I'm extremely new to -- nvim-tree is also there in modified buffers so this function filter it out
local modifiedBufs = function(bufs)
local t = 0
for k,v in pairs(bufs) do
if v.name:match("NvimTree_") == nil then
t = t + 1
end
end
return t
end
vim.api.nvim_create_autocmd("BufEnter", {
nested = true,
callback = function()
if #vim.api.nvim_list_wins() == 1 and
vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil and
modifiedBufs(vim.fn.getbufinfo({bufmodified = 1})) == 0 then
vim.cmd "quit"
end
end
}) |
also fix emmylua errors in log.lua file fixes nvim-tree#1005 fixes nvim-tree#871
nvim-tree/nvim-tree.lua#1005 (comment) seems like there not a proper way to properly auto close
The easiest way I found to do this is following the docs and setup the plugin in this way
|
In what part of my config should I put the function(s) provided? |
@ruperlopez What functions? This seems like a generic configuration question, not an issue, please ask under Discussions. |
OS: PopOS
Nvim Version: v0.7.0-dev
Nvim-tree-version: I just update this plugin, but i don't know how to check version of this
Bug: auto-close not work
Step to reproduce: Close the buffer while the tree open
The text was updated successfully, but these errors were encountered: