Giter Club home page Giter Club logo

coc-python's Introduction

coc-python

WARNING: it's recommended to use coc-pyright if you're using python3 or use coc-jedi if you're using jedi, the code of coc-python is too hard to maintain!

Python extension for coc.nvim, fork of vscode-python from commit 16899f6b13477786212f29eb3cb7a459b5ebf0a4.

Built with rich support for the Python language (for all actively supported versions of the language: 2.7, >=3.5), including features such as linting, IntelliSense, code navigation, code formatting, refactoring, snippets, and more!

关于 VS Code 中 python 的智障补全的解决方案,以 pytorch 为例

Install

In your vim/neovim, run command:

:CocInstall coc-python

Get start

  • To use Microsoft Python Language Server, add "python.jediEnabled": false in your settings file, coc-python would download latest stable MPLS for you.
  • Checkout :h coc-status to have statusline integration with coc.nvim, so you can get download status.
  • When jedi is not enabled, the language server will be downloaded. Make sure you have coc statusline integrated, check out :h coc-status.
  • Install a linter to get errors and warnings -- you can further customize linting rules to fit your needs.
  • Select your preferred Python interpreter/version/environment using the python.setInterpreter command.
    • Note the autoselected python interpreter could be wrong, make sure select the right one for you.
  • Install ctags for Workspace Symbols, from here, or using brew install ctags on macOS.

Useful commands

Open the Command List (use :CocCommand command in vim) and type in one of the following commands:

Command Description
python.setInterpreter Switch between Python interpreters, versions, and environments.
python.startREPL Start an interactive Python REPL using the selected interpreter in the VS Code terminal.
python.execInTerminal Runs the active Python file in the VS Code terminal.
python.setLinter Switch from PyLint to flake8 or other supported linters.
python.upgradePythonLanguageServer Upgrade MPLS to latest daily version.

To see all available Python commands, open the Command Palette and type Python.

Note: to enable multiple linters, edit the configuration file instead of use python.setLinter command.

Features

Except from test, debug and datascience features of vscode-python.

  • IDE-like features
    • Automatic indenting
    • Code navigation ("Go to", "Find all" references)
    • Code definition (Peek and hover definition, View signatures)
    • Rename refactoring
    • Sorting import statements (use the Python: Sort Imports command)
  • Intellisense and autocomplete (including PEP 484 and PEP 526 support)
    • Ability to include custom module paths (e.g. include paths for libraries like Google App Engine, etc.; use the setting python.autoComplete.extraPaths = [])
  • Code formatting
    • Auto formatting of code upon saving changes (default to 'Off')
    • Use either yapf, autopep8, or Black for code formatting (defaults to autopep8)
  • Linting
  • Snippets
  • Miscellaneous
    • Running a file or selected text in python terminal
    • Automatic activation of environments in the terminal
  • Refactoring
    • Rename refactorings
    • Extract variable refactorings
    • Extract method refactorings
    • Sort imports

Options

  • python.autoComplete.addBrackets:Automatically add brackets for functions, not work for MPLS., default: false
  • python.autoComplete.extraPaths:List of paths to libraries and the like that need to be imported by auto complete engine. E.g. when using Google App SDK, the paths are not in system path, hence need to be added into this list., default: []
  • python.autoComplete.showAdvancedMembers:Controls appearance of methods with double underscores in the completion list., default: true
  • python.autoComplete.typeshedPaths:Specifies paths to local typeshed repository clone(s) for the Python language server., default: []
  • python.autoUpdateLanguageServer:Automatically update the language server., default: true
  • python.disableInstallationCheck:Whether to check if Python is installed (also warn when using the macOS-installed Python)., default: false
  • python.envFile:Absolute path to a file containing environment variable definitions., default: "${workspaceFolder}/.env"
  • python.trace.server:Trace level of tsserver, default: "off"
  • python.formatting.autopep8Args:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.formatting.autopep8Path:Path to autopep8, you can use a custom version of autopep8 by modifying this setting to include the full path., default: "autopep8"
  • python.formatting.provider:Provider for formatting. Possible options include 'autopep8', 'black', and 'yapf'., default: "autopep8"
  • python.formatting.blackArgs:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.formatting.blackPath:Path to Black, you can use a custom version of Black by modifying this setting to include the full path., default: "black"
  • python.formatting.yapfArgs:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.formatting.yapfPath:Path to yapf, you can use a custom version of yapf by modifying this setting to include the full path., default: "yapf"
  • python.globalModuleInstallation:Whether to install Python modules globally when not using an environment., default: false
  • python.jediEnabled:Enables Jedi as IntelliSense engine instead of Microsoft Python Analysis Engine., default: true
  • python.jediMemoryLimit:Memory limit for the Jedi completion engine in megabytes. Zero (default) means 1024 MB. -1 means unlimited (disable memory limit check), default: 0
  • python.jediPath:Path to directory containing the Jedi library (this path will contain the 'Jedi' sub directory)., default: ""
  • python.analysis.diagnosticEnabled: Enable diagnostic support of language server, default: true
  • python.analysis.openFilesOnly:Only show errors and warnings for open files rather than for the entire workspace., default: true
  • python.analysis.diagnosticPublishDelay:Delay before diagnostic messages are transferred to the problems list (in milliseconds)., default: 1000
  • python.analysis.typeshedPaths:Paths to look for typeshed modules., default: []
  • python.analysis.errors:List of diagnostics messages to be shown as errors., default: []
  • python.analysis.warnings:List of diagnostics messages to be shown as warnings., default: []
  • python.analysis.information:List of diagnostics messages to be shown as information., default: []
  • python.analysis.disabled:List of suppressed diagnostic messages., default: []
  • python.analysis.logLevel:Defines type of log messages language server writes into the output window., default: "Error"
  • python.analysis.symbolsHierarchyDepthLimit:Limits depth of the symbol tree in the document outline., default: 10
  • python.linting.enabled:Whether to lint Python files., default: true
  • python.linting.flake8Args:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.linting.flake8CategorySeverity.E:Severity of Flake8 message type 'E'., default: "Error"
  • python.linting.flake8CategorySeverity.F:Severity of Flake8 message type 'F'., default: "Error"
  • python.linting.flake8CategorySeverity.W:Severity of Flake8 message type 'W'., default: "Warning"
  • python.linting.flake8Enabled:Whether to lint Python files using flake8, default: false
  • python.linting.flake8Path:Path to flake8, you can use a custom version of flake8 by modifying this setting to include the full path., default: "flake8"
  • python.linting.ignorePatterns:Patterns used to exclude files or folders from being linted., default: [".vscode/*.py","**/site-packages/**/*.py"]
  • python.linting.lintOnSave:Whether to lint Python files when saved., default: true
  • python.linting.maxNumberOfProblems:Controls the maximum number of problems produced by the server., default: 100
  • python.linting.banditArgs:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.linting.banditEnabled:Whether to lint Python files using bandit., default: false
  • python.linting.banditPath:Path to bandit, you can use a custom version of bandit by modifying this setting to include the full path., default: "bandit"
  • python.linting.mypyArgs:Arguments passed in. Each argument is a separate item in the array., default: ["--ignore-missing-imports","--follow-imports=silent","--show-column-numbers"]
  • python.linting.mypyCategorySeverity.error:Severity of Mypy message type 'Error'., default: "Error"
  • python.linting.mypyCategorySeverity.note:Severity of Mypy message type 'Note'., default: "Information"
  • python.linting.mypyEnabled:Whether to lint Python files using mypy., default: false
  • python.linting.mypyPath:Path to mypy, you can use a custom version of mypy by modifying this setting to include the full path., default: "mypy"
  • python.linting.pep8Args:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.linting.pep8CategorySeverity.E:Severity of Pep8 message type 'E'., default: "Error"
  • python.linting.pep8CategorySeverity.W:Severity of Pep8 message type 'W'., default: "Warning"
  • python.linting.pep8Enabled:Whether to lint Python files using pep8, default: false
  • python.linting.pep8Path:Path to pep8, you can use a custom version of pep8 by modifying this setting to include the full path., default: "pep8"
  • python.linting.prospectorArgs:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.linting.prospectorEnabled:Whether to lint Python files using prospector., default: false
  • python.linting.prospectorPath:Path to Prospector, you can use a custom version of prospector by modifying this setting to include the full path., default: "prospector"
  • python.linting.pydocstyleArgs:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.linting.pydocstyleEnabled:Whether to lint Python files using pydocstyle, default: false
  • python.linting.pydocstylePath:Path to pydocstyle, you can use a custom version of pydocstyle by modifying this setting to include the full path., default: "pydocstyle"
  • python.linting.pylamaArgs:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.linting.pylamaEnabled:Whether to lint Python files using pylama., default: false
  • python.linting.pylamaPath:Path to pylama, you can use a custom version of pylama by modifying this setting to include the full path., default: "pylama"
  • python.linting.pylintArgs:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.linting.pylintCategorySeverity.convention:Severity of Pylint message type 'Convention/C'., default: "Information"
  • python.linting.pylintCategorySeverity.error:Severity of Pylint message type 'Error/E'., default: "Error"
  • python.linting.pylintCategorySeverity.fatal:Severity of Pylint message type 'Fatal/F'., default: "Error"
  • python.linting.pylintCategorySeverity.refactor:Severity of Pylint message type 'Refactor/R'., default: "Hint"
  • python.linting.pylintCategorySeverity.warning:Severity of Pylint message type 'Warning/W'., default: "Warning"
  • python.linting.pylintEnabled:Whether to lint Python files using pylint., default: true
  • python.linting.pylintPath:Path to Pylint, you can use a custom version of pylint by modifying this setting to include the full path., default: "pylint"
  • python.linting.pylintUseMinimalCheckers:Whether to run Pylint with minimal set of rules., default: true
  • python.pythonPath:Path to Python, you can use a custom version of Python by modifying this setting to include the full path., default: "python"
  • python.condaPath:Path to the conda executable to use for activation (version 4.4+)., default: ""
  • python.pipenvPath:Path to the pipenv executable to use for activation., default: "pipenv"
  • python.poetryPath:Path to the poetry executable., default: "poetry"
  • python.sortImports.args:Arguments passed in. Each argument is a separate item in the array., default: []
  • python.sortImports.path:Path to isort script, default using inner version, default: ""
  • python.terminal.activateEnvironment:Activate Python Environment in Terminal created using the Extension., default: true
  • python.terminal.executeInFileDir:When executing a file in the terminal, whether to use execute in the file's directory, instead of the current open folder., default: false
  • python.terminal.launchArgs:Python launch arguments to use when executing a file in the terminal., default: []
  • python.venvFolders:Folders in your home directory to look into for virtual environments., default: ["envs",".pyenv",".direnv"]
  • python.venvPath:Path to folder with a list of Virtual Environments (e.g. ~/.pyenv, ~/Envs, ~/.virtualenvs)., default: ""
  • python.workspaceSymbols.ctagsPath:Fully qualified path to the ctags executable (else leave as ctags, assuming it is in current path)., default: "ctags"
  • python.workspaceSymbols.enabled:Set to 'false' to disable Workspace Symbol provider using ctags., default: true
  • python.workspaceSymbols.exclusionPatterns:Pattern used to exclude files and folders from ctags See http://ctags.sourceforge.net/ctags.html., default: ["**/site-packages/**"]
  • python.workspaceSymbols.rebuildOnFileSave:Whether to re-build the tags file on when changes made to python files are saved., default: true
  • python.workspaceSymbols.rebuildOnStart:Whether to re-build the tags file on start (defaults to true)., default: true
  • python.workspaceSymbols.tagFilePath:Fully qualified path to tag file (exuberant ctags file), used to provide workspace symbols., default: "${workspaceFolder}/.vscode/tags"

