-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Keep tree open in all tabs #1880
Comments
Would an auto command on event such as |
That was my initial idea, but I couldn't find a way to get the state of the tree (only open it, if it is already open in another tab, close it if it is closed in the last active tab) |
I could get it to somewhat work using: local nt_api = require("nvim-tree.api")
local tree_open = false
local function tab_enter()
if tree_open then
nt_api.tree.open()
else
nt_api.tree.close()
end
end
nt_api.events.subscribe(nt_api.events.Event.TreeOpen, function() tree_open=true end)
nt_api.events.subscribe(nt_api.events.Event.TreeClose, function() tree_open=false end)
api.nvim_create_autocmd("TabEnter", {callback=tab_enter}) Remaining issues where I would be happy for some guidance:
|
Nice! Perhaps we could add an api returning state. @alex-courtis
Try detecting if nvim-tree is active, which it might always be, not sure, after switching tabs, and run
Try also |
This also works, great. This does what I want: local nt_api = require("nvim-tree.api")
local tree_open = false
local function tab_enter()
if tree_open then
nt_api.tree.open()
api.nvim_command("wincmd p")
else
nt_api.tree.close()
end
end
nt_api.events.subscribe(nt_api.events.Event.TreeOpen, function() tree_open=true end)
nt_api.events.subscribe(nt_api.events.Event.TreeClose, function() tree_open=false end)
api.nvim_create_autocmd("TabEnter,TabNewEnter", {callback=tab_enter})
|
Awesome! Would you mind adding it to wiki? |
We could do something generic like exposing nvim-tree.lua/lua/nvim-tree/utils.lua Line 401 in e322fbb
|
Is there a way to avoid opening same file duplicate tabs when a file is opened in a tab, and instead switch to the already open tab like coc-explorer does? |
That is standard vim behaviour: You can build this yourself. Something like:
|
This does not work for me. I am using it lazy.nvim and am placing it in nvim-tree.lua, as with all the other n vim-tree related configs: This is what I get:
It seems like it is an undefined variable. |
|
I'm confused how to use this as well, should I be able to put this in my If I make the
Thank you! |
Try to make list of events a table: |
I ended up doing something a little different that accomplishes the same functionality: #1493 (comment) |
Can this functionality be implemented utilising API?
Maybe, but I didn't find a way to detect if the tree is already open in another tab, so my idea of having a an autocmd on TabEnter did not work out.
Is your feature request related to a problem? Please describe.
I am basically looking for the same functionality as provided by https://github.com/jistr/vim-nerdtree-tabs for nerdtree.
Open the file tree ones, have it open in all tabs. When closing, have it close in all tabs. When having a tree open in one tab, creating a new tab or entering an existing tab without the tree open currently, there is no tree in the new tab. The other way around as well: closing the tree in one tab and then switching to one where it was open will still have it open.
Describe the solution you'd like
Be able to have the tree open/close/toggle for all tabs, including new tabs. Not sure what the best way of implementing is. Could be done minimally with new api reporting the current state or a top-level option for this behavior.
The text was updated successfully, but these errors were encountered: