Getting started

  1. Install a language server from the list below, ensuring it can be started from the command line (is in your PATH)

  2. Run "LSP: Enable Language Server" from Sublime's Command Palette to allow the server to start.

  3. Open a document in your language - if the server starts its name will be in the left side of the status bar.

Javascript/Typescript

Different servers wrapping microsoft's typescript services, most support plain javascript:

Theia's typescript-language-server: npm install -g typescript-language-server

My own tomv564/lsp-tsserver: npm install -g lsp-tsserver

Sourcegraph's javascript-typescript-langserver: npm install -g javascript-typescript-langserver

Flow (Javascript)

Official part of flow-bin: npm install -g flow-bin

Older flow-language-server: github: npm install -g flow-bin

Vue (Javascript)

See: LSP-vue

Be sure to install Vue Syntax Highlight from Package Control.

Python

pip install python-language-server

See: github:palantir/python-language-server

Alternatively, Microsoft's python language server (using .NET Core runtime)

Instructions here

Use virtualenv adding the following settings :

"settings": {
        "LSP": {
            "pyls": {
                "env": {
                    "PYTHONPATH": "/Users/mike/.virtualenvs/my-virtual-env/lib/python3.7/site-packages"
                }
            }
        }
    }

PHP

Intelephense

npm i intelephense -g

See bmewburn/intelephense-docs

PHP Language server

See: github:felixfbecker/php-language-server

Global installation:

  1. modify ~/.composer/composer.json to set "minimum-stability": "dev" and "prefer-stable": true
  2. run composer global require felixfbecker/language-server
  3. run composer run-script --working-dir=~/.composer/vendor/felixfbecker/language-server parse-stubs

Ruby / Ruby on Rails

Requires the solargraph gem:

gem install solargraph

See github.com:castwide/solargraph for up-to-date installation instructions.

Rust

Goes well with the Rust Enhanced package which uses the RLS server: github:rust-lang-nursery/rls for up-to-date installation instructions.

Alternatively, a newer rust-analyzer server is under development, also supported by LSP.

Scala

  • Metals: Most complete LSP server for Scala, see instructions here for installation.
  • SBT: Version 1.x supports limited and unmaintained language server functionalities, setup is described here.
  • Dotty: The future Scala compiler contains LSP support. It is developed against VS Code, so ignore instructions related to VS Code. Get the project compiling with dotty first (see instructions). At this point LSP should complain in the logs java.util.concurrent.CompletionException: java.io.FileNotFoundException: /Users/tomv/Projects/tomv564/dottytest/finagle/doc/src/sphinx/code/quickstart/.dotty-ide.json Then run sbt configureIDE to create the .dotty-ide.json file Then the LSP plugin should launch as configured in LSP.sublime-settings using coursier.

C/C++

See the dedicated C/C++ guide for using ccls, cquery or clangd.

C

Omnisharp omnisharp-roslyn

Download or build according to instructions above, then add this client config to your LSP settings under clients:

"omnisharp": {
  "command":
  [
    "/home/tb/prebuilt/omnisharp/OmniSharp.exe", // or eg. /usr/local/opt/omnisharp/run
    "-lsp"
  ],
  "enabled": true,
  "languageId": "csharp",
  "syntaxes": ["Packages/C#/C#.sublime-syntax"],
  "scopes":
  [
    "source.cs"
  ]
}

D

See instructions for d-language-server.

dub fetch dls
dub run dls:bootstrap

Add to LSP settings' clients:


"dls": {
    "command": ["<PATH TO DLS EXECUTABLE>"],
    "enabled": true,
    "languageId": "d",
    "scopes": ["source.d"],
    "syntaxes": ["Packages/D/D.sublime-syntax"]
}

Elm

See instructions for installing the elm-language-server. Install Elm Syntax Higlighting from Package Control for syntax highlighting.

Add to LSP settings' clients:

"elm": {
    "command": [
        "elm-language-server",
        "--stdio"
    ],
    "enabled": true,
    "languageId": "elm",
    "scopes":
    [
        "source.elm"
    ],
    "syntaxes":
    [
        "Packages/Elm Syntax Highlighting/src/elm.sublime-syntax"
    ],
    "initializationOptions": {
        "elmAnalyseTrigger": "change"
    }
}

Ocaml/Reason

You will need to install sublime-reason and the dependencies listed in the repo, such as ocaml-language-server. If you only use OCaml, you still need those listed dependencies, but not the sublime-reason plugin itself.

Go

Gopls

go get -u golang.org/x/tools/cmd/gopls

Official go language server, under development.

Sourcegraph's go-langserver

go get github.com/sourcegraph/go-langserver

See: github:palantir/sourcegraphgo-langserver

CSS

Using the CSS language server from VS Code

