neoclide / coc-python

Python extension for coc.nvim, fork of vscode-python
574 stars 51 forks source link

Delay in loading coc-python in non-project files #214

Closed rbhanot4739 closed 4 years ago

rbhanot4739 commented 4 years ago

My environment


vim version: NVIM v0.4.3
node version: v12.16.2
coc.nvim version: 0.0.78-0c973a7a47
coc.nivm directory: /Users/rbhanot/.config/nvim/plugged/coc.nvim
term: iTerm.app
platform: darwin

I have installed coc-python extension and set the python.jediEnabled: false and have followed everything exactly as mentioned in the docs, however there seems to be some issue in loading the extension. There is a delay of 1-2 before the extension actually loads, for the first 1-2 minutes after opening the python files, the features like autocompletion, go to definions etc does not work. And only after this delay things start to work.

However if I open any python project which has its own venv and everything seems to work just fine. I cannot show the delay in screen shots but here is the output of cocInfo for two different python files.

Here is a simple python file

test.py

import json
json.loads({"a":"b"})

CocInfo for above file

## Output channel: Python
Starting Microsoft Python language server.
[Info  - 4:11:56 PM] Analysis cache path: /Users/rbhanot/Library/Caches/Microsoft/Python Language Server
[Info  - 4:11:56 PM] Microsoft Python Language Server version 0.5.50.0
[Info  - 4:11:56 PM] Workspace root: /Users/rbhanot
[Info  - 4:11:56 PM] GetCurrentSearchPaths /Users/rbhanot/.pyenv/versions/3.7.3/bin/python 
[Info  - 4:11:56 PM] Interpreter search paths:
[Info  - 4:11:56 PM]     /Users/rbhanot/.pyenv/versions/3.7.3/lib/python3.7
[Info  - 4:11:56 PM]     /Users/rbhanot/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload
[Info  - 4:11:56 PM]     /Users/rbhanot/.pyenv/versions/3.7.3/lib/python3.7/site-packages
[Info  - 4:11:56 PM] User search paths:
[Info  - 4:11:56 PM]     /Users/rbhanot/.local/lib/python3.7/site-packages
##########Linting Output - flake8##########

if I list the laoded extensions using cocList extensions the coc-python extension shows as loaded.

Now here is the outpout of cocInfo for a file which is inside a python project which has its own virtul env, here extension loads correctly and everython starts to work instantly as soon as I open a file.

## Output channel: Python

Starting Microsoft Python language server.
[Info  - 4:22:58 PM] Analysis cache path: /Users/rbhanot/Library/Caches/Microsoft/Python Language Server
[Info  - 4:22:58 PM] Microsoft Python Language Server version 0.5.50.0
[Info  - 4:22:58 PM] Workspace root: /Users/rbhanot/products/projectdir
[Info  - 4:22:58 PM] GetCurrentSearchPaths /Users/rbhanot/products/projectdir/build/projectdir/venv/bin/python 
[Info  - 4:22:58 PM] Interpreter search paths:
[Info  - 4:22:58 PM]     /Users/rbhanot/products/projectdir/build/projectdir/venv/lib/python3.6
[Info  - 4:22:58 PM]     /Users/rbhanot/products/projectdir/build/projectdir/venv/lib/python3.6/lib-dynload
[Info  - 4:22:58 PM]     /export/apps/python/3.6/lib/python3.6
[Info  - 4:22:58 PM]     /Users/rbhanot/products/projectdir/build/obhc-agent/venv/lib/python3.6/site-packages
[Info  - 4:22:58 PM] User search paths:
[Info  - 4:22:58 PM]     /Users/rbhanot/products/projectdir/projectdir/src
##########Linting Output - flake8##########
[Info  - 4:22:59 PM] Initializing for /Users/rbhanot/products/projectdir/build/projectdir/venv/bin/python
[Info  - 4:22:59 PM] Analysis caching mode: None.

coc-settings.json

{
    "coc.preferences.formatOnSaveFiletypes": [
        "css",
        "markdown",
        "html",
        "yaml",
        "json",
        "python"
    ],
    "coc.source.around.firstMatch": false,
    "coc.source.buffer.firstMatch": false,
    "suggest.noselect": false,
    "suggest.snippetIndicator": "►",
    "diagnostic.errorSign": "✖",
    "diagnostic.warningSign": "⚠",
    "diagnostic.infoSign": "ℹ",
    "diagnostic.hintSign": "➤",
    "diagnostic.refreshOnInsertMode": true,
    "codeLens.enable": true,
    "signature.enable": true,
    "python.jediEnabled": false,
    "python.venvFolders": [
        "envs",
        ".pyenv",
        ".direnv",
        "products/**/build/**/venv/bin"
    ],
    "python.formatting.provider": "autopep8",
    "python.linting.flake8Enabled": true,
    "explorer.icon.enableNerdfont": true,
    "explorer.width": 40,
    "explorer.keyMappings": {
        "<right>": "expand",
        "<left>": "shrink"
    },
    "explorer.quitOnOpen": true
}

Please let me know if some more info is needed for troubleshooting this.

chemzqm commented 4 years ago

MPLS needs some time to initialize

rbhanot4739 commented 4 years ago

1-2 minutes to initilalize ? Then how come in other project it just works instantly within 1 sec ? If it takes this much time to initialize in independent python files just to load then it effectively means we can start the actual work only after 2 minutes ?

chemzqm commented 4 years ago

Yes, it's known issue of MPLS, depends on the python path it have searched