neoclide / coc.nvim

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

Golang with gopls Notification error: jumpDefinition [] Error: current buffer 14 not attached #3726

Closed diabloneo closed 2 years ago

diabloneo commented 2 years ago

Result from CocInfo

Env:

## versions

vim version: NVIM v0.7.0-dev
node version: v16.14.0
coc.nvim version: 0.0.80-5830e03d 2022-03-27 04:58:12 +0800
coc.nvim directory: /home/ubuntu/.config/nvim/plugged/coc.nvim
term: screen-256color
platform: linux

## Log of coc.nvim
2022-03-28T18:28:36.577 INFO (pid:36239) [services] - registered service "languageserver.ccls"
2022-03-28T18:28:36.578 INFO (pid:36239) [services] - registered service "languageserver.bash"
2022-03-28T18:28:36.578 INFO (pid:36239) [services] - registered service "languageserver.golang"
2022-03-28T18:28:36.674 INFO (pid:36239) [plugin] - coc.nvim initialized with node: v16.14.0 after 149ms
2022-03-28T18:28:44.114 INFO (pid:36239) [services] - golang state change: stopped => starting
2022-03-28T18:28:44.125 INFO (pid:36239) [language-client-index] - Language server "languageserver.golang" started with 36377
2022-03-28T18:28:44.242 INFO (pid:36239) [services] - golang state change: starting => running
2022-03-28T18:28:44.245 INFO (pid:36239) [services] - service languageserver.golang started
2022-03-28T18:39:51.873 INFO (pid:36239) [completion-complete] - 2 results from: around,languageserver.golang
2022-03-28T18:40:23.087 INFO (pid:36239) [attach] - receive notification: jumpDefinition []
2022-03-28T18:40:23.093 ERROR (pid:36239) [attach] - Notification error: jumpDefinition [] Error: current buffer 14 not attached
    at Zx.getCurrentState (/home/ubuntu/.config/nvim/plugged/coc.nvim/build/index.js:280:22528)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Dx.request (/home/ubuntu/.config/nvim/plugged/coc.nvim/build/index.js:270:2681)
    at async Dx.gotoDefinition (/home/ubuntu/.config/nvim/plugged/coc.nvim/build/index.js:270:4148)
    at async Jx.cocAction (/home/ubuntu/.config/nvim/plugged/coc.nvim/build/index.js:280:34384)
    at async U1.<anonymous> (/home/ubuntu/.config/nvim/plugged/coc.nvim/build/index.js:280:35903)
2022-03-28T18:40:27.564 INFO (pid:36239) [attach] - receive notification: showInfo []

Describe the bug

I work on a Golang project which use gopls as language server. The error happens sometimes when I try to jump to some definitions.

The way I used neovim and coc is:

chemzqm commented 2 years ago

https://github.com/neoclide/coc.nvim/blob/0a6977dd0f59f4ee9daab6525162b5d4a14d13dd/doc/coc.txt#L2229

diabloneo commented 2 years ago

Hi, @chemzqm

