rust-tools.nvim
                                
                                
                                
                                    rust-tools.nvim copied to clipboard
                            
                            
                            
                        inlay_hints error when removing a file with NvimTree
I'm getting the following error when removing a file, that is opened in a buffer, using NvimTree:
Error executing vim.schedule lua callback: ...m/plugged/rust-tools.nvim/lua/rust-tools/inlay_hints.lua:14: Invalid buffer id: 5
stack traceback:
        [C]: in function 'nvim_buf_clear_namespace'
        ...m/plugged/rust-tools.nvim/lua/rust-tools/inlay_hints.lua:14: in function 'clear_ns'
        ...m/plugged/rust-tools.nvim/lua/rust-tools/inlay_hints.lua:245: in function 'render'
        ...m/plugged/rust-tools.nvim/lua/rust-tools/inlay_hints.lua:165: in function 'handler'
        ...Cellar/neovim/0.7.2_1/share/nvim/runtime/lua/vim/lsp.lua:1025: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
To reproduce the error, open NvimTree, open a .rs file, delete the file by hitting d in NvimTree. I also tried to reproduce the bug by removing the buffer with :bd and :bw but everything worked fine.
I think adding a vim.api.nvim_buf_is_valid(bufnr) to https://github.com/simrat39/rust-tools.nvim/blob/master/lua/rust-tools/inlay_hints.lua#L14 should fix the issue. Let me know if that makes sense, also I can submit a PR if you want.
Yup, that should work. Feel free to PR!