F.A.Q

Q: "python.linting.enabled": false not work when jedi disabled.

A: That setting only works when python files are used, not MPLS, you have to use "python.analysis.diagnosticEnabled": false to disable diagnostics from language server.

Q: MPLS using too much memory and CPU.

A: It's bug of MPLS, checkout microsoft/python-language-server#832.

Q: MPLS doesn't work with unsaved buffer.

A: Yes, it's not. You have to save your buffer to make it work.

Q: Get unable to find document error from MPLS.

A: Some filename would cause MPLS throw this error.

License

MIT

coc-python's People

Contributors

alexd2580 avatar braun-steven avatar burninglutz avatar ccoolsnake avatar chemzqm avatar hoov avatar jesperrix avatar mrparalon avatar randrej avatar theangryangel avatar voldikss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coc-python's Issues

Error output from python: Starting client failed:

Thank you for share this wonderful program :)

I moved from coc and coc-pyls.
I reinstalled coc too! but It occur error. I have no idea what's wrong. Please help!

Here is my env

  • OS: ubuntu x64 18.x.x LTS
  • Node version: 10.15.3 (installed by NVM)
  • Yarn version: 1.15.2
  • vim-plug Plug 'neoclide/coc.nvim', { 'do': 'yarn install --frozen-lockfile'}
  • output of CocList extensions:
  1 + coc-json 1.0.12 ~/.config/coc/extensions/node_modules/coc-json
  2 + coc-python 1.0.4 ~/.config/coc/extensions/node_modules/coc-python
  3 + coc-vetur 1.1.0 ~/.config/coc/extensions/node_modules/coc-vetur

And this is screen shot
coc-python 제보

Here is outpt of :CocOpenLog

