Skip to content

Instantly share code, notes, and snippets.

@robcowie
Last active August 29, 2022 19:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robcowie/46e72318cf15af0194f2cbb3339068f3 to your computer and use it in GitHub Desktop.
Save robcowie/46e72318cf15af0194f2cbb3339068f3 to your computer and use it in GitHub Desktop.
Install and configure the python language server for Sublime Text 3 (using the LSP plugin)

Install and configure Python LSP & Sublime Text 3

Install the langauge server

This installs the python server provided by Palantir.

Microsoft also provide the C# server which requires the .net runtime.

pipenv install 'python-language-server[all]'
pipenv --venv | pbcopy

I reccomend installing this in it's own environment. This example uses pipenv.

Install the LSP plugin for ST3

See https://github.com/tomv564/LSP

Select Package Control: Install Package
Select LSP

Configure the python language server

The most important configuration is to point to the pyls executable wherver you installed it, by setting command.

Preferences: LSP Settings

An example config:

{
  "clients": {
    "pyls":
      {
        "enabled": true,
        "command": [
          "/path/to/virtualenvs/sublime-text-python-lsp-NW5Vqshn/bin/pyls"
        ],
        "settings": {
          "pyls": {
            "configurationSources": ["flake8"],
            "plugins": {
              "jedi_definition": {
                "follow_imports": true
              }
            }
          }
        },
        "scopes": ["source.python"],
        "syntaxes": [
          "Packages/Python/Python.sublime-syntax",
          "Packages/Djaneiro/Syntaxes/Python Django.tmLanguage"
        ],
        "languageId": "python"
      }
  }
}

Useful Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment