neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.15k stars 953 forks source link

jumpdefinition buffer 1 not created #4973

Closed laoshaw closed 2 months ago

laoshaw commented 2 months ago

Result from CocInfo

## versions

vim version: VIM - Vi IMproved 9.0 9000749
node version: v20.12.0
coc.nvim version: 0.0.82-00bd79e0 2024-02-28 12:40:55 +0800
coc.nvim directory: /home/userx/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2024-04-09T18:21:02.178 INFO (pid:31373) [configurations] - Add folder configuration from file: /home/userx/tmp/frontend/webui/.vim/coc-settings.json
2024-04-09T18:21:02.655 INFO (pid:31373) [plugin] - coc.nvim initialized with node: v20.12.0 after 1746
2024-04-09T18:21:02.700 INFO (pid:31373) [services] - LanguageClient clangd state change: stopped => starting
2024-04-09T18:21:02.706 INFO (pid:31373) [language-client-index] - Language server "clangd" started with 31456
2024-04-09T18:21:03.073 INFO (pid:31373) [services] - LanguageClient clangd state change: starting => running
2024-04-09T18:21:03.082 INFO (pid:31373) [services] - service clangd started
2024-04-09T18:21:03.110 INFO (pid:31373) [core-watchman] - watchman watching project: /home/userx/tmp/frontend/webui
2024-04-09T18:24:30.571 INFO (pid:31373) [attach] - receive notification: jumpDefinition []
2024-04-09T18:25:00.883 INFO (pid:31373) [attach] - receive notification: detach []
2024-04-09T18:25:13.571 INFO (pid:31373) [attach] - receive notification: jumpDefinition []
2024-04-09T18:25:13.576 ERROR (pid:31373) [attach] - Error on notification jumpDefinition Error: Buffer 1 not created.
    at x1.getAttachedDocument (/home/userx/.vim/plugged/coc.nvim/build/index.js:198:3344)
    at Oy.getCurrentState (/home/userx/.vim/plugged/coc.nvim/build/index.js:281:34170)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async xy.request (/home/userx/.vim/plugged/coc.nvim/build/index.js:269:5498)
    at async xy.gotoDefinition (/home/userx/.vim/plugged/coc.nvim/build/index.js:269:6966)
    at async Ay.cocAction (/home/userx/.vim/plugged/coc.nvim/build/index.js:281:46295)
    at async EventEmitter.<anonymous> (/home/userx/.vim/plugged/coc.nvim/build/index.js:281:47916)
2024-04-09T18:25:24.155 INFO (pid:31373) [attach] - receive notification: jumpDefinition []
2024-04-09T18:25:24.159 ERROR (pid:31373) [attach] - Error on notification jumpDefinition Error: Buffer 1 not created.
    at x1.getAttachedDocument (/home/userx/.vim/plugged/coc.nvim/build/index.js:198:3344)
    at Oy.getCurrentState (/home/userx/.vim/plugged/coc.nvim/build/index.js:281:34170)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async xy.request (/home/userx/.vim/plugged/coc.nvim/build/index.js:269:5498)
    at async xy.gotoDefinition (/home/userx/.vim/plugged/coc.nvim/build/index.js:269:6966)
    at async Ay.cocAction (/home/userx/.vim/plugged/coc.nvim/build/index.js:281:46295)
    at async EventEmitter.<anonymous> (/home/userx/.vim/plugged/coc.nvim/build/index.js:281:47916)
2024-04-09T18:29:39.844 INFO (pid:31373) [attach] - receive notification: showInfo []

Describe the bug

A clear and concise description of what the bug is.

using with c file and a working compile_commands.json with clangd for coc.nvim.

I use 'gd' to jump to definition which worked fine initially, then I ctrl-o jump back and try gd on a different function then it reports "buffer 1 not create" and refuse to jump

Reproduce the bug

We will close your issue when you don't provide minimal vimrc and we can't reproduce it

it works well but jump to declaration instead of definition, is the default gd jump to declarations?

Screenshots (optional)

If applicable, add screenshots to help explain your problem.

fannheyward commented 2 months ago

I use 'gd' to jump to definition which worked fine initially, then I ctrl-o jump back and try gd on a different function then it reports "buffer 1 not create" and refuse to jump

Tested with vim 9.1 and latest coc.nvim with clangd, can't reproduce.

it works well but jump to declaration instead of definition, is the default gd jump to declarations?

How do you set your gd mapping? coc.nvim didn't set default gd.

coc.nvim requests to language server, handle the jumping with locations, before jumping to the document buffer that created and attached. The buffer 1 not created means the buffer is not created.

[attach] - receive notification: detach