I checked the four reasons in the document:

  1. The 'buftype' option is neither nor acwrite. ( It's empty)
  2. Buffer variable b:coc_enabled is set to 0. (It's undefined)
  3. Size of buffer bigger than coc.preferences.maxFileSize configuration. (Not exceed)
  4. The buffer is used for command line window. (It's a normal source code file buffer)

So, I still can't figure the reason. Any more guides?

B.T.W, I used release branch when I reported this issue, and later I tried with master branch, still got same issue.

chemzqm commented 2 years ago

Could be autocmds not fired for document, try minimal vimrc or use set updatetime=300 and make sure CursorHold event fired.

chemzqm commented 2 years ago

Try upgrade coc.nvim, might be fixed.

drewbailey commented 2 years ago

Hi just wanted to +1 this issue and that after updating after this comment it seems to be better for me (haven't run into it again yet).

diabloneo commented 2 years ago

@chemzqm Them problem seems solved after I upgraded coc.nvim. I tested with NVIM v0.6.1.

mingleeShade commented 2 years ago

I got the same problem, after I updgrade coc.nvim, the problem still exists. Here is my log from CocInfo:

## versions                                                                                                                                                                          

vim version: NVIM v0.6.1                                                                                                                                                             
node version: v14.18.3                                                                                                                                                               
coc.nvim version: 0.0.80-0042eb35 2022-04-19 23:44:42 +0800                                                                                                                          
coc.nvim directory: /home/haiming/.config/nvim/plugged/coc.nvim                                                                                                                      
term: tmux                                                                                                                                                                           
platform: linux                                                                                                                                                                      

## Log of coc.nvim                                                                                                                                                                   

2022-04-20T14:25:20.297 INFO (pid:22158) [services] - registered service "languageserver.golang"                                                                                     
2022-04-20T14:25:20.327 INFO (pid:22158) [coc-git] - Looking for git in: git                                                                                                         
2022-04-20T14:25:20.398 INFO (pid:22158) [plugin] - coc.nvim initialized with node: v14.18.3 after 204ms                                                                             
2022-04-20T14:25:20.894 INFO (pid:22158) [attach] - receive notification: highlight []                                                                                               
2022-04-20T14:25:24.568 INFO (pid:22158) [attach] - receive notification: highlight []                                                                                               
2022-04-20T14:25:25.265 INFO (pid:22158) [attach] - Request action: jumpDefinition []                                                                                                
2022-04-20T14:25:25.267 ERROR (pid:22158) [attach] - Request error: jumpDefinition [] Error: Document of 1 not attached, checkout :h CocAction('ensureDocument')                     
    at g$.getAttachedDocument (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:200:2499)
    at $x.getCurrentState (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:288:22556)                                                                                     
    at processTicksAndRejections (internal/process/task_queues.js:95:5)                                                                                                              
    at async _x.request (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:276:2680)                                                                                        
    at async _x.gotoDefinition (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:276:4147)                                                                                 
    at async Xx.cocAction (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:288:34336)                                                                                     
    at async nA.<anonymous> (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:288:36304)
mingleeShade commented 2 years ago

I got the same problem, after I updgrade coc.nvim, the problem still exists. Here is my log from CocInfo:

## versions                                                                                                                                                                          

vim version: NVIM v0.6.1                                                                                                                                                             
node version: v14.18.3                                                                                                                                                               
coc.nvim version: 0.0.80-0042eb35 2022-04-19 23:44:42 +0800                                                                                                                          
coc.nvim directory: /home/haiming/.config/nvim/plugged/coc.nvim                                                                                                                      
term: tmux                                                                                                                                                                           
platform: linux                                                                                                                                                                      

## Log of coc.nvim                                                                                                                                                                   

2022-04-20T14:25:20.297 INFO (pid:22158) [services] - registered service "languageserver.golang"                                                                                     
2022-04-20T14:25:20.327 INFO (pid:22158) [coc-git] - Looking for git in: git                                                                                                         
2022-04-20T14:25:20.398 INFO (pid:22158) [plugin] - coc.nvim initialized with node: v14.18.3 after 204ms                                                                             
2022-04-20T14:25:20.894 INFO (pid:22158) [attach] - receive notification: highlight []                                                                                               
2022-04-20T14:25:24.568 INFO (pid:22158) [attach] - receive notification: highlight []                                                                                               
2022-04-20T14:25:25.265 INFO (pid:22158) [attach] - Request action: jumpDefinition []                                                                                                
2022-04-20T14:25:25.267 ERROR (pid:22158) [attach] - Request error: jumpDefinition [] Error: Document of 1 not attached, checkout :h CocAction('ensureDocument')                     
    at g$.getAttachedDocument (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:200:2499)
    at $x.getCurrentState (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:288:22556)                                                                                     
    at processTicksAndRejections (internal/process/task_queues.js:95:5)                                                                                                              
    at async _x.request (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:276:2680)                                                                                        
    at async _x.gotoDefinition (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:276:4147)                                                                                 
    at async Xx.cocAction (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:288:34336)                                                                                     
    at async nA.<anonymous> (/home/haiming/.config/nvim/plugged/coc.nvim/build/index.js:288:36304)

Problem solved, I used to set config 'coc.preferences.maxFileSize' to 25M, but I make a mistake of setting '25MB' to '25M', maybe that's the reason. After change 'M' to 'MB', the problem seems solved.

chemzqm commented 2 years ago

Use command :CocCommand document.checkBuffer to check buffer state.