Repository navigation
|
The idea is to find the project's root dir based on current file, when entering a buffer and set neotree's root accordingly IF neotree is already open. I have tried this: vim.api.nvim_create_autocmd('BufEnter', {
callback = function()
local fp = vim.api.nvim_buf_get_name(0)
local rootdir = vim.fs.root(fp, {'README.md', "Makefile", ".git"})
require("neo-tree.command").execute({
reveal = false,
focus = false,
dir = rootdir
})
end,
})But it does not work properly because it constantly open and try re-focus neotree, which puzzle me.. |
Answered by
pynappo
Dec 30, 2025
Replies: 1 comment 1 reply
|
In fact I realize that I do not know how to set neotree's root dir without opening it in lua. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the focusing issue you can add
action = "show"To only do it when neo-tree is open, the current way is basically to loop over open windows and check for
vim.bo[bufnr].filetype = "neo-tree"