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 Globally" or "LSP: Enable Lanuage Server in Project" 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.

About LSP

The Language Server Protocol is a specification about the communication protocol for use between text editors or IDEs and language servers - tools which provide language-specific features like autocomplete, go to definition, or documentation on hover. This LSP package acts as an interface between Sublime Text and the language servers, which means that to obtain these features you need to install a server for your language first. Language servers can be provided as standalone executables or might require a runtime environment like Node.js or Python. The list below shows installation instructions and example configurations for several servers that have been tested and are known to work with the LSP package. Visit Langserver.org or the list of language server implementations maintained by Microsoft for a complete overview of available servers for various programming languages.

For a few languages you can also find dedicated packages on Package Control, which can optionally be installed to simplify the configuration and installation process of a language server and might provide additional features such as automatic updates for the server:

Server Configuration

After you have installed a language server, the LSP settings need to be configured to enable communication between LSP and that server for suitable filetypes. LSP ships with default configurations for a few language servers, but these need to be enabled before they will start. To globally enable a server, open the Command Palette and choose "LSP: Enable Language Server Globally". This will add "enabled": true to the corresponding language server setting under the "clients" key in your user-settings file for LSP. Your user-settings file is stored at Packages/User/LSP.sublime-settings and can be opened via "Preferences > Package Settings > LSP > Settings" from the menu. If your language server is missing or not configured correctly, you need to add/override further settings which are explained below.

Here is an example of the LSP.sublime-settings file with configurations for the JavaScript/TypeScript server:

{
  // General settings
  "log_stderr": true,
  "log_payloads": true,

  // Language server configurations
  "clients": {
    "lsp-tsserver": {
      "command": ["lsp-tsserver"],
      "enabled": true,
      "languageId": "typescript",
      "scopes": ["source.ts", "source.tsx"],
      "syntaxes": ["Packages/TypeScript-TmLanguage/TypeScript.tmLanguage", "Packages/TypeScript-TmLanguage/TypeScriptReact.tmLanguage"]
    }
  }
}

Some language servers support multiple languages, which can be specified in the following way:

{
  // General settings
  "log_stderr": true,
  "log_payloads": true,

  // Language server configurations
  "clients": {
    "lsp-tsserver": {
      "command": ["lsp-tsserver"],
      "enabled": true,
      "languages": [{
        "languageId": "javascript",
        "scopes": ["source.js", "source.jsx"],
        "syntaxes": ["Packages/Babel/JavaScript (Babel).sublime-syntax", "Packages/JavaScript/JavaScript.sublime-syntax"]
      }, {
        "languageId": "typescript",
        "scopes": ["source.ts", "source.tsx"],
        "syntaxes": ["Packages/TypeScript-TmLanguage/TypeScript.tmLanguage", "Packages/TypeScript-TmLanguage/TypeScriptReact.tmLanguage"]
      }]
    }
  }
}
Setting Description
enabled enables a language server (default is disabled)
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)
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 LSP specifications
languages group scope, syntax and languageId together for servers that support more than one language
tcp_port see instructions below
tcp_host see instructions below
tcp_mode see instructions below

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
          }
        }
      }
    }
  }
}

Language servers

The following list can help you to install and configure language servers for use with LSP. Please remember to put the configurations in a "clients" dictionary in your LSP.sublime-settings file, as shown in the example above. If you use or would like to use language servers that are not in this list, please create issues or pull requests, so we can add support for more languages.

Bash

1. Install the Bash Language Server:

npm i -g bash-language-server

2. Run "LSP: Enable Language Server Globally" from the Command Palette and choose bashls.

C/C++

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

C#

  1. Download or build OmniSharp.
  2. Add to LSP settings' clients:
"omnisharp": {
  "command": [
    "/home/tb/prebuilt/omnisharp/OmniSharp.exe", // or eg. /usr/local/opt/omnisharp/run
    "-lsp"
  ],
  "enabled": true,
  "languageId": "csharp",
  "scopes": ["source.cs"],
  "syntaxes": ["Packages/C#/C#.sublime-syntax"]
}

Clojure

  1. Download clojure-lsp.
  2. Add to LSP settings' clients:
