neoclide / coc.nvim

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

CoC breaks on neovim's latest nightly #3388

Closed richin13 closed 2 years ago

richin13 commented 3 years ago

Result from CocInfo

While on neovim version 0.5.0

## versions

vim version: NVIM v0.5.0
node version: v14.15.1
coc.nvim version: 0.0.80-03c9add7cd
coc.nvim directory: /home/rmadriz/.config/nvim/pack/packager/start/coc.nvim
term: alacritty
platform: linux

## Log of coc.nvim

2021-09-20T08:14:49.309 INFO (pid:122330) [services] - registered service "jedi"
2021-09-20T08:14:49.312 INFO (pid:122330) [services] - jedi-language-server state change: stopped => starting
2021-09-20T08:14:49.334 INFO (pid:122330) [services] - registered service "highlight"
2021-09-20T08:14:49.349 INFO (pid:122330) [services] - registered service "diagnostic-languageserver"
2021-09-20T08:14:49.349 INFO (pid:122330) [services] - diagnostic language service state change: stopped => starting
2021-09-20T08:14:49.351 INFO (pid:122330) [plugin] - coc.nvim 0.0.80-03c9add7cd initialized with node: v14.15.1 after 541ms
2021-09-20T08:14:49.356 INFO (pid:122330) [language-client-index] - Language server "jedi" started with 122527
2021-09-20T08:14:49.418 INFO (pid:122330) [attach] - receive notification: highlight []
2021-09-20T08:14:49.521 INFO (pid:122330) [services] - diagnostic language service state change: starting => running
2021-09-20T08:14:49.522 INFO (pid:122330) [services] - service diagnostic-languageserver started
2021-09-20T08:14:49.760 INFO (pid:122330) [services] - jedi-language-server state change: starting => running
2021-09-20T08:14:49.762 INFO (pid:122330) [services] - service jedi started
2021-09-20T08:14:53.568 INFO (pid:122330) [attach] - receive notification: rename []
2021-09-20T08:14:54.974 WARN (pid:122330) [plugin] - Slow action "rename" cost 1405ms
2021-09-20T08:14:55.336 INFO (pid:122330) [attach] - receive notification: highlight []
2021-09-20T08:14:57.029 INFO (pid:122330) [attach] - receive notification: showInfo []

Latest nightly build (NVIM v0.6.0-dev+304-g924e8e4f2)

## versions

vim version: NVIM v0.6.0-dev+304-g924e8e4f2
node version: v14.15.1
coc.nvim version: 0.0.80-03c9add7cd
coc.nvim directory: /home/rmadriz/.config/nvim/pack/packager/start/coc.nvim
term: alacritty
platform: linux

## Log of coc.nvim

2021-09-20T08:13:29.579 INFO (pid:120114) [plugin] - coc.nvim 0.0.80-03c9add7cd initialized with node: v14.15.1 after 64ms
2021-09-20T08:13:29.885 INFO (pid:120114) [attach] - receive notification: highlight []
2021-09-20T08:13:32.954 INFO (pid:120114) [attach] - receive notification: rename []
2021-09-20T08:13:32.959 ERROR (pid:120114) [attach] - Notification error: rename [] Error: rename provider not found for current buffer, your language server doesn't support it.
    at Lw.checkProvier (/home/rmadriz/.config/nvim/pack/packager/start/coc.nvim/build/index.js:263:42354)
    at Sw.rename (/home/rmadriz/.config/nvim/pack/packager/start/coc.nvim/build/index.js:263:7427)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Aw.cocAction (/home/rmadriz/.config/nvim/pack/packager/start/coc.nvim/build/index.js:263:55784)
    at async wF.<anonymous> (/home/rmadriz/.config/nvim/pack/packager/start/coc.nvim/build/index.js:263:57390)