705 2019-03-27T15:58:33.392 INFO (pid:15097) [extension-coc-python] - Python Extension: Interpreters returned by WorkspaceVirtualEnvService are of count 0
706 2019-03-27T15:58:33.393 INFO (pid:15097) [extension-coc-python] - Python Extension: Get language server folder name, Class name = LanguageServerFolderService, , Return Value: "languageServer.0.2.31"
707 2019-03-27T15:58:33.395 INFO (pid:15097) [extension-coc-python] - Python Extension: Cached data exists getEnvironmentVariables, /home/the1900/repo/erp_joyfulworks_api/manage.py
708 2019-03-27T15:58:33.400 INFO (pid:15097) [extension-coc-python] - Python Extension: Interpreters returned by VirtualEnvService are of count 3
709 2019-03-27T15:58:33.405 INFO (pid:15097) [extension-coc-python] - Python Extension: Interpreters returned by CurrentPathService are of count 5
710 2019-03-27T15:58:33.406 INFO (pid:15097) [extension-coc-python] - Python Extension: Cached data exists getEnvironmentVariables, <No Resource>
711 2019-03-27T15:58:33.409 ERROR (pid:15097) [extension-coc-python] - Python Extension: getActivatedEnvironmentVariables TypeError: scriptFile.fileToCommandArgument is not a function
712   ¦ at Bash.<anonymous> (/home/the1900/.config/coc/extensions/node_modules/coc-python/lib/common/terminal/environmentActivationProviders/bash.js:31:42)
713   ¦ at Generator.next (<anonymous>)
714   ¦ at fulfilled (/home/the1900/.config/coc/extensions/node_modules/tslib/tslib.js:104:62)
715 2019-03-27T15:58:33.410 INFO (pid:15097) [extension-coc-python] - Python Extension: getActivatedEnvironmentVariables, Class name = EnvironmentActivationService, Arg 1: <Uri:/home/the1900/repo/erp_joyfulworks_api/manage.py>
716 2019-03-27T15:58:33.410 INFO (pid:15097) [extension-coc-python] - Python Extension: Cached data exists getEnvironmentVariables, /home/the1900/repo/erp_joyfulworks_api/manage.py
717 2019-03-27T15:58:33.411 INFO (pid:15097) [extension-coc-python] - Python Extension: Get language server folder name, Class name = LanguageServerFolderService, , Return Value: "languageServer.0.2.31"
718 2019-03-27T15:58:33.421 ERROR (pid:15097) [server] - uncaughtException Error: spawn /home/the1900/.config/coc/extensions/coc-python-data/languageServer.0.2.31/Microsoft.Python.LanguageServer EACCES
719   ¦ at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
720   ¦ at onErrorNT (internal/child_process.js:415:16)
721   ¦ at process._tickCallback (internal/process/next_tick.js:63:19)
722 2019-03-27T15:58:33.422 ERROR (pid:15097) [server] - unhandledRejection  Promise {
723   <rejected> Error: Launching server using command /home/the1900/.config/coc/extensions/coc-python-data/languageServer.0.2.31/Microsoft.Python.LanguageServer failed.
724   ¦ ¦ at LanguageClient.createMessageTransports (/home/the1900/.local/share/nvim/plugged/coc.nvim/lib/language-client/index.js:343:23) } Error: Launching server using command /home/the1900/.config/coc/extensions/coc-python-data/lang
725   ¦ at LanguageClient.createMessageTransports (/home/the1900/.local/share/nvim/plugged/coc.nvim/lib/language-client/index.js:343:23)
726 2019-03-27T15:58:33.564 INFO (pid:15097) [extension-coc-python] - Python Extension: Interpreters returned by PipEnvService are of count 1
727 2019-03-27T15:58:33.564 INFO (pid:15097) [extension-coc-python] - Python Extension: Checking whether locactors have completed locating, Class name = InterpreterLocatorProgressService, , Return Value: false
728 2019-03-27T15:58:33.564 INFO (pid:15097) [extension-coc-python] - Python Extension: Checking whether locactors have completed locating, Class name = InterpreterLocatorProgressService, , Return Value: false
729 2019-03-27T15:58:33.564 INFO (pid:15097) [extension-coc-python] - Python Extension: Checking whether locactors have completed locating, Class name = InterpreterLocatorProgressService, , Return Value: false

linter turned off when python.jediEnabled is set to false

Putting

"python.jediEnabled": false

in coc-settings.json (to enable Intellisense, since it is disabled by default in favor of jedi) seems to disable the linter, even when

"python.linting.enabled": true,
"python.linting.pylintEnabled": true,

are in coc-settings.json as well.

A similar problem for vscode itself is reported here:

microsoft/vscode-python#3292

Do you know whether this is fixable for coc-python?

Thanks again!

Don't automatically put python.pythonPath into coc-settings.json

Hi chemzqm, first of all thank you so much for coc.nvim. It's improved my entire vim experience.

Here's my issue:

I work on a bunch of different python projects — some have their own virtual environment, some just work in the global/system Python space. One project specifically causes coc to automatically add this line into coc-settings.json:

"python.pythonPath": ".venv/bin/python3"

The problem is that venv path is not universal for all my projects, and once that line has been added to coc-settings.json, it causes my other projects with different python paths to pop up the No Python interpreter is selected prompt.

Is there a way to prevent automatically writing python.pythonPath into the config file, and just use the current python that exists in $PATH?

Improper Jedi environment initialization prevents older Jedi versions from working

Sometimes you want to use an older version of Jedi in a virtualenv with coc-python, because PyQT5 / PySide2 don't work with Jedi versions >12.1.

Here's the Jedi issue that outlines what happens: davidhalter/jedi#1287.

So, until they fix that, people who work with PyQT5 / PySide2 have to use jedi = "0.12.1".
But that doesn't work with coc-python because the code in this project (forked from the vscode plugin) initializes the jedi environment the wrong way:

    def __init__(self):
        self.default_sys_path = sys.path
        self.environment = jedi.api.environment.Environment(sys.executable)

which is clearly against the recommendation in the Jedi project

class Environment(_BaseEnvironment):
    """
    This class is supposed to be created by internal Jedi architecture. You
    should not create it directly. Please use create_environment or the other
    functions instead. It is then returned by that function.
    """

This, coupled with an API change in Jedi, renders coc-python unable to interface with the legacy Jedi version, since jedi.api.environment.Environment constructor's arguments have changed in the meantime.

But, if we use the recommended way of creating the environment, jedi.api.environment.Environment, the issue goes away and coc-python works properly with both jedi = "0.12.1" and jedi = "0.13.3" (latest).

This is the change:

    def __init__(self):
        self.default_sys_path = sys.path
        self.environment = jedi.api.environment.create_environment(
            sys.executable, safe=False
        )

I'll put up a pull request with this fix right away.

Neomake error

:NeomakeInfo show me this error.
[coc.nvim] error: Uncaught exception: TypeError: Cannot read property 'remove' of undefined
at Object.dispose (/home/perilla/.config/coc/extensions/node_modules/vscode-jsonrpc/lib/events.js:99:41)
at disposables.forEach.disposable (/home/perilla/.config/coc/extensions/node_modules/coc-python/lib/common/process/proc.js:131:58)
at Array.forEach ()
at ChildProcess.proc.once (/home/perilla/.config/coc/extensions/node_modules/coc-python/lib/common/process/proc.js:131:25)
at Object.onceWrapper (events.js:273:13)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:962:16)
at Socket.stream.socket.on (internal/child_process.js:381:11)
at Socket.emit (events.js:182:13)
at Pipe._handle.close (net.js:606:12)

This error seems to be related with virtualtext option, because when I have errors on my
python file, I have virtualtext for each error when cursor is over the error, but when I fix
my error, virtualtext is not removed.

Console session recorded:
https://asciinema.org/a/PKcu5yDTSBkheCtBN2SM81ntE

coc-python hangs / high mem usage

Hello,

It seems to hang here:

versions

vim version: NVIM v0.4.0-dev
node version: v11.12.0
coc.nvim version: 0.0.62
term: undefined
platform: darwin

Error messages

Output channel: Python

~ │Starting Microsoft Python language serve
~ │r.
~ │[Info - 8:35:22 PM] GetCurrentSearchPat
~ │hs /usr/local/opt/python/bin/python3.6
~ │[Info - 8:35:22 PM] Python search paths
~ │:
~ │[Info - 8:35:22 PM] /private/var/fo
~ │lders/pm/6bbp0sh94_nc9qtfh6n5yp180000gq/
~ │T/aeswundx.4ek
~ │[Info - 8:35:22 PM] /usr/local/Cell
~ │ar/python/3.6.5/Frameworks/Python.framew
~ │ork/Versions/3.6/lib/python3.6
~ │[Info - 8:35:22 PM] /usr/local/Cell
~ │ar/python/3.6.5/Frameworks/Python.framew
~ │ork/Versions/3.6/lib/python3.6/lib-dynlo
~ │ad
~ │[Info - 8:35:22 PM] /usr/local/lib/
~ │python3.6/site-packages
~ │[Info - 8:35:22 PM] Configuration searc
~ │h paths:
~ │