It's strange that coc.nvim received detach event to detach the buffer.

laoshaw commented 2 months ago

I used the default suggestion in coc.nvim github: nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) this has been a while, and it occurs to me on various languages and is always reproducible, I don't know how to debug this and not sure if it's caused by something else.

laoshaw commented 2 months ago

it's very odd, I just tried to change .vimrc, it works without issues, I can recover the original .vimrc, it still works, now not sure what is going on, but it works for the moment.

fannheyward commented 2 months ago

occurs to me on various languages

What's the language server?

laoshaw commented 2 months ago

when it happens it seems to be LSP irrelevant, I tested clangd and tsserver

fannheyward commented 2 months ago

Needs a way to reproduce to debug the issue.

laoshaw commented 2 months ago

will try to find it out, it just came back, not sure if .vimrc caused it since changing .vimrc does make some difference, need check more closely, thanks.

fannheyward commented 2 months ago

Try to bisect your vimrc

laoshaw commented 2 months ago

did that before, so far the pattern is: while in the bisect, when my vimrc halves to a certain size(this varies, today's it's the first 700 line), 'gd' starts to fully work, now if I copy the original failed .vimrc, it still works, in short, when it starts to work, there is no more issues for the day. I'm going to try logout/reboot and see if that changes anything.

laoshaw commented 2 months ago

bisected to certain lines it starts to work, then it keeps working, even after I copy the original .vimrc back, or after a logout/login, or after a reboot, it keeps working and never dies, this is truly odd.

laoshaw commented 2 months ago

might be my own problem as I could not reproduce it on another ubuntu 22.04 laptop, but it occurs on my ubuntu 22.04 desktop

laoshaw commented 2 months ago
## versions

vim version: VIM - Vi IMproved 9.0 9000749
node version: v20.12.2
coc.nvim version: 0.0.82-d1568d56 2023-09-29 19:43:34 +0800
coc.nvim directory: /home/userx/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2024-04-24T22:13:27.606 WARN (pid:6859) [commands] - Command prettier.createConfigFile already registered
2024-04-24T22:13:27.606 WARN (pid:6859) [commands] - Command prettier.openOutput already registered
2024-04-24T22:13:27.606 WARN (pid:6859) [commands] - Command prettier.forceFormatDocument already registered
2024-04-24T22:13:27.606 WARN (pid:6859) [commands] - Command prettier.formatFile already registered
2024-04-24T22:13:27.650 INFO (pid:6859) [plugin] - coc.nvim initialized with node: v20.12.2 after 411
2024-04-24T22:13:27.658 INFO (pid:6859) [services] - LanguageClient clangd state change: stopped => starting
2024-04-24T22:13:27.663 INFO (pid:6859) [language-client-index] - Language server "clangd" started with 6920
2024-04-24T22:13:27.671 INFO (pid:6859) [services] - LanguageClient clangd state change: starting => running
2024-04-24T22:13:27.675 INFO (pid:6859) [services] - service clangd started
2024-04-24T22:13:27.909 INFO (pid:6859) [core-watchman] - watchman watching project: /home/userx/devel/notes
2024-04-24T22:13:29.407 INFO (pid:6859) [attach] - receive notification: jumpDefinition []
2024-04-24T22:13:31.050 INFO (pid:6859) [attach] - receive notification: detach []
2024-04-24T22:13:32.447 INFO (pid:6859) [attach] - receive notification: jumpDefinition []
2024-04-24T22:13:32.451 ERROR (pid:6859) [attach] - Error on notification jumpDefinition Error: Buffer 1 not created.
    at FE.getAttachedDocument (/home/userx/.vim/plugged/coc.nvim/build/index.js:194:3344)
    at $y.getCurrentState (/home/userx/.vim/plugged/coc.nvim/build/index.js:277:34038)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Iy.request (/home/userx/.vim/plugged/coc.nvim/build/index.js:265:5418)
    at async Iy.gotoDefinition (/home/userx/.vim/plugged/coc.nvim/build/index.js:265:6886)
    at async Gy.cocAction (/home/userx/.vim/plugged/coc.nvim/build/index.js:277:46159)
    at async EventEmitter.<anonymous> (/home/userx/.vim/plugged/coc.nvim/build/index.js:277:47778)
2024-04-24T22:13:39.508 INFO (pid:6859) [attach] - receive notification: showInfo []

now this shows up on both of my ubuntu 22.04, it comes and goes, most of the time it's there. so far I could not track down its root cause, it occurs randomly.

laoshaw commented 2 months ago

I removed most of my plugins and configuration tweaks, with only coc.nvim and a few must-have plugs, so far there is no issue