Skip to content
Afa' Afa'

Kate LSP Client: Run pylsp for a python with virtual environment

Configure Kate to run python-lsp-server from a project virtual environment.

1 min read Updated

Kate's LSP client can run python-lsp-server from a project's virtual environment instead of a global install. This note adds the server as a development dependency and registers it in Kate's settings. The commands and configuration are below.

Install

sh
poetry add --group=dev python-lsp-server[rope,pylint,pydocstyle,autopep8]

Documentation

~/.config/kate/lspclient/settings.json

json
{
  "servers": {
    "_python-venv": {
      "command": ["%{Project:NativePath}/.venv/bin/pylsp", "--check-parent-process"],
      "url": "https://github.com/python-lsp/python-lsp-server",
      "root": "%{Project:NativePath}",
      "path": ["%{Project:NativePath}/venv/bin", "%{Project:NativePath}/.venv/bin"],
      "highlightingModeRegex": "^Python$",
      "settings": {
        "pylsp": {
          "plugins": {
            "flake8": {
              "enabled": false
            },
            "pylint": {
              "enabled": true,
              "executable": "%{Project:NativePath}/venv/bin/pylint"
            },
            "pydocstyle": {
              "enabled": true
            },
            "autopep8": {
              "enabled": true
            },
            "rope_autoimport": {
              "enabled": true,
              "python_path": ".venv/lib/python3.11/site-packages:.venv/lib/python3.10/site-packages:$PYTHONPATH",
              "completions": {
                "enabled": true
              },
              "code_actions": {
                "enabled": true
              }
            }
          }
        }
      }
    }
  }
}
Something wrong or want to discuss this article? Get in touch

Search articles and projects

Type to filter articles and projects. Use the arrow keys to move through results and Enter to open one. Press Escape to close.