2021-09-20T08:13:44.950 INFO (pid:120114) [attach] - receive notification: runCommand [ 'workspace.showOutput' ]
2021-09-20T08:13:45.293 INFO (pid:120114) [attach] - receive notification: highlight []
2021-09-20T08:13:56.919 INFO (pid:120114) [attach] - receive notification: showInfo []

Describe the bug

When using a nightly build of neovim CoC won't register any services at all and whenever you try to use your language server's feature it throws an error message:

2021-09-20T08:13:32.959 ERROR (pid:120114) [attach] - Notification error: rename [] Error: rename provider not found for current buffer, your language server doesn't support it.
    at Lw.checkProvier (/home/rmadriz/.config/nvim/pack/packager/start/coc.nvim/build/index.js:263:42354)
    at Sw.rename (/home/rmadriz/.config/nvim/pack/packager/start/coc.nvim/build/index.js:263:7427)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Aw.cocAction (/home/rmadriz/.config/nvim/pack/packager/start/coc.nvim/build/index.js:263:55784)
    at async wF.<anonymous> (/home/rmadriz/.config/nvim/pack/packager/start/coc.nvim/build/index.js:263:57390)

I first noticed this issue Yesterday, Sunday 19th 2021. It works fine with the latest stable release (0.5.0)

Reproduce the bug

For this you will need to have a way to use two different versions of neovim so that you can compare the results. I'm using asdf version manager to switch between versions. The following config file reproduces the issue as long as you use the right version.

Screenshots (optional)

The above logs it's all I got 😅

fannheyward commented 3 years ago

I can't get a nvim nightly release from https://github.com/neovim/neovim/releases, so I built from source https://github.com/neovim/neovim/commit/e8fb0728e220bb378a8689415c3915fe5912e987.

:version
NVIM v0.6.0-dev+e8fb0728e
Build type: Release
LuaJIT 2.1.0-beta3

Tested with the master and release branch, can't reproduce this, the rename/doHover works as expected.

fannheyward commented 3 years ago

Tested with node 14 and 16, coc-tsserver for TypeScript, coc-pyright/coc-jedi for Python, coc-go for Go project, with coc.nvim release branch, still can't reproduce this.

fannheyward commented 3 years ago

@npearson72 @UltiRequiem @pappasam @andrevmatos sorry to boring you, but I saw you reacted on this issue, can you guys share something info/steps to reproduce this?

richin13 commented 3 years ago

@fannheyward thanks for looking into it; one important thing to mention is that I don't use g:coc_global_extensions nor CocInstall and instead added the plugins directly with my package manager like this:

    call packager#add('pappasam/coc-jedi', {'do': 'yarn install --frozen-lockfile'})
richin13 commented 3 years ago

I can't get a nvim nightly release from https://github.com/neovim/neovim/releases, so I built from source neovim/neovim@e8fb072.

:version
NVIM v0.6.0-dev+e8fb0728e
Build type: Release
LuaJIT 2.1.0-beta3

Tested with the master and release branch, can't reproduce this, the rename/doHover works as expected.

Yep, there's an issue in neovim (https://github.com/neovim/neovim/issues/15709) where sometimes the CI will fail to publish the latest nightly. I'll try again with master

richin13 commented 3 years ago

@fannheyward confirming the issue is still there when building directly from master however, CocInstalled plugins are not affected. I've

  1. Manually deleted coc-tsserver located at $HOME/.config/nvim/pack/packager/start/coc-tsserver
  2. Installed it again using :CocInstall
  3. Opened my typescript test file and everything works as normal, here's CocInfo after this change:
## versions

vim version: NVIM v0.6.0-dev
node version: v16.6.0
coc.nvim version: 0.0.80-03c9add7cd
coc.nvim directory: /home/rmadriz/.config/nvim/pack/packager/start/coc.nvim
term: alacritty
platform: linux

## Log of coc.nvim

