fix(neo-tree): correctly set up cwd (#3097)

* fix(neo-tree): correctly set up `cwd`

* refactor: cleanup

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
Iordanis Petkakis 2024-05-12 11:08:55 +03:00 committed by GitHub
parent f7450a5236
commit 30ce84f7a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 7 deletions

View file

@ -142,7 +142,10 @@ function M.setup()
LazyVim.root.info()
end, { desc = "LazyVim roots for the current buffer" })
vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged" }, {
-- FIX: doesn't properly clear cache in neo-tree `set_root` (which should happen presumably on `DirChanged`),
-- probably because the event is triggered in the neo-tree buffer, therefore add `BufEnter`
-- Maybe this is too frequent on `BufEnter` and something else should be done instead??
vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged", "BufEnter" }, {
group = vim.api.nvim_create_augroup("lazyvim_root_cache", { clear = true }),
callback = function(event)
M.cache[event.buf] = nil