Skip to content
This repository was archived by the owner on Dec 24, 2020. It is now read-only.

Jump To Definition does not work for modules inside site-packages #144

Open
Dissonant-Tech opened this issue Feb 18, 2020 · 10 comments · May be fixed by #295
Open

Jump To Definition does not work for modules inside site-packages #144

Dissonant-Tech opened this issue Feb 18, 2020 · 10 comments · May be fixed by #295

Comments

@Dissonant-Tech
Copy link

When calling using jump to definition inside of a file in any of the site-packages directories I get: Definition provider not found for current document.

Jumping to/from modules inside of the project works fine, but once I go to any definition outside of the project I get the above error.

The following MPLS output shows the request and response for the initial jump that sends me into the Django site-packages, following requests are not sent to the MPLS server at all and just result in
Definition provider not found for current document

[Trace - 12:11:16 PM] Sending request 'textDocument/definition - (1)'.                                                                                                                                              
Params: {                                                                                                                                                                                                           
    "textDocument": {                                                                                                                                                                                               
        "uri": "file:///[REDACTED]/user_auth/models.py"                                                                                                                    
    },                                                                                                                                                                                                              
    "position": {                                                                                                                                                                                                   
        "line": 4,                                                                                                                                                                                                  
        "character": 22                                                                                                                                                                                             
    }                                                                                                                                                                                                               
}                                                                                                                                                                                                                   
                                                                                                                                                                                                                    
                                                                                                                                                                                                                    
[Trace - 12:11:16 PM] Received notification 'python/reportProgress'.                                                                                                                                                
Params: [                                                                                                                                                                                                           
    "Analyzing in background, 130 items left..."                                                                                                                                                                    
]                                                                                                                                                                                                                   
                                                                                                                                                                                                                    
                                                                                                                                                                                                                    
[Trace - 12:11:17 PM] Received notification 'telemetry/event'.                                                                                                                                                      
Params: {                                                                                                                                                                                                           
    "EventName": "python_language_server/rpc.request",                                                                                                                                                              
    "Properties": {                                                                                                                                                                                                 
        "method": "textDocument/definition",                                                                                                                                                                        
        "plsVersion": "0.5.30.0"                                                                                                                                                                                    
    },                                                                                                                                                                                                              
    "Measurements": {                                                                                                                                                                                               
        "elapsedMs": 338.8661                                                                                                                                                                                       
    }                                                                                                                                                                                                               
}                                                                                                                                                                                                                   
                                                                                                                                                                                                                    
                                                                                                                                                                                                                    
[Trace - 12:11:17 PM] Received response 'textDocument/definition - (1)' in 392ms.                                                                                                                                   
Result: [                                                                                                                                                                                                           
    {                                                                                                                                                                                                               
        "uri": "file:///home/dissonance/.local/lib/python3.8/site-packages/django/db/models/__init__.py",                                                                                                           
        "range": {                                                                                                                                                                                                  
            "start": {                                                                                                                                                                                              
                "line": 0,                                                                                                                                                                                          
                "character": 0                                                                                                                                                                                      
            },                                                                                                                                                                                                      
            "end": {                                                                                                                                                                                                
                "line": 0,                                                                                                                                                                                          
                "character": 0                                                                                                                                                                                      
            }                                                                                                                                                                                                       
        }                                                                                                                                                                                                           
    }                                                                                                                                                                                                               
]
@zachliu
Copy link

zachliu commented Feb 19, 2020

What version (commit hash) of coc-python are you using?

  • When I tried the latest one (Feb 19th, commit 0bbda6e), the jumping to/from modules inside of the project doesn't work. I got the same error Definition provider not found for current document
  • I had to switch to an earlier version (Jan 15th, commit 3e03f98)
  • I haven't tried other commits in between

@Dissonant-Tech
Copy link
Author

@zachliu Just tried with both tags 1.2.9 and 1.2.7 (Jan 15th build) and both still have the same issue.
Also I tried with Jedi and it works fine.

@zachliu
Copy link

zachliu commented Feb 24, 2020

right, forgot to mention i'm using jedi, but jedi+1.2.9 doesn't work on my computer 😂

@emarbo
Copy link

emarbo commented Feb 27, 2020

Hi everyone, I've experienced the same issue here.

After a few hours checking the configuration and trying several things, I've found:

  • VSCode has the same problem (reproducible). Navigation is broken once you get inside the site-packages
  • There's an open issue in the MPLS pointing the problem is in the extension
  • There's an open issue in the VSCode Python extension.

According to the last issue, the files outside the workspace are not sent to the MPLS after the Multi-root workspace support was added. See the description for a good and detailed explanation 🚀. It's likely the same issue is affecting to coc-nvim and coc-python extension someway.

Today, I also experienced an issue with coc-nvim and the workspaces. It was detecting the root workspace (CocList folders) at the repository root instead of the CWD where I'd placed the .vim/coc-settings.json file. This was making everything fail. The solution was to add .vim folder to the coc.preferences.rootPatterns (never used before). Final value: "coc.preferences.rootPatterns": [".vim", ".git", ".hg", ".projections.json"]

alwc added a commit to alwc/dotfiles that referenced this issue Mar 8, 2020
@emarbo
Copy link

emarbo commented Mar 19, 2020

Hi, the issue should be fixed in the 0.5.37 version of Python Language Server 🎉 (changing parameter configuration). Here's the comment

@emarbo
Copy link

emarbo commented Mar 20, 2020

I have configured the coc-nvim to use the daily MPLS release and the new feature:

        "python.analysis.downloadChannel": "daily",
        "python.analysis.memory.keepLibraryAst": true,

After updating the coc-nvim (:CocUpdate) and the LS (automatic after restart?), the feature does not work and it is still complaining about the keepLibraryAst option:

[undefined] [W] Property python.analysis.memory.keepLibraryAst is not allowed.

I've checked out the repository and seen this option isn't listed in the package.json. I don't know if the solution is as simple as adding it to the options list and updating the languageServerVersion (package.json file), or there's something else to be done 🤔.

Anyway, I suppose coc-python only updates its languageServerVersion to the latest stable after checking that all the new options are well integrated. In this case, we must wait for (1) MPLS to include this feature in the stable version, and (2) coc-python to update the integration.

@wookayin
Copy link

wookayin commented Mar 21, 2020

@emarbo What is the version of python language server you are using? (e.g. :CocInfo, ~/.config/coc/extensions/coc-python-data/)
Did you run :CocCommand python.upgradePythonLanguageServer? With the daily channel being used, I can download languageServer.0.5.45.

@emarbo
Copy link

emarbo commented Mar 21, 2020

Hi @wookayin, I can download the same version as you, though I think the problem is in the extension.

As far as I understand, the coc-python is to Neovim as the vscode-python is to VSCode, and both extensions use the same language server: MPLS. Although we update the LS to the latest version, if the extension (coc-python or vscode-python) doesn't send the parameter to the LS it won't work.

That's what I think but I could be completely wrong. Does the feature work for you? I mean, can you use the go to declaration inside the virtualenv?

I didn't go deep into the extension code but I suppose the option must be declared in the package.json to be sent to the LS. Look at the package.json of both extensions:

@nacknime-official
Copy link

nacknime-official commented Jun 1, 2020

Hi, I have the same problem.

@GustavoKatel GustavoKatel linked a pull request Oct 22, 2020 that will close this issue
@GustavoKatel
Copy link

Hi all, I added to the package.json and it seems to be working for me using virtualenv and MPLS. Can one of u test using my pr, please? PR is here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants