@yaegassy/coc-pylsp
yaegassypylsp (python-lsp-server) extension for coc.nvim
Published Package Summary
coc-pylsp
pylsp (python-lsp-server) extension for coc.nvim.
Install
CocInstall:
:CocInstall @yaegassy/coc-pylsp
vim-plug:
Plug 'yaegassy/coc-pylsp', {'do': 'yarn install --frozen-lockfile'}
Detect: pylsp (python-lsp-server)
coc-pylsp detects and starts pylsp.
Priority to detect:
- pylsp.commandPath
- current python3/python environment (e.g. pylsp in venv)
- builtin pylsp (Installation commands are also provided)
Built-in install (pylsp and 3rd party plugins)
coc-pylsp allows you to create an extension-only "venv" and install "pylsp (python-lsp-server)" and "related tools" (e.g. pylsp-mypy).
By default, it is installed with pip install python-lsp-server[all]. (extras_require).
If you want to change "extras_require", please change the pylsp.builtin.installExtrasArgs setting
example:
- Example1:
"pylsp.builtin.installExtrasArgs": []pip install python-lsp-server
- Example2:
"pylsp.builtin.installExtrasArgs": ["all"]:pip install 'python-lsp-server[all]'
- Example3:
"pylsp.builtin.installExtrasArgs": ["yapf", "flake8"]:pip install 'python-lsp-server[yapf,flake8]'
It also supports the installation of "3rd Party Plugins".
- 3rd Party Plugins currently supported
By default, the installation of 3rd Party Plugins is "disabled".
To "enable" it, change each setting in coc-settings.json.
{
// snip...
"pylsp.builtin.enableInstallPylspMypy": true,
"pylsp.builtin.enableInstallPylsIsort": true,
"pylsp.builtin.enableInstallPythonLspBlack": true,
"pylsp.builtin.enableInstallPylspRope": true,
"pylsp.builtin.enableInstallPythonLspRuff": true,
// snip...
}
It is also possible to specify the version of the third party tool to be installed
{
// snip...
"pylsp.builtin.pylspMypyVersion": "0.5.2",
"pylsp.builtin.pylsIsortVersion": "0.2.2",
"pylsp.builtin.pythonLspBlackVersion": "1.0.1",
"pylsp.builtin.pylspRopeVersion": "0.1.10",
"pylsp.builtin.pythonLspRuffVersion": "1.0.5",
// snip...
}
The first time you use coc-pylsp, if pylsp is not detected, you will be prompted to do a built-in installation.
You can also run the installation command manually.
:CocCommand pylsp.builtin.install
python-lsp-ruff
If you enable python-lsp-ruff then you will probably want to disable the built-in pycodestyle,
pyflakes, mccabe and pyls_isort plugins, for example:
{
"pylsp.plugins.pycodestyle.enabled": false,
"pylsp.plugins.pyflakes.enabled": false
"pylsp.plugins.mccabe.enabled": false,
"pylsp.plugins.pyls_isort.enabled": false,
}
Although python-lsp-ruff tries to disable these automatically, they must be explicitly disabled
when using coc-pylsp.
Use tcp mode
To use the tcp mode, set pylsp.connectionMode to 'tcp'. Also, pylsp needs to be started in tcp mode separately.
coc-settings.json:
{
"pylsp.connectionMode": "tcp"
}
How to start pylsp in tcp mode:
# By default, host is 127.0.0.1 and port 2087 is set
pylsp --tcp
# Or specify any host (--host) and port (--port)
pylsp --tcp --host 127.0.0.1 --port 2087
Thanks
License
MIT
This extension is built with create-coc-extension
- pylsp (python-lsp-server) extension for coc.nvim
- onLanguage:python
Want to build, test, or contribute to coc.nvim extensions? Explore our official SDK and testing toolkits.
Open Developer GuideVersion History
This published npm package does not include a history.md or changelog.md file. Browse its npm versions or repository releases for available release information.
Contributed Commands
All contributes.commands entries from the published package manifest for @yaegassy/coc-pylsp@0.13.0.
| Command (:CocCommand) | Description |
|---|---|
| pylsp.builtin.install | Install python lsp server and related tools |
| pylsp.installServer | (old command) Install python lsp server and related tools |
Configuration Schema
All contributes.configuration entries from the published package manifest, including each raw property schema for coc-settings.json.
Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable coc-pylsp extension."
}Raw JSON Schema
{
"type": "string",
"scope": "resource",
"default": "127.0.0.1",
"description": "Specifies the host name to connect pylsp. This setting only works with connectionMode is 'tcp'."
}Raw JSON Schema
{
"type": "number",
"scope": "resource",
"default": "2087",
"markdownDescription": "Specifies the port to connect pylsp. This setting only works with connectionMode is 'tcp'."
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Custom path to the pylsp command. ~ and $HOME, etc. can also be used. If not set, pylsp detected by the current python environment or extension venv's pylsp used will be used"
}Raw JSON Schema
{
"enum": [
"off",
"messages",
"verbose"
],
"type": "string",
"default": "off",
"description": "Traces the communication between coc.nvim and the Python LSP Server."
}Raw JSON Schema
{
"enum": [
"stdio",
"tcp"
],
"type": "string",
"scope": "resource",
"default": "stdio",
"enumDescriptions": [
"Use stdio to communicate with pylsp.",
"Use tcp to connect pylsp. You need to launch pylsp."
],
"markdownDescription": "Controls the communication method to pylsp."
}Raw JSON Schema
{
"type": [
"array",
null
],
"items": {
"type": "string"
},
"default": null,
"description": "The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all.",
"uniqueItems": true
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Python 3.x path (Absolute path) to be used for built-in install"
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Arguments to pass to pylint.",
"uniqueItems": false
}Raw JSON Schema
{
"type": [
"string",
null
],
"default": null,
"description": "Path to optional `pyproject.toml` file."
}Raw JSON Schema
{
"type": [
"array",
null
],
"items": {
"type": "string"
},
"default": null,
"description": "List of error codes to fix during formatting. Empty by default, use `[\"I\"]` here to get import sorting as part of formatting."
}Raw JSON Schema
{
"type": [
"array",
null
],
"items": {
"type": "string"
},
"default": null,
"description": "Error codes to ignore."
}Raw JSON Schema
{
"type": [
"array",
null
],
"items": {
"type": "string"
},
"default": null,
"description": "List of error codes to enable."
}Raw JSON Schema
{
"enum": [
"black",
"ruff",
null
],
"type": [
"string",
"null"
],
"default": "black",
"description": "Formatter to use for reformatting signatures in docstrings."
}Raw JSON Schema
{
"type": "array",
"items": {
"enum": [
"pycodestyle",
"flake8"
],
"type": "string"
},
"default": [
"pycodestyle"
],
"description": "List of configuration sources to use.",
"uniqueItems": true
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Boolean to enable/disable the plugin."
}Raw JSON Schema
{
"type": [
"array",
null
],
"items": {
"type": "string"
},
"default": null,
"description": "Exclude files from being checked by `ruff`."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Boolean that enables/disables rules & fixes that are marked \"preview\" by `ruff`."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Boolean to enable/disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "A boolean to enable or disable black's --preview setting."
}Raw JSON Schema
{
"type": [
"string",
"null"
],
"default": null,
"description": "Path to the config file that will be the authoritative config source."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "List of errors and warnings to ignore (or skip)."
}Raw JSON Schema
{
"type": [
"array",
"null"
],
"items": {
"type": "string"
},
"default": null,
"description": "List of errors and warnings to enable.",
"uniqueItems": true
}Raw JSON Schema
{
"type": [
"object",
"null"
],
"default": null,
"description": "Define environment variables for jedi.Script and Jedi.names."
}Raw JSON Schema
{
"type": [
"string",
null
],
"default": null,
"description": "Builtin and c-extension modules that are allowed to be imported and inspected by rope."
}Raw JSON Schema
{
"type": "number",
"default": 88,
"description": "Maximum line length in signatures."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "List of files or directories to exclude."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": [
"string",
"null"
],
"default": null,
"description": "Only check for filenames matching the patterns in this list."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "List of modules to import on startup",
"uniqueItems": true
}Raw JSON Schema
{
"type": [
"string",
null
],
"default": null,
"description": "Path to the ruff executable. Uses `os.executable -m \"ruff\"` by default."
}Raw JSON Schema
{
"type": [
"integer",
null
],
"default": null,
"description": "Set the line-length for length checks."
}Raw JSON Schema
{
"type": [
"object",
"null"
],
"default": null,
"description": "Dictionary of custom severity levels for specific codes."
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Version of pyls-isort for built-in install"
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Version of pylsp-mypy for built-in install"
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Version of pylsp-rope for built-in install"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin (disabling required to use `yapf`)."
}Raw JSON Schema
{
"type": [
"string",
"null"
],
"default": null,
"description": "Define environment for jedi.Script and Jedi.names."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Define extra paths for jedi.Script."
}Raw JSON Schema
{
"type": "integer",
"default": 15,
"description": "The minimum threshold that triggers warnings about cyclomatic complexity."
}Raw JSON Schema
{
"type": "string",
"default": "(?!test_).*\\.py",
"description": "Check only files that exactly match the given regular expression; default is to match files that don't start with 'test_' but end with '.py'."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Boolean that enables/disables fixes that are marked \"unsafe\" by `ruff`."
}Raw JSON Schema
{
"type": "array",
"default": [
"all"
],
"description": "Setting extras_require for built-in installation"
}Raw JSON Schema
{
"type": "number",
"default": 88,
"description": "An integer that maps to black's max-line-length setting. Defaults to 88 (same as black's default). This can also be set through black's configuration files, which should be preferred for multi-user projects."
}Raw JSON Schema
{
"type": "string",
"default": "flake8",
"description": "Path to the flake8 executable."
}Raw JSON Schema
{
"type": [
"integer",
"null"
],
"default": null,
"description": "Set indentation spaces."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Ignore errors and warnings",
"uniqueItems": true
}Raw JSON Schema
{
"type": [
"array",
null
],
"items": {
"type": "string"
},
"default": null,
"description": "Select errors and warnings",
"uniqueItems": true
}Raw JSON Schema
{
"type": [
"string",
"null"
],
"default": null,
"description": "Executable to run pylint with. Enabling this will run pylint on unsaved files via stdin. Can slow down workflow. Only works with python3."
}Raw JSON Schema
{
"type": [
"array",
null
],
"items": {
"type": "string"
},
"default": null,
"description": "Same as ignore, but append to existing ignores."
}Raw JSON Schema
{
"type": [
"array",
null
],
"items": {
"type": "string"
},
"default": null,
"description": "Same as select, but append to existing error codes."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "A boolean to enable black configuration caching."
}Raw JSON Schema
{
"type": [
"boolean",
"null"
],
"default": null,
"description": "Hang closing bracket instead of matching indentation of opening bracket's line."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Ignore errors and warnings",
"uniqueItems": true
}Raw JSON Schema
{
"type": [
"array",
null
],
"items": {
"type": "string"
},
"default": null,
"description": "Select errors and warnings",
"uniqueItems": true
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Boolean to enable/disable the ruff formatter."
}Raw JSON Schema
{
"type": [
"object",
null
],
"default": null,
"description": "File-specific error codes to be ignored."
}Raw JSON Schema
{
"type": [
"string",
null
],
"default": null,
"description": "The minimum Python version to target."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "List of errors and warnings to append to ignore list."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "List of errors and warnings to append to select list."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Exclude files or directories which match these patterns.",
"uniqueItems": true
}Raw JSON Schema
{
"type": "string",
"default": "[^\\.].*",
"description": "Search only dirs that exactly match the given regular expression; default is to match dirs which do not begin with a dot."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Include signature docstring."
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Version of python-lsp-ruff for built-in install"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Disable the initialization and workdone progress notifications"
}Raw JSON Schema
{
"type": [
"integer",
"null"
],
"default": null,
"description": "Maximum allowed complexity threshold."
}Raw JSON Schema
{
"type": [
"integer",
"null"
],
"default": null,
"description": "Maximum allowed line length for the entirety of this run."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "When parsing directories, only check filenames matching these patterns.",
"uniqueItems": true
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Ignore errors and warnings in addition to the specified convention.",
"uniqueItems": true
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Select errors and warnings in addition to the specified convention.",
"uniqueItems": true
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Version of python-lsp-black for built-in install"
}Raw JSON Schema
{
"type": [
"array"
],
"items": {
"type": "string"
},
"default": [],
"description": "A pairing of filenames and violation codes that defines which violations to ignore in a particular file, for example: `[\"file_path.py:W305,W304\"]`)."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Resolve documentation and detail eagerly."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable fuzzy when requesting autocomplete."
}Raw JSON Schema
{
"enum": [
"pep257",
"numpy",
"google",
null
],
"type": [
"string",
"null"
],
"default": null,
"description": "Choose the basic list of checked errors by specifying an existing convention."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Resolve documentation and detail eagerly."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable/Disable built-in install of pyls-isort"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable/Disable built-in install of pylsp-mypy"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable/Disable built-in install of pylsp-rope"
}Raw JSON Schema
{
"type": [
"integer",
"null"
],
"default": null,
"description": "Set indentation spaces."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Make the autoimport database memory only. Drastically increases startup time."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "If True lists the names of all scopes instead of only the module namespace."
}Raw JSON Schema
{
"type": [
"boolean",
"null"
],
"default": null,
"description": "Hang closing bracket instead of matching indentation of opening bracket's line."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable or disable autoimport. If false, neither completions nor code actions are enabled. If true, the respective features can be enabled or disabled individually."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [
"numpy"
],
"description": "List of module names for jedi.settings.auto_import_modules."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": [
"pandas",
"numpy",
"tensorflow",
"matplotlib"
],
"description": "Modules for which labels and snippets should be cached."
}Raw JSON Schema
{
"type": [
"integer",
"null"
],
"default": null,
"description": "Set maximum allowed line length."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable/Disable built-in install of pylsp-lsp-ruff"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Enable/Disable built-in install of python-lsp-black"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Whether to place extra_paths at the beginning (true) or end (false) of `sys.path`"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable the plugin."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Auto-completes methods and classes with tabstops for each parameter."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "The goto call will follow imports."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "A boolean to enable or disable black's skip-magic-trailing-comma setting."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "A boolean to enable or disable black's --skip-string-normalization setting."
}Raw JSON Schema
{
"type": "integer",
"default": 25,
"description": "How many labels and snippets (at most) should be resolved?"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "If True includes symbols imported from other libraries."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable autoimport completions."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable or disable autoimport code actions (e.g. for quick fixes)."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Adds class objects as a separate completion item."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "If follow_imports is True will decide if it follow builtin imports."
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Adds function objects as a separate completion item."
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Follow builtin and extension definitions to stubs."
}