An LSP adapter for Sublime Text 3.
Python HTML
Pull request Compare This branch is 11 commits ahead, 15 commits behind Microsoft:master.
Latest commit 47a056b Nov 15, 2016 @uforic uforic committed on GitHub Update readme with required path additions
Permalink
Failed to load latest commit information.
icons Moving the sublime TypeScript folder contents to the root Feb 20, 2015
messages Minor change Jun 23, 2015
screenshots lsp: go to def, find references, and diagnostics converted Nov 8, 2016
snippets Remove extra newline in log snippet Feb 17, 2016
typescript TS/JS language support; Windows support (#5) Nov 15, 2016
.gitignore Stop event listenrs from running if LS is disabled Nov 26, 2015
Context.sublime-menu update readme, publish more than one diagnostic Nov 9, 2016
Default (Linux).sublime-keymap Enable all snippets and custom commands to work with tsx source files. Sep 15, 2015
Default (OSX).sublime-keymap Enable all snippets and custom commands to work with tsx source files. Sep 15, 2015
Default (Windows).sublime-keymap Stop event listenrs from running if LS is disabled Nov 26, 2015
Default.sublime-keymap Enable all snippets and custom commands to work with tsx source files. Sep 15, 2015
Default.sublime-mousemap fix #514 Sep 9, 2016
ErrorList.YAML-tmLanguage Polish the errorlist panel and update the tsserver to 1.5 release Jun 18, 2015
ErrorList.hidden-tmLanguage Polish the errorlist panel and update the tsserver to 1.5 release Jun 18, 2015
FindRefs.YAML-tmLanguage Added configuration request. The host can send this request to inform Mar 16, 2015
FindRefs.hidden-tmLanguage Added configuration request. The host can send this request to inform Mar 16, 2015
FindRefs.hidden-tmTheme Hooking the mouse (double-click) in the reference view to go to the r… Feb 24, 2015
FindRefs.sublime-settings Moving the sublime TypeScript folder contents to the root Feb 20, 2015
LICENSE Initial commit Dec 15, 2014
Main.sublime-menu lsp: go to def, find references, and diagnostics converted Nov 8, 2016
README.md Update readme with required path additions Nov 15, 2016
SublimeLsp.sublime-settings lsp: go to def, find references, and diagnostics converted Nov 8, 2016
TypeScript.sublime-commands update readme, publish more than one diagnostic Nov 9, 2016
TypeScript.sublime-settings Removes `$` from word_separators Fixes #457 Apr 17, 2016
main.py lsp: go to def, find references, and diagnostics converted Nov 8, 2016
messages.json Add message for 0.1.5 Jun 23, 2015
popup.html Move popup styling to the active color scheme Sep 5, 2016

README.md

LSP Connector for Sublime Text

A Language Server Protocol connector for Sublime Text 3.

The project is in beta mode. Feedback or issue? Please email us at support@sourcegraph.com or file an issue.

Overview

The Language Server Protocol is a specification that enables advanced language capabilities in an editor independent-way. Previously, to support a given language in a given editor, an editor extension writer would have to both write the editor specific functionality as well as language analysis capabilities for each language. This means that every editor and language had different levels of capability and reliability.

With LSP, one editor extension can be written per editor, and one language server per language. Sourcegraph's master plan is to support editor and language server open source authors, let us know if you'd like to work on one!

This plugin borrows heavily from the popular Microsoft TypeScript Sublime Plugin.

Operations supported

This connector currently supports:

Autocomplete, semantic symbol-based search, formatting utilities will soon be supported.

Languages supported

This plugin has been developed for use with the go-langserver language server. Sourcegraph is currently developing JavaScript/TypeScript, Python, and PHP language servers, which will also work with this adapter. Finally, any language server implementing the Language Server Protocol can be connected to this plugin.

Installation

Connector installation

Install the sublime-lsp connector for Sublime Text by cloning sublime-lsp repository into your Sublime Text 3 Packages folder:

macOS:

git clone git@github.com:sourcegraph/sublime-lsp.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/sublime-lsp

Linux:

git clone git@github.com:sourcegraph/sublime-lsp.git ~/.config/sublime-text-3/Packages/sublime-lsp

Windows:

cd "%APPDATA%\Sublime Text 3\Packages"
git clone https://github.com/sourcegraph/sublime-lsp

Go installation

Install the langserver-go binary by running go get -u github.com/sourcegraph/go-langserver/langserver/cmd/langserver-go. The langserver-go binary should now be available via your command line.

Next, configure the LSP connector for the langserver-go binary. To change your Sourcegraph settings, open SublimeLsp.sublime-settings by clicking Sublime Text > Preferences > Package Settings > Sublime Lsp Connector > Settings - User.

Add the following client descriptor into clients section

{
    ...
        "clients": [
            {
                "binary": "langserver-go",
                "file_exts": ["go"],
                // the go binary must be in the path
                "path_additions": ["/usr/local/go/bin"],
                "env": {
                    // GOPATH is a required argument, ~'s don't work
                    "GOPATH": "",
                }
            }
        ]
    ....
}

Finally, restart Sublime Text to start using the plugin. You may want to disable Sublime's native tooltips, as they are duplicative and interfere with this connector's tooltips.

TypeScript/JavaScript installation

First, you need to add TypeScript Sublime support the following way:

git clone git clone https://github.com/Microsoft/TypeScript-TmLanguage ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/TypeScript-TmLanguage

Linux:

git clone https://github.com/Microsoft/TypeScript-TmLanguage ~/.config/sublime-text-3/Packages/TypeScript-TmLanguage

Windows:

cd "%APPDATA%\Sublime Text 3\Packages"
git clone https://github.com/Microsoft/TypeScript-TmLanguage

Then install the TypeScript/JavaScript LSP server the following way:

export JSTS_DIR=...
git clone https://github.com/sourcegraph/javascript-typescript-langserver $JSTS_DIR
cd $JSTS_DIR
npm install
node_modules/.bin/tsc

Please make sure that $JSTS_DIR/bin is in $PATH

Next, register TypeScript/JavaScript LSP client. To change your Sourcegraph settings, open SublimeLsp.sublime-settings by clicking Sublime Text > Preferences > Package Settings > Sublime Lsp Connector > Settings - User.

Add the following client descriptor into clients section

{
    ...
        "clients": [
            {
                "binary": "javascript-typescript-stdio",
                "file_exts": ["ts", "tsx", "js", "jsx"],
                "path_additions": ["/path/to/jsts/bin", "/path/to/node/binary/usually/usr/local/bin"],
            }
    ]
    ...
}

Finally, restart Sublime Text to start using the plugin. You may want to disable Sublime's native tooltips, as they are duplicative and interfere with this connector's tooltips.

Usage

Hover

As you navigate through Go files, when your cursor is on a symbol, you should see hover tooltips. You may have to disable Sublime's native tooltips.

hover tooltips

Goto definition

Execute the Lsp: Goto definition command, and Sublime will jump to the definition of a symbol in your workspace.

goto def

Find all references

Execute the Lsp: Find all references command, and Sublime will open up a results pane with semantic references to the symbols within your project.

find all references

Diagnostics

As you type, the language server connector will receive diagnostics from the language server. If any errors are detected, the editor will display a tooltip when the offending text is clicked.

find all references

Troubleshooting

Make sure the langserver-go is installed

Run langserver-go -h in your command line. You should see a help menu.

Sublime Text 3 version check

For hover tooltips to work, you'll need Sublime Text 3, Build 3124 (released in 9/2016). Navigate to Sublime Text > About Sublime Text to check the version.

Remove Sublime Text 3 tooltips and Goto menu items

If you are seeing two tooltips that flicker when you hover over symbols, you may have to disable Sublime Text 3 tooltips. Navigate to Sublime Text > Preferences > Settings, and add the following lines:

{
    ...
    "show_definitions": false, // recommended: removes default Sublime tooltips
    "index_files": false, // optional: removes default Sublime "Goto Definition" from right click
    ...
} 

Using Sublime with LSP Connector

Open the command window

To open Sublime's command window and access LSP connector operations, just execute the following key combination:

  • Linux/Windows ctrl+shift+p
  • Mac command+shift+p

Any search items starting with Language Server is provided by the LSP connector.

command bar access

Add right click menu options

By default, the sublime-lsp connector includes two options to your right click menu. Find local references and Explore code at cursor.

Change default keybindings

TBD

Support

Found a bug, want to request a feature, or want to help Sourcegraph build the global graph of code? Send us an email at hi@sourcegraph.com.