I have coc.nvim with pyright installed. I added the following to my .vimrc

nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

I was hoping that pressnig gi over a function name will take me to the implementation, but alas, neither that nor gy does anything. This is the output of :CocInfo:

undefined## versions

vim version: VIM - Vi IMproved 8.1 8012269
node version: v14.15.0
coc.nvim version: 0.0.79-8b967b0bbd
coc.nvim directory: /home/fbence/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2020-12-12T18:33:40.895 INFO (pid:131785) [services] - registered service "pyright"
2020-12-12T18:33:40.896 INFO (pid:131785) [services] - Pyright Server state change: stopped => starting
2020-12-12T18:33:40.945 INFO (pid:131785) [plugin] - coc.nvim 0.0.79-8b967b0bbd initialized with node: v14.15.0 after 146ms
2020-12-12T18:33:40.952 INFO (pid:131785) [language-client-index] - pyright started with 131932
2020-12-12T18:33:41.096 INFO (pid:131785) [services] - Pyright Server state change: starting => running
2020-12-12T18:33:41.100 INFO (pid:131785) [services] - service pyright started
2020-12-12T18:33:42.654 INFO (pid:131785) [completion-complete] - Results from: around,pyright-1
2020-12-12T18:33:45.820 INFO (pid:131785) [completion-complete] - Results from: around,pyright-1
2020-12-12T18:34:48.147 WARN (pid:131785) [Handler] - type definition provider not found!
2020-12-12T18:34:55.149 WARN (pid:131785) [Handler] - implementation provider not found!

Is something not configured properly, or is this feature missing from pyright?


Let's say I have two files

# second.py
def myfunc(arg1):
    return 3*arg1
# first.py
from second import myfunc
a = myfunc(3)
#     |

My cursor is in first.py as designated by the |. If I press gd here the cursor will jump up a line to the line with the import and be on myfunc there. I would think, that gi would be what takes me to the function implementation in second.py.

  • The warnings for type definition provider not found and implementation look suspicious... Try searching for those on Google.
    – filbranden
    Dec 12 '20 at 17:59
  • Maybe my google-fu is not up-to-date, but I didn't really manage to get anything meaningful, so I was hoping maybe somebody here knows what's going on ...
    – fbence
    Dec 12 '20 at 18:12
  • 1
    Someone might indeed... I don't happen to be a user of CoC.nvim or of pyright, so I don't really know the details... But CoC.nvim is pretty popular, so you might find a good answer here.
    – filbranden
    Dec 12 '20 at 18:16

I think you are confused on what the various language sever protocol features do. I don't believe that trying to "go to implementation" or "go to type definition" on a function symbol makes any sense. If you are trying to go to the definition of the function, then you would want to "go to definition" (which would be gd with your mappings).

coc-implementation would be used for implementations of an interface, coc-type-definition would take you to the definition of the type of the variable (so if a variable was an object of class Fruit, it would take you to the Fruit class), and coc-references would show you all the references to the symbol.

  • What I was hoping for, is is I am over a function symbol and I press go to implementation, it takes me to the file where the actual function is implemented. If not for this, what is go to implementation for? Taking me to the implementation of Fruit would also be welcome. Maybe I am misunderstanding these though ... References can be used for getting there, but I have to search a bit.
    – fbence
    Dec 14 '20 at 17:52
  • Its a bit confusing, but you are looking for "go to definition". If you are hovered over a function symbol, then calling coc-definition would be what you want. That should take you to the location that the function is "implemented" or "defined' in.
    – pricheal
    Dec 14 '20 at 17:57
  • See my clarification in the question, coc-definition doesn't take me to the implementation, it takes me to the definition in the file. If the implementation happens to be in the same file the definition == implementation, but if they are in separate files this is not true.
    – fbence
    Dec 14 '20 at 21:45
  • 1
    @fbence in what case is function definition not the implementation? Perhaps in cases of declaration (like in C)? Concrete examples might help
    – D. Ben Knoble
    Dec 14 '20 at 22:27
  • Is my edit to the question not clear enough? The technical terms I am using might not be totally correct, but I hope the python example demonstrates what I was expecting.
    – fbence
    Dec 14 '20 at 22:42

Pyright doesn't support coc-implementation yet. You could use ALE instead, which seems to use Pyright under the hood.

A simple way to find your implementations of a class is to use coc-references instead.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.