"clojure-lsp": {
  "command": ["java", "-jar", "/PATH/TO/clojure-lsp"],
  "enabled": true,
  "initializationOptions": {},
  "languageId": "clojure",
  "scopes": ["source.clojure"],
  "syntaxes": ["Packages/Clojure/Clojure.sublime-syntax"]
}

clojure-lsp has a rich set of initializationOptions.

CSS

1. Install the CSS language server from VS Code:

npm install -g vscode-css-languageserver-bin

2. Run "LSP: Enable Language Server Globally" from the Command Palette and choose vscode-css.

D

1. Install the D Language Server:

dub fetch dls
dub run dls:bootstrap

2. Add to LSP settings' clients:

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

Dart

  1. Install the Dart package from Package Control for syntax highlighting.
  2. Install the Dart SDK and locate path to analysis_server.dart.snapshot in the "snapshots/bin" directory.
  3. Add to LSP settings' clients (adjust the path if necessary):
"dart": {
  "command": ["dart", "/usr/local/opt/dart/libexec/bin/snapshots/analysis_server.dart.snapshot", "--lsp"],
  "enabled": true,
  "languageId": "dart",
  "scopes": ["source.dart"],
  "syntaxes": ["Packages/Dart/Dart.tmLanguage"]
}

Note: The older natebosch/dart_language_server is now deprecated.

Elixir

  1. Install the Elixir package from Package Control for syntax highlighting.
  2. Download the prebuilt binaries or compile elixir-ls. This will get you a folder containing language_server.sh among other things.
  3. Add to LSP settings' clients (adjust the path if necessary):
"elixir-ls": {
  "command": ["/home/someUser/somePlace/elixir-ls/release/language_server.sh"],
  "enabled": true,
  "languageId": "elixir",
  "scopes": ["source.elixir"],
  "syntaxes": ["Packages/Elixir/Syntaxes/Elixir.tmLanguage"]
}

Elm

  1. Install the Elm Syntax Highlighting package from Package Control for syntax highlighting.
  2. See instructions for installing the elm-language-server.
  3. Add to LSP settings' clients:
"elm": {
  "command": ["elm-language-server", "--stdio"],
  "enabled": true,
  "initializationOptions": {
    "elmAnalyseTrigger": "change"
  },
  "languageId": "elm",
  "scopes": ["source.elm"],
  "syntaxes": ["Packages/Elm Syntax Highlighting/src/elm.sublime-syntax"]
}

Flow (JavaScript)

Official part of flow-bin:

npm install -g flow-bin

Older flow-language-server:

npm install -g flow-language-server

Fortran

1. Install the Fortran package from Package Control for syntax highlighting.
2. Install the Fortran Language Server (requires Python):

pip install fortran-language-server

3. Add to LSP settings' clients:

"fortls": {
  "command": ["fortls"],
  "enabled": true,
  "languageId": "fortran",
  "scopes": [
    "source.modern-fortran",
    "source.fixedform-fortran"
  ],
  "syntaxes": [
    "Packages/Fortran/grammars/FortranModern.sublime-syntax",
    "Packages/Fortran/grammars/FortranFixedForm.sublime-syntax"
  ]
}

Note: See the Language server settings documentation for a detailed description of available configuration options, for example "command": ["fortls", "--lowercase_intrinsics"] to use lowercase for autocomplete suggestions.

Go

Gopls

1. Install gopls, the official language server for the Go language:

go get golang.org/x/tools/gopls@latest

2. Run "LSP: Enable Language Server Globally" from the Command Palette and choose gopls.

Note: See the User guide for detailed installation instructions and configurations.

Sourcegraph's go-langserver

1. Install Sourcegraph's Go Language Server:

go get github.com/sourcegraph/go-langserver

2. Run "LSP: Enable Language Server Globally" from the Command Palette and choose golsp.

Note: Work on this language server has been deprioritized in favor of the gopls language server mentioned above.

Haskell

  1. Install ghcide.
  2. Add to LSP settings' clients:
"ghcide": {
  "enabled": true,
  "languageId": "haskell",
  "command": ["ghcide", "--lsp"],
  "scopes": ["source.haskell"],
  "syntaxes": ["Packages/Haskell/Haskell.sublime-syntax"]
}

Java

Eclipse JDT Language Server

  1. Download and extract Eclipse's jdt-ls.
  2. Add to LSP settings' clients:
"jdtls": {
  "command": [
    "java",
    "--add-modules=ALL-SYSTEM",
    "--add-opens",
    "java.base/java.util=ALL-UNNAMED",
    "--add-opens",
    "java.base/java.lang=ALL-UNNAMED",
    "-Declipse.application=org.eclipse.jdt.ls.core.id1",
    "-Dosgi.bundles.defaultStartLevel=4",
    "-Declipse.product=org.eclipse.jdt.ls.core.product",
    "-Dfile.encoding=UTF-8",
    "-DwatchParentProcess={true|false}",  // false on windows, true other OSs
    "-noverify",
    "-Xmx1G",
    "-XX:+UseG1GC",
    "-XX:+UseStringDeduplication",
    "-jar",
    "PATH/TO/jdt-language-server-latest/plugins/org.eclipse.equinox.launcher_*.jar"
    "-configuration",
    "PATH/TO/jdt-language-server-latest/config_{win|mac|linux}", // depending on the OS
    "-data",
    "<TEMP_DIR>/${project_base_name}/jdt_ws"
  ],
  "enabled": true,
  "languageId": "java",
  "scopes": ["source.java"],
  "syntaxes": ["Packages/Java/Java.sublime-syntax"]
}

IntelliJ

Requires IntelliJ to be running.

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

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

Julia

1. Install the Julia package from Package Control for syntax highlighting.
2. Install the LanguageServer and SymbolServer packages from the Julia REPL:

import Pkg;
Pkg.add("LanguageServer")
Pkg.add("SymbolServer")

3. Add to LSP settings' clients:

"julials": {
  "command": ["bash", "PATH_TO_JULIA_SERVER/LanguageServer/contrib/languageserver.sh"], // on Linux/macOS
  // "command": ["julia", "--startup-file=no", "--history-file=no", "-e", "using LanguageServer; using LanguageServer.SymbolServer; server=LanguageServer.LanguageServerInstance(stdin,stdout,false); run(server)"], // on Windows
  "languageId": "julia",
  "scopes": ["source.julia"],
  "settings": {
    // Default values from VS Code:
    "julia": {
      "format": {
        "calls": true,        // Format function calls
        "comments": true,     // Format comments
        "curly": true,        // Format braces
        "docs": true,         // Format inline documentation
        "indent": 4,          // Indent size for formatting
        "indents": true,      // Format file indents
        "iterOps": true,      // Format loop iterators
        "kw": true,           // Remove spaces around = in function keywords
        "lineends": false,    // [undocumented]
        "ops": true,          // Format whitespace around operators
        "tuples": true,       // Format tuples
      },
      "lint": {
        "call": false,        // Check calls against existing methods (experimental)
        "constif": true,      // Check for constant conditionals of if statements
        "datadecl": false,    // [undocumented]
        "iter": true,         // Check iterator syntax of loops
        "lazy": true,         // Check for deterministic lazy boolean operators
        "modname": true,      // Check for invalid submodule names
        "nothingcomp": false, // [undocumented]
        "pirates": true,      // Check for type piracy
        "run": true,          // run the linter on active files
        "typeparam": true     // Check for unused DataType parameters
      }
    }
  },
  "syntaxes": ["Packages/Julia/Julia.sublime-syntax"]
}

Kotlin

  1. Install the Kotlin package from Package Control for syntax highlighting.
  2. Install the Kotlin Language Server (requires building first).
  3. Add to LSP settings' clients:
"kotlinls": {
  "command": ["PATH/TO/KotlinLanguageServer/build/install/kotlin-language-server/bin/kotlin-language-server.bat"],
  "enabled": true,
  "languageId": "kotlin",
  "scopes": ["source.Kotlin"],
  "settings": {
    "kotlin": {
      // put your server settings here
    }
  },
  "syntaxes": ["Packages/kotlin/Kotlin.tmLanguage"]
}

LaTeX

  1. Download a precompiled binary (Windows/Linux/macOS) of the TexLab language server.
  2. Add to LSP settings' clients:
"texlab": {
  "command": ["PATH/TO/texlab"],
  "enabled": true,
  "languages": [{
    "languageId": "latex",
    "scopes": ["text.tex.latex"],
    "syntaxes": ["Packages/LaTeX/LaTeX.sublime-syntax"]
  }, {
    "languageId": "bibtex",
    "scopes": ["text.bibtex"],
    "syntaxes": ["Packages/LaTeX/Bibtex.sublime-syntax"]
  }]
}