2021-09-22T07:40:04.834 INFO (pid:1470243) [plugin] - coc.nvim 0.0.80-03c9add7cd initialized with node: v16.6.0 after 132ms
2021-09-22T07:40:04.872 INFO (pid:1470243) [services] - registered service "tsserver"
2021-09-22T07:40:06.375 INFO (pid:1470243) [attach] - receive notification: highlight []
2021-09-22T07:40:08.006 INFO (pid:1470243) [attach] - receive notification: showInfo []

Notice how this time the service was correctly discovered so this is definitely an issue with 'manually' installed plugins

fannheyward commented 3 years ago

added the plugins directly with my package manager like this:

call packager#add('pappasam/coc-jedi', {'do': 'yarn install --frozen-lockfile'})

@richin13 what's the package manager? https://github.com/therealblurch/vim-packager ?

Please make sure the yarn build is successful, after the successful building, for example coc-tsserver, there will be lib/index.js in the coc-tsserver root.

pappasam commented 3 years ago

@fannheyward I can reproduce. When I change from 0.5.1 to nightly, coc extensions managed as vim packages no longer work. The exact same installed packages work fine when the Vim version I use is 0.5.1 or 0.5.0.

Note: we're using vim's native package tooling. Maybe you're reproducing with an old-style plugin manager like vim-plug?

fannheyward commented 3 years ago

@pappasam I'm using vim-plug, here's my tests:

  1. Plug 'pappasam/coc-jedi', {'do': 'yarn install --frozen-lockfile'}
  2. PlugInstall, the yarn building is working
  3. open a Python file, coc-jedi is working to install jedi-language-server

Tested on nvim v0.6.0-dev+bec7f47ce.

yaegassy commented 3 years ago

Related issues? https://github.com/neovim/neovim/issues/15837

oblitum commented 3 years ago

@fannheyward, @pappasam meant that given you're using vim-plug to try reproduce the issue, you won't be able to because they're using native package management (like packer.nvim does, but not vim-plug).

fannheyward commented 3 years ago

