Language Server Protocol

Language Server Protocol

The Language Server Protocol is used between a tool (the client) and a language smartness provider (the server) to integrate features like auto complete, go to definition, find all references and alike into the tool. The LSP was created by Microsoft to define a common language for programming language analyzers to speak. Today, several companies have come together to support its growth, including Codenvy, Red Hat, and Sourcegraph, and the protocol is becoming supported by a rapidly growing list of editor and language communities. See below for details on and links to current client and server implementations.

SublimeText + LSP

  • Open “Preferences > Browse Packages”
  • git clone https://github.com/tomv564/LSP inside that directory
  • Open “Preferences > Package Settings > LSP > Settings”
  • Add the client definition for the programming language
  • Restart the code editor

SublimeText + LSP + Go

  • go get -u golang.org/x/tools/cmd/gopls
  • Open “Preferences > Package Settings > LSP > Settings”
  • Add the client definition for the Go programming language
{
    "clients": {
        "golsp": {
            "command": ["gopls"],
            "scopes": ["source.go"],
            "syntaxes": ["Packages/Go/Go.sublime-syntax"],
            "languageId": "go"
        }
    }
}

SublimeText + LSP + PHP

  • Install Composer from here
  • Create this file $HOME/composer.json
  • Add this {"minimum-stability": "dev", "prefer-stable": true}
  • Execute this composer require felixfbecker/language-server
  • Execute this composer run-script --working-dir=vendor/felixfbecker/language-server parse-stubs
  • Open “Preferences > Package Settings > LSP > Settings”
  • Add the client definition for the PHP programming language
{
    "clients": {
        "phpls": {
            "command": ["php", "~/vendor/felixfbecker/language-server/bin/php-language-server.php"],
            "scopes": ["source.php", "embedding.php"],
            "syntaxes": ["Packages/PHP/PHP.sublime-syntax"],
            "languageId": "php"
        }
    }
}
Do you have a project idea? Let's make it together!