Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yaegassy/coc-pylsp
pylsp (python-lsp-server) extension for coc.nvim.
https://github.com/yaegassy/coc-pylsp
coc coc-extensions coc-nvim lsp neovim pylsp python vim
Last synced: 7 days ago
JSON representation
pylsp (python-lsp-server) extension for coc.nvim.
- Host: GitHub
- URL: https://github.com/yaegassy/coc-pylsp
- Owner: yaegassy
- License: mit
- Created: 2021-04-19T02:37:18.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-28T03:56:32.000Z (2 months ago)
- Last Synced: 2024-10-28T09:59:06.203Z (10 days ago)
- Topics: coc, coc-extensions, coc-nvim, lsp, neovim, pylsp, python, vim
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@yaegassy/coc-pylsp
- Size: 467 KB
- Stars: 34
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# coc-pylsp
[pylsp](https://github.com/python-lsp/python-lsp-server) (python-lsp-server) extension for [coc.nvim](https://github.com/neoclide/coc.nvim).
## Install
**CocInstall**:
```vim
:CocInstall @yaegassy/coc-pylsp
```**vim-plug**:
```vim
Plug 'yaegassy/coc-pylsp', {'do': 'yarn install --frozen-lockfile'}
```## Detect: pylsp (python-lsp-server)
coc-pylsp detects and starts pylsp.
**Priority to detect**:
1. pylsp.commandPath
1. current python3/python environment (e.g. pylsp in venv)
1. 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
- [pylsp-mypy](https://github.com/Richardk2n/pylsp-mypy)
- [pyls-isort](https://github.com/paradoxxxzero/pyls-isort)
- [python-lsp-black](https://github.com/python-lsp/python-lsp-black)
- [pylsp-rope](https://github.com/python-rope/pylsp-rope)
- [python-lsp-ruff](https://github.com/python-lsp/python-lsp-ruff)By default, the installation of 3rd Party Plugins is "disabled".
To "enable" it, change each setting in `coc-settings.json`.
```jsonc
{
// 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
```jsonc
{
// 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.
```vim
: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**:
```json
{
"pylsp.connectionMode": "tcp"
}
```**How to start pylsp in tcp mode**:
```sh
# 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
```## Configuration options
- `pylsp.enable`: Enable coc-pylsp extension, default: `true`
- `pylsp.trace.server`: Traces the communication between coc.nvim and the Python LSP Server, default: `"off"`
- `pylsp.commandPath`: 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, default: `""`
- `pylsp.connectionMode`: Controls the communication method to pylsp, valid option `["stdio", "tcp"]`, default: `stdio`
- `pylsp.tcpHost`: Specifies the host name to connect pylsp. This setting only works with connectionMode is 'tcp', default: `"127.0.0.1"`
- `pylsp.tcpPort`: Specifies the port to connect pylsp. This setting only works with connectionMode is 'tcp', default: `2087`
- `pylsp.disableProgressNotifications`: Disable the initialization and workdone progress notifications, default: `true`
- `pylsp.builtin.pythonPath`: Python 3.x path (Absolute path) to be used for built-in install, default: `""`
- `pylsp.builtin.installExtrasArgs`: Setting extras_require for built-in installation, default: `["all"]`
- `pylsp.builtin.enableInstallPylspMypy`: Enable/Disable built-in install of `pylsp-mypy`, default: `false`
- `pylsp.builtin.enableInstallPylsIsort`: Enable/Disable built-in install of `pyls-isort`, default: `false`
- `pylsp.builtin.enableInstallPythonLspBlack`: Enable/Disable built-in install of `python-lsp-black`, default: `false`
- `pylsp.builtin.enableInstallPylspRope`: Enable/Disable built-in install of `pylsp-rope`, default: `false`
- `pylsp.builtin.enableInstallPythonLspRuff`: Enable/Disable built-in install of pylsp-lsp-ruff, default: `true`
- `pylsp.builtin.pylspMypyVersion`: Version of pylsp-mypy for built-in install, e.g. "0.5.2", default: `""`
- `pylsp.builtin.pylsIsortVersion`: Version of pyls-isort for built-in install, e.g. "0.2.2", default: `""`
- `pylsp.builtin.pythonLspBlackVersion`: Version of python-lsp-black for built-in install, e.g. "1.0.1" default: `""`
- `pylsp.builtin.pylspRopeVersion`: Version of pylsp-rope for built-in install, default: `""`
- `pylsp.builtin.pythonLspRuffVersion`: Version of python-lsp-ruff for built-in install, default: `""`For other settings, Check the "configuration" section of [package.json](/package.json).
## Commands
- `pylsp.builtin.install`: Install python lsp server and related tools
- pylsp will be installed in this path.
- Mac/Linux: `~/.config/coc/extensions/@yaegassy/coc-pylsp-data/pylsp/venv/bin/pylsp`
- Windows: `~/AppData/Local/coc/extensions/@yaegassy/coc-pylsp-data/pylsp/venv/Scripts/pylsp.exe`
- 3rd Party Plugins will also be installed in the same `venv`## Thanks
- [python-lsp/python-lsp-server](https://github.com/python-lsp/python-lsp-server)
## License
MIT
---
> This extension is built with [create-coc-extension](https://github.com/fannheyward/create-coc-extension)