pappasam / coc-jedi

coc.nvim wrapper for https://github.com/pappasam/jedi-language-server
MIT License
229 stars 9 forks source link

Cannot open Pip module documentation when imported as alias #47

Open mxkrn opened 2 years ago

mxkrn commented 2 years ago

It seems like coc-jedi doesn't follow aliased imports when looking up documentation.

For example in the code snippet below, the lookup (using showDocumentation) for numpy.ones works but for np.ones it tells me that it cannot find the documentation.

import numpy as np
import numpy

a = np.ones((1, 2))
b = numpy.ones((1, 2)

I'm using coc-jedi without the jedi-language-server package and in a virtual environment. I guess this could be considered a feature request.

pappasam commented 2 years ago

Sorry you're experiencing this! That said, I cannot reproduce on my end.

numpy-example

Would you be able to describe as many specifics about your environment that you can think of? For example, which OS, which Python version, how you're installing coc-jedi, etc?

mxkrn commented 2 years ago

Hey, thanks for the quick reply, my system is as follows:

OS: Ubuntu 20.04 on WSL2 Python: 3.9.7 Virtual environment: conda

I'm installing coc-jedi using vim-plug for neovim.

I played around with this a bit more and I'm starting to get better results after fixing some loose ends in my PYTHONPATH, progress means jump definition is now working consisntely well which was also failing before. However, showing the documentation for aliases or even imported modules, i.e. from collections import defaultdict, is still failing and just showing this message:


No Python documentation found for 'defaultdict'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
pappasam commented 2 years ago

This issue is directly related to an existing issue: our default conda support: https://github.com/pappasam/coc-jedi/issues/4

Basically, if might be a good idea for us to determine whether the user is using conda (or to at least provide a configuration option for conda). If you're willing to play around a bit, a good place in the code to start might he here: https://github.com/pappasam/coc-jedi/blob/171c3da4e4edaebb2f4df4c87d1ef1afadb1fc84/src/jlsExecutable.ts#L58-L70

pappasam commented 2 years ago

@mxkrn would you be able to test out the latest release and see if it resolves your issue with conda? The latest release solved a problem with system-site-packages for normal virtual environments and I'm wondering if that fix may have inadvertently resolved this issue too? If it hasn't, then we can keep trying a conda-specific approach.

mxkrn commented 2 years ago

@pappasam Took me a while but I finally got around to checking out the latest release, jump definition has improved and now also finds all aliased imports. However, for some reason it shows me twice the same definition option (duplicated) to jump to.

Documentation has improved in that it finds it, the problem is that it just briefly shows the docs and then it immediately disappears. (see gif) test-nvim