litee-calltree.nvim icon indicating copy to clipboard operation
litee-calltree.nvim copied to clipboard

Invalid buffer id: 1 when doing an incoming/outgoing calls

Open olatheander opened this issue 3 years ago • 6 comments

Doing a lua vim.lsp.buf.outgoing_calls() (or a lua vim.lsp.buf.incoming_calls()) cause the error below to be shown. After pressing Enter the call hierarchy shows in panel/popout as expected.

Error executing vim.schedule lua callback: ...tart/litee-calltree.nvim/lua/litee/calltree/handlers.lua:148: Invalid buffer id: 1                                                                                                                                            
stack traceback:                                                                                                                                                                                                                                                            
        [C]: in function 'nvim_create_autocmd'                                                                                                                                                                                                                              
        ...tart/litee-calltree.nvim/lua/litee/calltree/handlers.lua:148: in function 'handler'                                                                                                                                                                              
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1025: in function ''                                                                                                                                                                                                        
        vim/_editor.lua: in function <vim/_editor.lua:0>  
:version                                                                                                                                                                                                                                                                    
NVIM v0.7.2                                                                                                                                                                                                                                                                 
Build type: Release                                                                                                                                                                                                                                                         
LuaJIT 2.1.0-beta3                                                                                                                                                                                                                                                          
Compiled by builduser                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                            
Features: +acl +iconv +tui                                                                                                                                                                                                                                                  
See ":help feature-compile"                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                            
   system vimrc file: "$VIM/sysinit.vim"                                                                                                                                                                                                                                    
  fall-back for $VIM: "/usr/share/nvim"                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                            
Run :checkhealth for more info  

olatheander avatar Sep 01 '22 16:09 olatheander

The above error would indicate you unloaded the buffer in which you initially invoked the calltree.

The handler will grab the current buffer when the lsp call is made and then assign an auto command (event handler) to it.

When you experience this can you do a ": ls!" And see that state of the buffer which matches the buffer id in the error?

ldelossa avatar Sep 01 '22 20:09 ldelossa

Hi,

That buffer id does not exist (it's always =1 it seems) in the list produced by : ls!:

:ls!                                                                                                                                                                                                                                                                        
  2u h   "[Scratch]"                    line 0                                                                                                                                                                                                                              
  3u h-  "Calltree Help"                line 0                                                                                                                                                                                                                              
  4u h-  "Filetree Help"                line 0                                                                                                                                                                                                                              
  5u h-  "Bookmarks Help"               line 0 
...
..

Basically what I do is just put the cursor in side a method (Java/JDTLS) and perform the command:

: lua vim.lsp.buf.incoming_calls()

which then generate the error and after I pressed <Enter> the panel is displayed and working as expected (i.e. displaying the expected incoming/outgoing calls).

I only managed to get this to work at all for Java currently. E.g. for TS I get:

method textDocument/prepareCallHierarchy is not supported by any of the servers registered for the current buffer 

but I try to get that fixed so that I can try with another LSP-server.

olatheander avatar Sep 02 '22 09:09 olatheander

Odd, can you see if this happens with another LSP, wonder if it's specific to java

ldelossa avatar Sep 02 '22 22:09 ldelossa

I have the same issue (golang code).

marcomayer avatar Sep 16 '22 12:09 marcomayer

can you both check if the latest push fixed this?

ldelossa avatar Sep 27 '22 03:09 ldelossa

Yup works for me again now 👍

marcomayer avatar Sep 27 '22 10:09 marcomayer