Note: 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.

Lisp

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

Lua

  1. Download the VS Code extension.
  2. Add to LSP settings' clients:
"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.

OCaml/Reason

  1. Install the Reason package from Package Control for syntax highlighting.
  2. Install the Reason Language Server.
  3. Add to LSP settings' clients:
"reason": {
  "command": ["PATH/TO/reason-language-server.exe"],
  "enabled": true,
  "languageId": "reason",
  "scopes": ["source.ocaml", "source.reason"],
  "syntaxes": [
    "Packages/Ocaml/OCaml.sublime-syntax",
    "Packages/Reason/Reason.tmLanguage",
    "Packages/sublime-reason/Reason.tmLanguage"
  ]
}

PHP

Intelephense

npm i intelephense -g

See bmewburn/intelephense-docs

PHP Language server

See: 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

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
  • 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: Polymer/polymer-editor-service

PowerShell

  1. Install the PowerShell package from Package Control for syntax highlighting.
  2. Download and extract the latest release PowerShellEditorServices.
  3. 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 below).
  4. Add to LSP settings' clients:
"powershell-ls": {
  "command": [
    "powershell", // or pwsh for PowerShell Core
    "-NoLogo",
    "-NoProfile",
    "-NonInteractive",
    "-ExecutionPolicy", "Bypass", // Windows only
    "-Command", "PATH/TO/PowerShellEditorServices/PowerShellEditorServices/Start-EditorServices.ps1",
    "-LogPath", "PATH/TO/pses.log", // specify a path where a logfile should be stored
    "-LogLevel", "Normal",
    "-SessionDetailsPath", "PATH/TO/session.json", // specify a path where a file for session details should be stored
    "-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"]
}

Note: For more details see this issue.

Python

There are at least two language servers, use either one.

Palantir's Python Language Server

pip install 'python-language-server[all]'

Make sure you can run pyls in your terminal. If you've installed it into a virtualenv, you might need to override the path to pyls in global LSP settings (Package Settings -> LSP -> Settings):

"pyls": {
  "command": ["/Users/mike/.virtualenvs/pyls-virtual-env/bin/pyls"], // example path, adjust it for your use case
  "enabled": true // if you want to enable Python Language Server globally
}

If you use a virtualenv for your current project, add a path to it in your project configuration (Project -> Edit Project):

{
  "settings": {
    "LSP": {
      "pyls": {
        "enabled": true, // if you want to enable Python Language Server for current project only
        "env": {
          // example path, adjust it for your use case
          // it needs to be an absolute path, neither $HOME nor ~ work here
          "PYTHONPATH": "/Users/mike/.virtualenvs/my-virtual-env/lib/python3.7/site-packages"
        }
      }
    }
  }
}

See: github:palantir/python-language-server

Microsoft's Python Language Server

Alternatively, use Microsoft Python Language Server (using .NET Core runtime). Instructions.

R

1. Install the languageserver package from CRAN (see the CRAN mirrored package on GitHub for more information and up-to-date installation instructions):

install.packages("languageserver")

2. Run "LSP: Enable Language Server Globally" from the Command Palette and choose rlang.

Ruby/Ruby on Rails

1. Install the solargraph gem (see github:castwide/solargraph for up-to-date installation instructions):

gem install solargraph

2. Run "LSP: Enable Language Server Globally" from the Command Palette and choose ruby.

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.

Terraform

  1. Download terraform-lsp binary and make it available in your PATH.
  2. Add to LSP settings' clients:
"terraform": {
  "command": ["terraform-lsp"],
  "enabled": true,
  "languageId": "terraform",
  "scopes": ["source.terraform"],
  "syntaxes":  ["Packages/Terraform/Terraform.sublime-syntax"]
}

Vue (Javascript)

See: LSP-vue

Be sure to install Vue Syntax Highlight from Package Control.

XML

  1. Download jar from angelozerr/lsp4xml.
  2. Add to LSP settings' clients:
"lsp4xml": {
  "command": [
    "java",
    "-DwatchParentProcess=false",  // false on windows, true on other operating systems
    // 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"]
}

Note: Discussed in this issue.