@oblitum thank you for your point, I misunderstood @pappasam 's comment. I'll test with packer.nvim today. (I'm not a packer.nvim user, any help for this will be great.

Maybe this related https://github.com/neovim/neovim/pull/15632

fannheyward commented 3 years ago

coc.nvim will load extensions from &runtimepath.

init.vim:

if &compatible
  set nocompatible
endif

function! s:packager_init(packager) abort
  call a:packager.add('neoclide/coc.nvim', { 'branch': 'release' })
  call a:packager.add('fannheyward/coc-pyright', { 'do': 'yarn install --frozen-lockfile' })
endfunction

packadd vim-packager
call packager#setup(function('s:packager_init'))

nvim 0.5.1 + https://github.com/therealblurch/vim-packager:

[
  '/Users/fannheyward/.config/nvim',
  '/Users/fannheyward/.config/nvim/pack/packager/start/coc.nvim',
  '/Users/fannheyward/.config/nvim/pack/packager/start/coc-pyright',
  '/Users/fannheyward/.config/nvim/pack/packager/opt/vim-packager',
...
]

nvim 0.6.0 + https://github.com/therealblurch/vim-packager:

[
  '/Users/fannheyward/.config/nvim',
  '/Users/fannheyward/.config/nvim/pack/packager/opt/vim-packager',
...
]
fannheyward commented 3 years ago

Tested with https://github.com/wbthomason/packer.nvim

-- This file can be loaded by calling `lua require('plugins')` from your init.vim

return require('packer').startup(function()
  use {
    'neoclide/coc.nvim', branch = 'release'
  }
  use {
    'fannheyward/coc-pyright', run = 'yarn install --frozen-lockfile'
  }
  -- Packer can manage itself
  use 'wbthomason/packer.nvim'
end)

nvim 0.5.1:

[
  '/Users/fannheyward/.config/nvim',
  '/etc/xdg/nvim',
  '/Users/fannheyward/.local/share/nvim/site',
  '/Users/fannheyward/.local/share/nvim/site/pack/packer/start/packer.nvim',
  '/Users/fannheyward/.local/share/nvim/site/pack/packer/start/coc.nvim',
  '/Users/fannheyward/.local/share/nvim/site/pack/packer/start/coc-pyright',
...
]

nvim 0.6.0:

[
  '/Users/fannheyward/.config/nvim',
  '/etc/xdg/nvim',
  '/Users/fannheyward/.local/share/nvim/site',
  '/Users/fannheyward/.local/share/nvim/site/pack/packer/start/packer.nvim',
]
fannheyward commented 3 years ago

Add vim.cmd [[packadd coc-pyright]] in plugins.lua fixed this, now nvim 0.6.0:

[
  '/Users/fannheyward/.config/nvim',
  '/etc/xdg/nvim',
  '/Users/fannheyward/.local/share/nvim/site',
  '/Users/fannheyward/.local/share/nvim/site/pack/packer/start/coc-pyright',
  '/Users/fannheyward/.local/share/nvim/site/pack/packer/start/packer.nvim',
...
]
richin13 commented 3 years ago

Thanks everyone for the help, explicitly packadding the extensions solved it. I'm closing this since is not really related to CoC and more an issue with neovim itself.

pappasam commented 2 years ago

@richin13 @fannheyward I'm not sure this should be closed. Although the packadd hack does resolve the issue for users who think to use it, I think the way coc handles the runtime path should be fixed. See https://github.com/Shougo/defx.nvim/commit/701b2a9b04055d056cd2e3e1f6f6fa555b0c4cb6 for an example resolution of the underlying issue for defx.

I believe the relevant function that needs to be updated in coc.nvim is here: https://github.com/neoclide/coc.nvim/blob/master/src/extensions.ts#L680

oblitum commented 2 years ago

I agree, manually having to add packadd isn't the usual workflow of packer.nvim managed plugins.

andrevmatos commented 2 years ago

I can reproduce this issue on NixOS, with neovim-nightly-overlay; having the coc extensions installed from nix (home-manager), on current neovim stable (neovim-unwrapped package on nixos unstable/current), the extensions are loaded and listed, while just activating the overlay to use neovim-nightly makes them not be loaded/seen by CoC, although CoC and the other nvim plugins do get properly loaded.

savl-2021 commented 2 years ago

I have the same issue with nvim 0.6.0+dev+544+g7ae86c1d4-1 - after upgrading nvim and upgrading coc - there is no any extension loaded and coc is not working

savl-2021 commented 2 years ago

Add vim.cmd [[packadd coc-pyright]] in plugins.lua fixed this, now nvim 0.6.0:

[
  '/Users/fannheyward/.config/nvim',
  '/etc/xdg/nvim',
  '/Users/fannheyward/.local/share/nvim/site',
  '/Users/fannheyward/.local/share/nvim/site/pack/packer/start/coc-pyright',
  '/Users/fannheyward/.local/share/nvim/site/pack/packer/start/packer.nvim',
...
]

Could you provide what exactly should be placed in plugins.lua file to get coc-plugins work

fannheyward commented 2 years ago

@savl-2021 add vim.cmd [[packadd coc-pyright]] to your plug-in.lua.

There's a PR to fix this in a better way.

pappasam commented 2 years ago

@fannheyward this is now a usability issue with neovim's latest stable release: https://github.com/neovim/neovim/releases/tag/v0.6.0

andrevmatos commented 2 years ago

NixOS unstable just merged neovim's 0.6.0 release, effectively breaking coc plugins loading. Does anyone know a workaround? It seems vimPlugins.coc-nvim is built from the release branch, and therefore quite hard to overlay with the patch from the linked PR.

oblitum commented 2 years ago

@andrevmatos workaround is provided by @fannheyward in thread already. Either that or using coc's own dep system, which still works fine.

fannheyward commented 2 years ago

Should be fixed in https://github.com/neoclide/coc.nvim/pull/3511