It takes a few minutes to find the Configuration search paths, but often it crashes or the pc hangs before it does so. Is there a way to specify this manually or something? I can see the Python Language Server running in the background with like 50MB, and once it found the search paths it goes up to like 2GB.

Thanks!

Way to disable MLPS linter, python.analysis?

When MLPS is turned on (jedi enabled = False) and the linters are off, it still seems to 'lint' through the python.analysis thing of MLPS (I think it is). Please see below (the messages of the 'linter' overlap with the code below). Is there a way to turn that off?

Screen Shot 2019-03-28 at 10 54 27 AM

I tried the following in coc-settings but it doesn't seem to help:

"python.jediEnabled": false,
"python.analysis.logLevel": "Fatal",
"python.analysis.errors": ["undefined-variable"],
"python.analysis.errors": ["undefined-variable"],
"python.analysis.information": ["undefined-variable"],
"python.linting.enabled": false,

Selecting flake8 each time and Python2

I have no pylint installed - just flake8.
Each time I open .py file I get a question:

Linter pylint is not installed.:
1. Install
2. Select linter
3. Do not show again

I select 2. and then I check flake8.
It looks like it never works and the choice is not saved.
I added in my ~/.config/nvim/coc-settings.json:

{
  "python.setInterpreter": "python2",
  "python.setLinter": "flake8"
}

And still it does not help. Python version is also choosen inproper (Python3 instead of Python2)

And moreover, how to always show the linter results?

[solved] can not make coc-python auto-completion work with Jedi

Update: it seems that the problem is due to that Jedi package is not in the latest version, although I don not understand why.

problem description

I tried to install coc.nvim and coc-python extension on two machines: Mac and Linux. On Mac, it works as expected after install. But on Linux, I can not make the completion work.

My environment

  • Mac: mac os mojave
  • Linux: CentOS 7.4
  • Neovim: 0.4.0
  • Python: Python 3.5+ (bundled with Anaconda)
  • Jedi

steps I have tried

Here is what I do

  1. Install Nodejs (I have installed a binary version of nodejs since I do not have root rights) and set its path correctly.

  2. Install yarn via the script provided in the coc.nvim readme. I can call yarn on the command line

  3. Install coc.nvim via vim-plug

  4. Install coc-python via the command :CocInstall coc-python. (It seems that coc-python supports both Jedi and MPLS and Jedi is used by default. I have already installed Jedi.)

On my Mac, this is all I do to make the auto-completion work for Python file.
But on Linux, it does not work.

Steps further tried on Linux

I run the :checkhealth command inside neovim and found some error related to coc.nvim and nodejs. For coc.nvim, it shows that :pyx does not work. All it prompted me to use :call coc#util#build() command. For nodejs, the warning is that neovim is not installed.

I add set pyxversion=3 to my config and run the command :call coc#util#build() and the build is successful.

I also installed neovim module via

yarn global add neovim

After all these steps, :checkhealth shows no errors or warnings related to coc.nvim

health#coc#check
========================================================================
  - OK: Environment check passed

  - OK: Build javascript found
  - OK: Service started

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~

health#provider#check
========================================================================
## Clipboard (optional)
  - WARNING: No clipboard tool found. Clipboard registers (`"+` and `"*`) will not work.
    - ADVICE:
      - :help clipboard

## Python 2 provider (optional)
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - ERROR: Python provider error:
    - ADVICE:
      - provider/pythonx: Could not load Python 2:
          /bin/python2 does not have the "neovim" module. :help provider-python
          /bin/python2.7 does not have the "neovim" module. :help provider-python
          python2.6 not found in search path or not executable.
          /home/haojiedong/tools/anaconda3/bin/python is Python 3.6 and cannot provide Python 2.
  - INFO: Executable: Not found

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Executable: /home/haojiedong/tools/anaconda3/bin/python3
  - INFO: Python version: 3.6.5
  - INFO: pynvim version: 0.3.2
  - OK: Latest pynvim is installed.

## Ruby provider (optional)
  - WARNING: `ruby` and `gem` must be in $PATH.
    - ADVICE:
      - Install Ruby and verify that `ruby` and `gem` commands work.

## Node.js provider (optional)
  - INFO: Node.js: v10.15.3
  - INFO: Neovim node.js host: /home/haojiedong/.config/yarn/global//node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn package is installed: 4.5.0

After that, I open a python file and auto-completion still does not work for packages and modules. Any idea, what should I try next?

what works

It should be noted that completion for words inside the buffer works:

image

But auto-completion for packages does not work:

image

I also tried to see if auto-completion for viml works by installing the following plugin:

Plug 'Shougo/neco-vim'
Plug 'neoclide/coc-neco'

Auto-completion does work for vim script as shown below

image

So it seems that coc.nvim works. The issue may be in coc-python. Currently, I only add the following config to my coc-settings.json file:

{
"suggest.timeout": 5000
}

( On my Mac, I can use python auto-completion without setting anything inside this file. )

I have also tried to remove coc.nvim and re-install from scratch. But it does not solve the problem either.

My minimal non-working config

Here is my minimal non-working config:

call plug#begin(expand('~/.local/share/nvim/plugged'))
Plug 'neoclide/coc.nvim', {'do': './install.sh'}
Plug 'Shougo/neco-vim'
Plug 'neoclide/coc-neco'
call plug#end()

set pyxversion=3

Follow up

After all these step, I tried to update jedi:

conda update jedi

Now the auto-completion finally works! Maybe it is caused by Jedi? But if I use deoplete and deoplete-jedi for auto-completion, there is no such issue.

I not sure why updating to latest Jedi solves this issue. Does coc-python depends on some specific features from the latest version of Jedi? Maybe there should be a warning message about the Jedi is not in the latest version when using :checkhealth.

Not using the python in PATH