npm install -g vscode-css-languageserver-bin

Polymer

npm install -g polymer-editor-service

Note: requires an up to date version of NodeJS. v6 is the minimum supported version as of 2017.

Features:

  • typeahead completions for elements, attributes, and css custom properties
  • typeahead completions for elements, attributes, and css custom properties
  • documentation on hover for elements and attributes
  • jump to definition for elements, attributes, and css custom properties
  • linting, configured through polymer.json at your workspace root.

More info: https://github.com/Polymer/polymer-editor-service

Dart

Install the Dart Sublime package and the Dart SDK

Then locate the "snapshots/bin" directory of the SDK, and specify the path to analysis_server.dart.snapshot in the LSP user settings under "clients", "dart", then "command".

The older natebosch/dart_language_server is now deprecated

Kotlin

Install from kotlin language server Requires building first.

"kotlinls":
{
    "command":
    [
        "PATH_TO_KotlinLanguageServer/build/install/kotlin-language-server/bin/kotlin-language-server.bat" // adjust this path!
    ],
    "enabled": true,
    "languageId": "kotlin",
    "scopes":
    [
        "source.Kotlin"
    ],
    "syntaxes":
    [
        "Packages/kotlin/Kotlin.tmLanguage"
    ]
}

Additionally, install the Kotlin sublime package for syntax highlighting.

Julia

Install the LanguageServer package from the Julia repl.

Install the LSP-julia sublime package from package control.

Or instead of LSP-julia, add the following client configuration:

"julials":
{
  "command": ["bash", "PATH_TO_JULIA_SERVER/LanguageServer/contrib/languageserver.sh"],
  "languageId": "julia",
  "scopes": ["source.julia"],
  "syntaxes": ["Packages/Julia/Julia.sublime-syntax"],
  "settings": {"runlinter": true}
}

Lua

  1. Download the VSCode extension
  2. add these configurations:
"lua-ls":
{
    "command":
    [
        "PATH/TO/sumneko.lua-#.#.#/extension/server/bin/lua-language-server",
        "-E",
        "PATH/TO/sumneko.lua-#.#.#/extension/server/main.lua"
    ],
    "enabled": true,
    "languageId": "lua",
    "scopes":
    [
        "source.lua",
    ],
    "syntaxes":
    [
        "Packages/Lua/Lua.sublime-syntax"
    ]
},

alternatively you can use the less maintained lua-lsp

Lisp<a name="lisp"

  1. Install cc-lsp using Roswell
  2. Add this configuration to your clients in the LSP settings:
"cc-lsp":
{
    "command":
    [
        "cl-lsp",
        "stdio"
    ],
    "enabled": true,
    "languageId": "lisp",
    "scopes":
    [
        "source.lisp",
    ],
    "syntaxes":
    [
        "Packages/Lisp/Lisp.sublime-syntax""
    ]
}

Bash

Install the bash language server

npm i -g bash-language-server

PowerShell

  1. Download and extract the latest release PowerShellEditorServices
  2. Install the powershell plugin for syntax highlighting
  3. add these configurations:
"powershell-ls":
{
  "command":
  [
    "PATH/TO/powershell or pwsh",
    "-NoLogo",
    "-NoProfile",
    "-NonInteractive",
    "-ExecutionPolicy", "Bypass",  // windows only
    "-Command",
    "PATH/TO/PowerShellEditorServices/PowerShellEditorServices/Start-EditorServices.ps1",
    "-LogPath", "PATH/TO/pses.log",  // the path itself is not relevant
    "-LogLevel", "Normal",
    "-SessionDetailsPath", "PATH/TO/session.json",  // the path itself is not relevant
    "-FeatureFlags", "@()",
    "-HostName", "'Sublime Text'",
    "-HostProfileId", "subl",
    "-HostVersion", "1.0.0",
    "-AdditionalModules", "@()",
    "-BundledModulesPath", "PATH/TO/PowerShellEditorServices",
    "-Stdio"
  ],
  "enabled": true,
  "languageId": "powershell",
  "scopes":
  [
    "source.powershell"
  ],
  "syntaxes":
  [
    "Packages/PowerShell/Support/PowershellSyntax.tmLanguage"
  ]
}
  1. make sure powershell help files are up to date by running Update-Help in the powershell console (the one you're using in the command)

For more details see this issue

Terraform

  1. Download terraform-lsp binary and make it available in PATH
  2. add these configurations:
"terraform":
{
  "command":
  [
    "terraform-lsp"
  ],
  "enabled": true,
  "scopes": ["source.terraform"],
  "syntaxes":  ["Packages/Terraform/Terraform.sublime-syntax"],
  "languageId": "terraform"
}

XML

Discussed in this issue

Download jar from angelozerr/lsp4xml

Add config:

"lsp4xml":
{
    "command":
    [
        "java",

        // false on windows, true on other operating systems
        "-DwatchParentProcess=false",
        // JVM options (not necessary) but the vscode extension uses them by default
        "-noverify",  // bypass class verification
        "-Xmx64M",  // set the maximum heap size
        "-XX:+UseG1GC",  // use the G1 garbage collector
        "-XX:+UseStringDeduplication",  // enable string deduplication optimisation
        "-jar",
        "PATH/TO/org.eclipse.lsp4xml-uber.jar"
    ],
    "enabled": true,
    "languageId": "xml",
    "scopes":
    [
        "text.xml"
    ],
    "syntaxes":
    [
        "Packages/XML/XML.sublime-syntax"
    ]
}

IntelliJ

Requires IntelliJ to be running.

"intellij":{
  "tcp_port": 8080 // default port
  "command": [],
  "languageId": "java",
  "scopes": [
    "source.java"
  ],
  "syntaxes": [
    "Packages/Java/Java.sublime-syntax"
  ]
}

LaTeX

Download a precompiled binary (Windows/Linux/macOS) of the TexLab Language Server and place it in a directory that is in your PATH.

Add to LSP settings' clients:

"texlab": {
  "command": ["texlab"],
  "languages": [{
    "scopes": ["text.tex.latex"],
    "syntaxes": ["Packages/LaTeX/LaTeX.sublime-syntax"],
    "languageId": "latex"
  }, {
    "scopes": ["text.bibtex"],
    "syntaxes": ["Packages/LaTeX/Bibtex.sublime-syntax"],
    "languageId": "bibtex"
  }],
  "enabled": true
}

To enable code completions while typing, ensure to have text.tex.latex (for LaTeX files) and/or text.bibtex (for BibTeX files) included in the auto_complete_selector setting in your Preferences.sublime-settings file. For further requirements see the TexLab Docs.

Other

Please create issues / pull requests so we can get support for more languages.

Server Configuration

LSP ships with default configurations for a few language servers. These configurations need to be enabled before they will start.

If your language server is missing or not configured correctly, you can add/override the below settings under the "clients" key in the LSP Settings.

Here is an example for the Javascript/Typescript server:

"jsts": {
  "command": ["lsp-tsserver"],
  "scopes": ["source.ts", "source.tsx"],
  "syntaxes": ["Packages/TypeScript-TmLanguage/TypeScript.tmLanguage", "Packages/TypeScript-TmLanguage/TypeScriptReact.tmLanguage"],
  "languageId": "typescript"
}

or in multi-language form:

"lsp-tsserver": {
  "command": ["lsp-tsserver"],
  "languages": [{
    "scopes": ["source.js", "source.jsx"],
    "syntaxes": ["Packages/Babel/JavaScript (Babel).sublime-syntax", "Packages/JavaScript/JavaScript.sublime-syntax"],
    "languageId": "javascript"
  }, {
    "scopes": ["source.ts", "source.tsx"],
    "syntaxes": ["Typescript"],
    "languageId": "typescript"
  }
  ]
}

Most important:

  • enabled - enables a language server (default is disabled)

Values that determine if a server should be started and queried for a given document:

  • scopes - add language flavours, eg. source.js, source.jsx.
  • syntaxes - syntaxes that enable LSP features on a document, eg. Packages/Babel/JavaScript (Babel).tmLanguage
  • languageId - identifies the language for a document - see https://microsoft.github.io/language-server-protocol/specification#textdocumentitem
  • languages - group scope, syntax and languageId together for servers that support more than one language

Settings used to start and configure a language server:

  • command - must be on PATH or specify a full path, add arguments (can be empty if starting manually, then TCP transport must be configured)
  • env - dict of environment variables to be injected into the language server's process (eg. PYTHONPATH)
  • settings - per-project settings (equivalent to VS Code's Workspace Settings)
  • initializationOptions - options to send to the server at startup (rarely used)

The default transport is stdio, but TCP is also supported. The port number can be inserted into the server's arguments by adding a {port} placeholder in command.

Server-owned port

Set tcp_port and optionally tcp_host if server running on another host.

Editor-owned port (servers based on vscode-languageserver-node):

Set tcp_mode to "host", leave tcp_port unset for automatic port selection. tcp_port can be set if eg. debugging a server. You may want to check out the LSP source and extend the TCP_CONNECT_TIMEOUT.

Per-project overrides

Any global language server settings can be overridden per project by adding an LSP settings block to your .sublime-project file.

{
  "folders":
  [
    {
      "path": "."
    }
  ],
  "settings": {
    "LSP": {
      "jsts": {
        "enabled": false,
      },
      "eslintls": {
        "settings": {
          "eslint": {
            "autoFixOnSave": true
          }
        }
      }
    }
  }
}