Closed AgentCosmic closed 2 years ago
I have just installed and that command isn't working
works just fine for me, i cannot reproduce if you don't provide more informations.
I updated today and it doesn't find file in tree in some cases. What information would be helpful to find out what's wrong? I use nvim 0.5.1 on Linux and nvim-tree with default options.
For example, if I open some file in nvim from my home directory
~ $ nvim Documents/vimwiki/Vim.md
and then use the command
:NvimTreeFindFile
it opens nvim-tree just in my home directory
I'm experiencing the same problem
I think this issue is related to some LSP servers running in single file mode (e.g. clangd on a single file)
When I disable LSP (:LspStop
) NvimTreeFindFile
works correctly.
Maybe that happens because NvimTree tries to find LSP root directory, but since LSP is running in single file mode it goes to home directory
Screenshot from :LspInfo
:
Edit: my bad, this doesn't happen every time so maybe it isn't related to LSP
Edit2: if I press R
(to reload files in NvimTree) after :NvimTreeFindFile
it works well
So this shouldn't be LSP-related, but it's a matter of reloading
If you press R
after finding file NvimTree displays files well
If you press
R
after finding file NvimTree displays files well
I can confirm this. When I use NvimTreeFindFile
it doesn't work properly. Then I press R
and it works like a charm.
still cannot reproduce even with provided steps... Maybe someone could provide a minimal sample config file to reproduce this issue consistently.
NvimTreeFindFile
still doesn't work correctly for me after the fix
Fix didn't work for me either. Even after pressing R
.
Just out of curiosity, are you LunarVim users?
Nope, custom config https://github.com/AgentCosmic/neovim
I also use custom config https://github.com/kuznetsss/nvim_lua_config
I have debugged the issue a little and find that here https://github.com/kyazdani42/nvim-tree.lua/blob/2e33b1654384921ec1cc9656a2018744f3f1ce81/lua/nvim-tree/view.lua#L227
pcall
returns error Cursor position outside buffer
Also if you put here
https://github.com/kyazdani42/nvim-tree.lua/blob/2e33b1654384921ec1cc9656a2018744f3f1ce81/lua/nvim-tree/lib.lua#L221-L226
just M.redraw()
instead of calling git.load_project_status()
everything works fine for me.
So maybe to reproduce the issue you just need to be not in git repo.
Update:
The problematic call of git.load_project_status()
mentioned above ends with the line
https://github.com/kyazdani42/nvim-tree.lua/blob/2e33b1654384921ec1cc9656a2018744f3f1ce81/lua/nvim-tree/git/init.lua#L59
So it seems the problem in the lambda https://github.com/kyazdani42/nvim-tree.lua/blob/2e33b1654384921ec1cc9656a2018744f3f1ce81/lua/nvim-tree/lib.lua#L222-L225
I'll make PR fixing this
nvim-tree only opens the window but does not go to the file when I run
:NvimTreeFindFile
. I remember it working before. But it stopped working quite some time ago.