My coc-settings.json has no python settings at all (i.e. it's a blank slate), and my virtualenv is activated (in other words $VIRTUAL_ENV has a value).

Despite this, it's showing every sign of not properly identifying the virtualenv python path:

  • Throwing "unresolved-import" warnings on packages that are definitely installed in the virtualenv
  • Unable to auto-complete on packages that are definitely installed

As an example, from within the python shell I can run from django.db import models, but then immediately opening neovim, with a file that contains that line, throws an "unresolved-import".

Here's a quick GIF showing the issue:

coc-problems

Out of the range or missing libcuda.so.1

It broken when open file.

## versions

vim version: NVIM v0.4.0-420-g29d6993cc
node version: v11.12.0
coc.nvim version: 0.0.62
term: screen-256color
platform: linux

## Error messages
UnhandledRejection: Specified argument was out of the range of valid values.
Error: Specified argument was out of the range of valid values.
    at handleResponse (/home/lijie/.vim/plugged/coc.nvim/node_modules/vscode-jsonrpc/lib/main.js:436:48)
    at processMessageQueue (/home/lijie/.vim/plugged/coc.nvim/node_modules/vscode-jsonrpc/lib/main.js:263:17)
    at Immediate.setImmediate (/home/lijie/.vim/plugged/coc.nvim/node_modules/vscode-jsonrpc/lib/main.js:247:13)
    at processImmediate (timers.js:638:19)
## Output channel: snippets

## Output channel: Python
Starting Microsoft Python language server.
[Info  - 11:04:00 PM] GetCurrentSearchPaths /home/lijie/.pyenv/shims/python 
[Info  - 11:04:00 PM] Python search paths:
[Info  - 11:04:00 PM]     /home/lijie/.pyenv/versions/3.7.1/lib/python3.7
[Info  - 11:04:00 PM]     /home/lijie/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload
[Info  - 11:04:00 PM]     /home/lijie/.pyenv/versions/3.7.1/lib/python3.7/site-packages
[Info  - 11:04:00 PM] Configuration search paths:
[Error  - 11:04:00 PM] Server initialization failed.
  Message: Specified argument was out of the range of valid values.
  Code: -32000 
   at System.ReadOnlySpan`1..ctor(Void* pointer, Int32 length)
   at Interop.Sys.DirectoryEntry.GetName(Span`1 buffer)
   at System.IO.Enumeration.FileSystemEntry.get_FileName()
   at System.IO.Enumeration.FileSystemEnumerableFactory.<>c__DisplayClass3_0.<UserFiles>b__1(FileSystemEntry& entry)
   at System.IO.Enumeration.FileSystemEnumerable`1.DelegateEnumerator.ShouldIncludeEntry(FileSystemEntry& entry)
   at System.IO.Enumeration.FileSystemEnumerator`1.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Microsoft.Python.Core.IO.PathUtils.EnumerateFiles(String root, String pattern, Boolean recurse, Boolean fullPaths)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at Microsoft.Python.Analysis.Modules.Resolution.ModuleResolutionBase.ReloadModulePaths(IEnumerable`1& rootPaths)
   at Microsoft.Python.Analysis.Modules.Resolution.MainModuleResolution.ReloadAsync(CancellationToken cancellationToken)
   at Microsoft.Python.Analysis.Modules.Resolution.MainModuleResolution.InitializeAsync(CancellationToken cancellationToken)
   at Microsoft.Python.Analysis.Analyzer.PythonInterpreter.LoadBuiltinTypesAsync(String root, IServiceManager sm, CancellationToken cancellationToken)
   at Microsoft.Python.Analysis.Analyzer.PythonInterpreter.CreateAsync(InterpreterConfiguration configuration, String root, IServiceManager sm, CancellationToken cancellationToken)
   at Microsoft.Python.LanguageServer.Implementation.Server.InitializeAsync(InitializeParams params, CancellationToken cancellationToken)
   at Microsoft.Python.LanguageServer.Implementation.LanguageServer.Initialize(JToken token, CancellationToken cancellationToken)

I try another project, the error differs. I install pytorch along with tensorflow-cpu, and no nvidia card is on my PC.

## versions

vim version: NVIM v0.4.0-420-g29d6993cc
node version: v11.12.0
coc.nvim version: 0.0.62
term: screen-256color
platform: linux

## Error messages

## Output channel: snippets

## Output channel: Python
Starting Microsoft Python language server.
[Info  - 11:02:27 PM] GetCurrentSearchPaths /home/lijie/.pyenv/versions/3.7.1/bin/python 
[Info  - 11:02:27 PM] Python search paths:
[Info  - 11:02:27 PM]     /home/lijie/.pyenv/versions/3.7.1/lib/python3.7
[Info  - 11:02:27 PM]     /home/lijie/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload
[Info  - 11:02:27 PM]     /home/lijie/.pyenv/versions/3.7.1/lib/python3.7/site-packages
[Info  - 11:02:27 PM] Configuration search paths:
[Info  - 11:02:27 PM] Microsoft Python Language Server version 0.2.31.0
[Info  - 11:02:27 PM] Initializing for /home/lijie/.pyenv/versions/3.7.1/bin/python
Traceback (most recent call last):
  File "/home/lijie/.config/coc/extensions/coc-python-data/languageServer.0.2.31/scrape_module.py", line 1489, in <module>
    state.initial_import(sys.argv[2])
  File "/home/lijie/.config/coc/extensions/coc-python-data/languageServer.0.2.31/scrape_module.py", line 872, in initial_import
    mod = __import__(self.module_name)
ImportError: libcuda.so.1: cannot open shared object file: No such file or directory
[Info  - 11:03:17 PM] GetCurrentSearchPaths /home/lijie/.pyenv/shims/python 
[Info  - 11:03:17 PM] Python search paths:
[Info  - 11:03:17 PM]     /home/lijie/.pyenv/versions/3.7.1/lib/python3.7
[Info  - 11:03:17 PM]     /home/lijie/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload
[Info  - 11:03:17 PM]     /home/lijie/.pyenv/versions/3.7.1/lib/python3.7/site-packages
[Info  - 11:03:17 PM] Configuration search paths:
[Info  - 11:03:18 PM] Microsoft Python Language Server version 0.2.31.0
[Info  - 11:03:18 PM] Initializing for /home/lijie/.pyenv/shims/python
Traceback (most recent call last):
  File "/home/lijie/.config/coc/extensions/coc-python-data/languageServer.0.2.31/scrape_module.py", line 1489, in <module>
    state.initial_import(sys.argv[2])
  File "/home/lijie/.config/coc/extensions/coc-python-data/languageServer.0.2.31/scrape_module.py", line 872, in initial_import
    mod = __import__(self.module_name)
ImportError: libcuda.so.1: cannot open shared object file: No such file or directory

Thx

Error on write

If a save a python file (unfortunately cannot share) two times in a row with :w I get the error in screenshot:
2019-05-29-115136_1920x1080_scrot

If you really need it I can try reproducing the issue in a public file.

Initial reactions to using extension

I now have this extension installed and running.

These comments are not directed to the coc-python extension but rather the Microsoft Python Language Server which provides the functionality behind it.

It seems the Microsoft Python LanguageServer does not do asynchronous linting -- only on file save or if manually invoked.

Based on comments in the issues section of the Microsoft Python LanguageServer github repo, the latest version takes a long long time and lots of memory to do its initial source scan. While it is doing this, it is not availble for code completion. This seems to be new behavior -- there are a lot of complaints. On my system, for a small (150 lines) Python program which uses pandas and matplotlib, it takes about 2 minutes to become usable. When it does become ready code completion is quite good.

So, currently, I am running this extension with linting diabled so I am only using code completion.

I am using ALE for linting.

Bottom line...this extension seems to be working OK but the underlying language server has some issues.

Unresolved import

Hello. I got a problem when having the following CocConfig:

{
    "suggest.enablePreview": true,
    "python.jediEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.linting.pylintEnabled": false,
    "suggest.timeout": 5000
}

I got en error that I have an unresolved import. I think this may be a problem with MLPS? But in VS code I don't get this error:
Screenshot 2019-04-02 at 16 19 01
This also makes so I don't get suggestions for gym_minigrid. Enabling Jedi get rid of the error but the suggestions still won't work. Any suggestions?

Fixer

Coc-python is a really tool to lint but is there a way to use it as a fixer ?

[file].py.[hash].py temporary files confuse pytest

There are some cases where files with the name scheme [file].py.[hash].py are left on the disk in my project directory. Looks like temporary files that are not cleaned up in all cases.

This makes e.g. my pytest unit tests fail with an error like this:

ImportError: No module named py.b4589e12220d89ad8ac6d192d7ad9a25

I think the files should use another naming scheme which does not confuse common workflows. I guess that making them not end with ".py" would be a good start.

Opening files renders errors

When opening files from Nerdtree, it gives these kind of errors in CocOpenLog, not sure whether it has to do with tabs/buffers and whether these need to be refreshed? When I open a file with :ex, I dont get these errors.

[Error - 9:35:39 PM] Unable to find document file:///Users/admin/Dropbox/FinalCrawUbu/website/github/progSpyder/00000000_stface_rec.py
[Error - 9:35:40 PM] Unable to find document file:///Users/admin/Dropbox/FinalCrawUbu/website/github/progSpyder/00000000_stface_rec.py
[Error - 9:37:21 PM] Request textDocument/completion failed.
Message: name
Code: -32000
at Microsoft.Python.Analysis.Values.VariableCollection.DeclareVariable(String name, IMember value, VariableSource source, LocationInfo location)
at Microsoft.Python.Analysis.Analyzer.Evaluation.ExpressionEval.DeclareVariable(String name, IMember value, VariableSource source, LocationInfo location, Boolean overwrite)
at Microsoft.Python.Analysis.Analyzer.Handlers.ImportHandler.HandleImport(ModuleName moduleImportExpression, NameExpression asNameExpression, Boolean forceAbsolute)
at Microsoft.Python.Analysis.Analyzer.Handlers.ImportHandler.HandleImport(ImportStatement node)
at Microsoft.Python.Parsing.Ast.ImportStatement.Walk(PythonWalker walker)
at Microsoft.Python.Parsing.Ast.SuiteStatement.Walk(PythonWalker walker)
at Microsoft.Python.Parsing.Ast.PythonAst.Walk(PythonWalker walker)
at Microsoft.Python.Analysis.Analyzer.PythonAnalyzer.AnalyzeEntry(PythonAnalyzerEntry entry, IPythonModule module, PythonAst ast, Int32 version, CancellationToken cancellationToken)
at Microsoft.Python.Analysis.Analyzer.PythonAnalyzer.Analyze(IDependencyChainNode1 node, IDependencyChainWalker2 walker, Stopwatch stopWatch, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Python.Analysis.Analyzer.PythonAnalyzerEntry.<>c.b__23_0(Task1 t) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Python.Analysis.Analyzer.PythonAnalyzer.GetAnalysisAsync(PythonAnalyzerEntry entry, CancellationToken timeoutCt, CancellationToken cancellationToken)
at Microsoft.Python.Analysis.Analyzer.PythonAnalyzer.GetAnalysisAsync(IPythonModule module, Int32 waitTime, CancellationToken cancellationToken)
at Microsoft.Python.LanguageServer.Implementation.Server.Completion(CompletionParams params, CancellationToken cancellationToken)
at Microsoft.Python.LanguageServer.Implementation.LanguageServer.Completion(JToken token, CancellationToken cancellationToken)
[Error - 9:37:49 PM] Unable to find document file:///Users/admin/Dropbox/FinalCrawUbu/website/github/progSpyder/00000000_stface_rec.py

Function signature snippet not working

In the deprecated python extension coc-pyls, autocompletion of a function resulted in a snippet where it was possible to jump between the prefilled function arguments. I have not been able to reproduce this behavior, nor with jedi neither with MLPS. Is there any further configuration needed or will this not be supported by this extension?

Should MPLS update automatically?

python.autoUpdateLanguageServer is set to true by default in the extension. However, it won't update automatically. I have been removing the language server download at ~/.config/coc/extensions/coc-python-data/languageServer.x.x.xx manually for whatever version is installed and the current version will then download.

Error when writing buffer to disk

When saving a buffer to disk, it throws the following error in CocInfo. It only seems to happen with python files. Latest cog-python is installed. Any clue?

## versions

vim version: NVIM v0.4.0-dev
node version: v10.15.3
coc.nvim version: 0.0.67
term: iTerm.app
platform: darwin

## Error messagesUncaught exception: TypeError: Cannot read property 'remove' of undefined
    at Object.dispose (/Users/me/.config/coc/extensions/node_modules/vscode-jsonrpc/lib/events.js:99:41)
    at disposables.forEach.disposable (/Users/me/.config/coc/extensions/node_modules/coc-python/lib/common/process/proc.js:131:58)
    at Array.forEach (<anonymous>)
    at ChildProcess.proc.once (/Users/me/.config/coc/extensions/node_modules/coc-python/lib/common/process/proc.js:131:25)
    at Object.onceWrapper (events.js:277:13)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

## Output channel: Python
Starting Jedi Python language engine.
##########Linting Output - pylint##########
************* Module capacity_main
408,0,refactor,too-many-branches:Too many branches (23/12)
408,0,refactor,too-many-statements:Too many statements (125/50)

------------------------------------------------------------------
Your code has been rated at 9.93/10 (previous run: 9.93/10, +0.00)

Minimal Init.vim

set shell=bash

filetype off

call plug#begin('~/.local/share/nvim/plugged')

Plug 'neoclide/coc.nvim', {'tag': '*', 'do': { -> coc#util#install()}}

call plug#end()

" We have to turn this stuff back on if we want all of our features.
filetype plugin indent on " Filetype auto-detection
syntax on " Syntax highlighting

let g:python3_host_prog = expand('~/anaconda3/bin/python')
" let g:loaded_python_provider = 1 " disable python2 support
let g:python_host_prog = expand('~/anaconda3/envs/staffing/bin/python')

check health from Neovim

health#coc#check
========================================================================
  - OK: Environment check passed

  - OK: Build javascript found
  - OK: Service started

Formatting problems

Hi,

I am not able to use formatting (with black) with this extension. I'm getting Error on 'format': undefined errors when using :call CocAction('format') or :call CocAction('format', @%).

Can you provide documentation how to format the whole buffer using this extension?

Thanks

Master fails to compile

> yarn install --frozen-lockfile                                                                                                                                                                                 
yarn install v1.16.0
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] Validating package.json...
warning [email protected]: The engine "coc" appears to be invalid.
[2/5] Resolving packages...
warning @types/[email protected]: This is a stub types definition. del provides its own type definitions, so you do not need this installed.
warning webpack > micromatch > snapdragon > base > [email protected]: Critical bug fixed in v2.0.1, please upgrade to the latest version.
warning webpack > micromatch > snapdragon > base > cache-base > [email protected]: Critical bug fixed in v3.0.1, please upgrade to the latest version.
warning webpack > micromatch > snapdragon > base > cache-base > union-value > [email protected]: Critical bug fixed in v3.0.1, please upgrade to the latest version.
[3/5] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
[5/5] Building fresh packages...

$ npx npm-run-all clean build
npx: installed 58 in 1.471s
yarn run v1.16.0
warning [email protected]: The engine "coc" appears to be invalid.
$ rimraf lib
Done in 0.17s.
yarn run v1.16.0
warning [email protected]: The engine "coc" appears to be invalid.
$ webpack
Hash: b9e4006829e8b55c7f1b
Version: webpack 4.35.0
Time: 13238ms
Built at: 06/23/2019 12:58:03 PM
   Asset      Size  Chunks             Chunk Names
index.js  12.2 MiB       0  [emitted]  main
Entrypoint main = index.js
  [0] ./src/index.ts 11.8 KiB {0} [built]
  [2] external "coc.nvim" 42 bytes {0} [built]
 [73] ./src/activation/serviceRegistry.ts 5.1 KiB {0} [built]
 [75] ./src/common/types.ts 3.53 KiB {0} [built]
 [77] ./src/activation/types.ts 2.12 KiB {0} [built]
 [78] ./src/common/application/types.ts 519 bytes {0} [built]
 [83] ./src/application/types.ts 242 bytes {0} [built]
 [84] ./src/common/constants.ts 4.77 KiB {0} [built]
 [90] ./src/interpreter/contracts.ts 2 KiB {0} [built]
 [95] ./src/ioc/types.ts 315 bytes {0} [built]
[150] ./src/common/utils/async.ts 2.44 KiB {0} [built]
[165] ./src/common/utils/stopWatch.ts 412 bytes {0} [built]
[629] ./src/api.ts 662 bytes {0} [built]
[630] ./src/application/serviceRegistry.ts 623 bytes {0} [built]
[647] ./src/common/dotnet/serviceRegistry.ts 1.48 KiB {0} [built]
    + 847 hidden modules

ERROR in /home/kmoschcau/.local/share/nvim/plugged/coc-python/src/interpreter/locators/helpers.ts
./src/interpreter/locators/helpers.ts
[tsl] ERROR in /home/kmoschcau/.local/share/nvim/plugged/coc-python/src/interpreter/locators/helpers.ts(56,15)
      TS2322: Type 'string | boolean | Version | Architecture' is not assignable to type 'never'.
  Type 'string' is not assignable to type 'never'.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "build" exited with 2.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

MPLS doesn't load .env correctly when another workspaceFolder exists

If no other workspace folders exist when a Python file is opened, MPLS
correctly loads the .env file. However if any other workspace folder exists,
MPLS fails to load the .env file. The current directory is still added to
CocList folders and the correct directory is watched by watchman.

To replicate this issue enable MPLS instead of Jedi and add a .env file with
something like PYTHONPATH=test/ in the appropriate location in the python
project. Open a file in the python project without any other workspaces open.
CocInfo should have a Configuration search paths: section under the python
output channel with the correct path. In a new instance of vim/nvim open some
other workspace and then open a python file. While everything else will work
correctly, the Configuration search paths: section will be empty and the
language server won't search the additional paths.

coc-python has error on startup

I just did an update of coc.nvim and and a CocInstall of coc-python.

I am running vim 8.1

When I open a python file I get the following error:

2019-03-26T19:39:33.101 INFO (pid:12031) [plugin] - coc initialized with node: v8.9.0
2019-03-26T19:41:43.539 INFO (pid:12143) [services] - registed service "languageserver.ccls"
2019-03-26T19:41:43.625 ERROR (pid:12143) [util-factoroy] - TypeError: Reflect.hasOwnMetadata is not a function
at /home/dpriedel/.config/coc/extensions/node_modules/inversify/lib/annotation/injectable.js:7:21
at Object.__decorate (/home/dpriedel/.config/coc/extensions/node_modules/tslib/tslib.js:90:99)
at Object. (/home/dpriedel/.config/coc/extensions/node_modules/coc-python/lib/common/utils/random.js:25:18)
at Module._compile (/snapshot/coc.nvim/lib/util/factory.js:67:32)
at Object.Module._extensions..js (module.js:644:10)
at Module.load (module.js:552:32)
at tryModuleLoad (module.js:495:12)
at Function.Module._load (module.js:487:3)
at Module.require (module.js:577:17)
at Module.require (pkg/prelude/bootstrap.js:1159:31)
2019-03-26T19:41:43.652 INFO (pid:12143) [plugin] - coc initialized with node: v8.9.0

Thanks

How to use the refactoring features?

I have this mapping in my init.vim:

" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>a  <Plug>(coc-codeaction-selected)

But when I select some lines and press <leader>a, the only code action available is Sort imports, there are no extract variables and extract method code actions:
image

I can use the refactoring features fine in vscode.

python.autoComplete.extraPaths: Inconsistent path expansion

Different paths like python.linting.pylintPath are supporting tilde (home path) expansion internally, but the paths given in python.autoComplete.extraPaths are not expanded. Haven't tested, but python.autoComplete.typeshedPaths may also be affected by this.

In the moment I use something like this I in the coc-settings.json the path is not used correctly:

"python.autoComplete.extraPaths": ["~/git/test"],

This works as expected:

"python.autoComplete.extraPaths": ["/home/lm/git/test"],

Using ${workspaceFolder} also works as expected

"python.autoComplete.extraPaths": ["${workspaceFolder}/test"],

autocomplete with underscore doesn't work

It seems that using the _ character renders autocomplete options invalid. For instance, see below (using MPLS, might be on jedi too).

These are the options:

Screen Shot 2019-04-02 at 12 26 29 PM

Now with the _ it doesnt show the options anymore:

Screen Shot 2019-04-02 at 12 26 56 PM

Is there a reason for this / can this be fixed? Would be great!

Skipping the _ does show the options, some of them, through fuzzy matching:

Screen Shot 2019-04-02 at 12 26 49 PM

Interpreter keep switching to global one

I'm using this minimal vimrc

set runtimepath+=~/.vim
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'do': 'yarn install'}
Plug 'honza/vim-snippets'
call plug#end()
let g:coc_snippet_next = '<TAB>'
let g:coc_snippet_prev = '<S-TAB>'
 let g:coc_global_extensions =['coc-snippets','coc-json']
inoremap <silent><expr> <TAB>
      \ pumvisible() ? "\<C-n>" :
      \ <SID>check_back_space() ? "\<TAB>" :
      \ coc#refresh()
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"

Starting it inside a virtualenv called "buxbot" and vi -u mini.vim
Running :CocCommand -> Select Interpreter

Select pythonPath, current: /usr/local/opt/python/bin/python3.7:
1. /usr/bin/python
2. /usr/local/bin/python
3. /usr/local/opt/python@2/bin/python2.7
4. /Users/user/.virtualenvs/buxbot/bin/python
5. /usr/local/bin/python3

After choosing 4 and run CocCommand again,

Select pythonPath, current: /usr/local/opt/python/bin/python3.7:

Also I think it should choose the current python (which is the virtualenv) by default.

I'm using NVIM v0.3.4 on MacOS

Timeout

While trying to use completion:
[coc.nvim] source python timeout after 5000ms

Also cpu usage is 100%
Снимок экрана 2019-04-11 в 15 26 21

My coc-settings.json:

{
	"diagnostic.errorSign": " ",
	"diagnostic.warningSign": " ",
	"diagnostic.infoSign": " ",
	"diagnostic.hintSign": "",
	"suggest.timeout": 5000,
	"python.jediEnabled": false,
	"python.linting.flake8Path": "/usr/local/bin/flake8",
	"python.linting.flake8Enabled": true,
	"python.autoComplete.addBrackets": true,
	"python.linting.enabled": true,
	"languageserver": {
		"bash": {
		      "command": "bash-language-server",
		      "args": ["start"],
		      "filetypes": ["sh"],
		      "ignoredRootPaths": ["~"]
		},
	},
}

I'm using master:
Plug 'neoclide/coc.nvim', { 'do': 'yarn install --frozen-lockfile'}

ENOENT error Unhandle Rejection

Hello,

Fantastic that you made this! Just ran the CoC Install, and got this error, do you know how to fix this?Thanks!

extension coc-python installed!
[coc.nvim] Error loading extension from /Users/admin/.config/coc/extensions/node_modules/coc-python/lib/index.js: (intermediate value).disable(...).ignoreErrors is not a function
[vim-node-coc]: UnhandledRejection: ENOENT: no such file or directory, rename '/Users/admin/.config/coc/extensions/node_modules/coc-python/out/client/debugger/debugAdapter/main.js.map' -> '/Users/admin/.c
onfig/coc/extensions/node_modules/coc-python/out/client/debugger/debugAdapter/main.js.map.disabled'
Error: ENOENT: no such file or directory, rename '/Users/admin/.config/coc/extensions/node_modules/coc-python/out/client/debugger/debugAdapter/main.js.map' -> '/Users/admin/.config/coc/extensions/node_mod
ules/coc-python/out/client/debugger/debugAdapter/main.js.map.disabled'
[coc.nvim] Extension coc-python not found!
[coc.nvim] Extension coc-python not found!
extension coc-python installed!
[coc.nvim] Error loading extension from /Users/admin/.config/coc/extensions/node_modules/coc-python/lib/index.js: (intermediate value).disable(...).ignoreErrors is not a function
[vim-node-coc]: UnhandledRejection: ENOENT: no such file or directory, rename '/Users/admin/.config/coc/extensions/node_modules/coc-python/lib/index.js.map' -> '/Users/admin/.config/coc/extensions/node_mo
dules/coc-python/lib/index.js.map.disabled'
Error: ENOENT: no such file or directory, rename '/Users/admin/.config/coc/extensions/node_modules/coc-python/lib/index.js.map' -> '/Users/admin/.config/coc/extensions/node_modules/coc-python/lib/index.js
.map.disabled'

virtualenv problem

1.So, I create virtualenv, select it in coccomand menu. But it doesn't see the virtualenv, intellisense and go to definition do not work.
2. But if I create virtualenv with --system-site-packages and choose it in coccomandmenu, then everything works.
After a little bit of searching I found that coc-python uses jedi, which I need to pip install in each virtualenv. Or use --system-site-packages flag. Does someone know more elegant way of dealing with it?
Microsoft python language server does not work, btw

Linter messages not always visible

After starting neovim with current version of coc+coc-python I always get the correct information from the linter, can cycle through the messages with coc-diagnostic-next and get the detail message in the popup next to the cursor.

From time to time the popup does not work anymore and I have no chance to see the detail message of the linter. The icons on the side of the lines are correctly created. And the messages are visible with ":CocCommand python.viewOutput".

a) Would love to have this working without issues.
b) In case it is not easy fixable, would it be possible to show the message in the command-line?

Is there anything needed I can send you to help?

linter not disabled?

I tried to disable the lint function but it doesn't seem to respect the coc-settings.json? it looks as follows

{
"coc.preferences.timeout": 5000,
"python.jediEnabled": false,
"python.linting.enabled"; false,
}

But still seems to lint:

Screen Shot 2019-03-27 at 3 57 58 PM

Thanks again!

RuntimeError: location not created nor specified'. Make sure pipenv is on the PATH.

你好,我只是简单的打开了一个脚本,当前目录下也没有pipfile这个文件,但是messages里面报这个错误。

[coc.nvim] Workspace contains pipfile but attempt to run 'pipenv --venv' failed with 'Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>                                                                                                                                                     
    sys.exit(cli())
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 105, in augment_usage_errors
    yield
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 105, in augment_usage_errors
    yield
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/cli/command.py", line 136, in cli
    do_py()
  File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 1640, in do_py
    click.echo(which("python", allow_global=system))
  File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 114, in which
    raise RuntimeError("location not created nor specified")
RuntimeError: location not created nor specified'. Make sure pipenv is on the PATH.

Debug [coc.nvim] source jedi timeout after 5000ms

When input im in a *.py, I get [coc.nvim] source jedi timeout after 5000ms. I cannot get any completion from JD (jedi). MPLS also times out for me. I am not sure what happens. The same configuration file works on another machine. Below is my coc-settings.json:

   "suggest.timeout":  5000,
   "diagnostic.checkCurrentLine": true,
   "emmet.includeLanguages": {"markdown": "html"},
   "emmet.excludeLanguages": [],
   "python.jediEnabled": true,
   "list.normalMappings": {
       "<C-c>": "do:exit"
   },
   "list.insertMappings": {
       "<C-c>": "do:exit"
   },
   "languageserver": {
       "ccls": {
           "command": "ccls",
           "filetypes": ["c", "cpp", "objc", "objcpp"],
           "rootPatterns": [".ccls", "compile_commands.json", ".vim/", ".git/", ".hg/"],
           "initializationOptions": {
               "cache": {
                   "directory": "/tmp/ccls"
               }
           }
       }
   }
}

Change jedi source shortcut?

It seems like the shortcut for jedi is hardcoded to JD. Is there a way to change this? setting jedi.shortcut or coc.source.jedi.shortcut don't seem to work.

"Formatting with yapf" message shown after formatting

When calling ":Format" on a buffer coc-python shows the status message

[coc.nvim] Formatting with yapf

This message is kept shown in the status line even after formatting is done. I would expect this message to be hidden after formatting or at least being replaced by a success message.

Extension fails to install on latest coc.nvim

Environment

  • NVIM v0.3.4
  • macOS Mojave 10.14.4 (18E226)
  • Node.js version in $PATH: v11.11.0
  • Commit (coc.nvim): 99789bb016cefd3730535ed7a211c600b4cc8772
  • Branch: master

Description

I'm running into an issue where the coc-python extension fails to install with the following statusline error:

[coc.nvim] Error loading extension from /Users/eyalkalderon/.config/coc/extensions/node_modules/coc-python/lib/index.js: Reflect.hasOwnMetadata is not a function

I've already removed the 'tag': '*' from the relevant Plug command in my init.vim and have upgraded my coc.nvim to the latest master, as suggested here. Any idea what could be going wrong?

yarn error

Getting a yarn pkg error here, when trying:

:CocInstall coc-python

Do you know if it's already on there? Thanks for this, very exciting!

Prospector with empty output

I have a problem using coc-python with prospector.
I don't have any output with prospector when a use a specific configuration:

{
"diagnostic.refreshOnInsertMode": true,
"suggest.enablePreview": false,
"coc.preferences.formatOnSaveFiletypes": ["python"],
"diagnostic.joinMessageLines":true,
"diagnostic.checkCurrentLine":true,
"diagnostic.warningSign":"",
"diagnostic.errorSign": "",
"diagnostic.infoSign": "",
"diagnostic.hintSign": "",
"diagnostic.displayByAle": false,
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.jediEnabled": true,
"python.linting.pylintEnabled": false,
"python.linting.prospectorEnabled": true,
"python.linting.prospectorArgs": ["--profile --my_own_profile","-D"],
"python.linting.pydocstyleEnabled": true,
"python.formatting.provider": "black",
"python.formatting.blackArgs": ["--line-length 119"],
"python.linting.banditEnabled": true,
"list.source.tags.command": "ctags -R ."
}

I already try put "python.linting.prospectorArgs": ["--profile","my_own_profile","-D"], but I think that two syntax don't have difference between.

python.output:

Starting Jedi Python language engine.
##########Linting Output - pydocstyle##########
/home/felipemarcelino/documents/main/fun_lo.py:1 at module level:
D100: Missing docstring in public module
/home/felipemarcelino/documents/main/fun_lo.py:1 in public function teste:
D103: Missing docstring in public function
/home/felipemarcelino/documents/main/fun_lo.py:5 in public function sfd:
D103: Missing docstring in public function
/home/felipemarcelino/documents/main/fun_lo.py:9 in public class class_b:
D101: Missing docstring in public class
##########Linting Output - bandit##########
##########Linting Output - prospector##########
##########Linting Output - prospector##########
##########Linting Output - pydocstyle##########
/home/felipemarcelino/documents/main/fun_lo.py:1 at module level:
D100: Missing docstring in public module
/home/felipemarcelino/documents/main/fun_lo.py:1 in public function teste:
D103: Missing docstring in public function
/home/felipemarcelino/documents/main/fun_lo.py:5 in public function sfd:
D103: Missing docstring in public function
/home/felipemarcelino/documents/main/fun_lo.py:9 in public class class_b:
D101: Missing docstring in public class
##########Linting Output - bandit##########
##########Linting Output - prospector##########
##########Linting Output - prospector##########

*** EDIT 1***

I changed to
"python.linting.prospectorArgs": ["--profile", "my_own_profile","-D"],
and python output with some errors and warnings, but this don't populate my floating window and neither my column sign.

*** EDIT 2***

Works when I remove prospector args, but not with my edited profile config! The two cases with profile and without profile have output, but only the last one is populate in file by coc!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.