trouble.nvim
trouble.nvim copied to clipboard
Invalid buffer id on opening Trouble
Hi,
I've been getting an intermittent error using trouble for quite a while now when running
Trouble lsp_workspace_diagnostics
ever so often the command will fail with the following error
E5108: Error executing lua ...m/site/pack/packer/opt/trouble.nvim/lua/trouble/util.lua:72: Invalid buffer id: 13
This error also seems to take down Telescope's workspace diagnostics once it happens. I can still access the diagnostics using the lsp's set loclist function on LspDiagnosticsChanged
. I'm not really sure what is happening exactly since it only happens from time to time.
Looking at the code the process_items
function seems to be where it's happening i.e. a bufnr is being passed to nvim_buf_get_name
but the number is no longer valid. Seems to have been unloaded, when I check for the buffer number using ls!
it is not in the list.
Tbh I'm not sure why/how it has reference to a buffer that has since vanished but I guess a naive fix would be to check the bufnr is valid before using it.
As the logic is borrowed from telescope and it also errors it seems somewhere/somehow in my config or some plugin a buffer is being created which this plugin gets a reference to then being removed but I can't identify what is doing it because by the time this error occurs all traces of this buffer are gone
I get this constantly after a while. Can't really figure out what's wrong. BTW, this mostly happens when working in Dart with flutter-tools.nvim
Here's a full stacktrace that may help:
E5108: Error executing lua ...s/fperson/.vim/plugged/trouble.nvim/lua/trouble/util.lua:128: Invalid buffer id: 30
stack traceback:
[C]: in function 'nvim_buf_get_name'
...s/fperson/.vim/plugged/trouble.nvim/lua/trouble/util.lua:128: in function 'process_item'
...lugged/trouble.nvim/lua/trouble/providers/diagnostic.lua:25: in function 'provider'
....vim/plugged/trouble.nvim/lua/trouble/providers/init.lua:55: in function 'get'
...erson/.vim/plugged/trouble.nvim/lua/trouble/renderer.lua:37: in function 'render'
...s/fperson/.vim/plugged/trouble.nvim/lua/trouble/view.lua:129: in function 'update'
...s/fperson/.vim/plugged/trouble.nvim/lua/trouble/view.lua:201: in function 'setup'
...s/fperson/.vim/plugged/trouble.nvim/lua/trouble/view.lua:373: in function 'create'
...s/fperson/.vim/plugged/trouble.nvim/lua/trouble/init.lua:82: in function 'open'
...s/fperson/.vim/plugged/trouble.nvim/lua/trouble/init.lua:98: in function 'toggle'
[string ":lua"]:1: in main chunk
I just noticed this happens after the first file save, regardless of whether trouble was toggled before. I'll look into this a bit more and see if there's possibly something in my config that causes this behavior
UPD: I feel like this was caused by a BufWritePre
autocommand saving the session with Shatur/neovim-session-manager
. It also caused some other issues (like closing the file manager, the trouble popup, not saving git messages properly, etc.). I got rid of it, and the issue seems resolved so far. I'll come back & update the comment after a while to confirm it works.
UPD2: I confirm that the issues were indeed caused by the session manager. trouble works perfect for me now!
Development on the main branch is EOL.
Trouble has been rewritten and will be merged in main soon.
This issue/feature either no longer exists or has been implemented on dev.
For more info, see https://github.com/folke/trouble.nvim/tree/dev