Skip to content

Customization

Hover popups#

LSP uses mdpopups to display the popup. You can override its style by creating a Packages/User/mdpopups.css file. In particular, to get the same font in the popup as your "font_face" setting in Packages/User/Preferences.sublime-settings, add

html {
    --mdpopups-font-mono: "your desired font face";
}

to Packages/User/mdpopups.css. See the mdpopups documentation for more details.

Keyboard shortcuts (key bindings)#

LSP's key bindings can be edited from the Preferences: LSP Key Bindings command in the Command Palette. Many of the default key bindings (visible in the left view) are disabled to avoid conflicts with default or user key bindings. To enable those, copy them to your user key bindings on the right, un-comment, and pick the key shortcut of your choice.

If you want to create a new key binding that is different from the ones that are already included, you might want to make it active only when there is a language server with a specific LSP capability (refer to the ServerCapabilities structure in that link) running. In that case, you can make use of the lsp.session_with_capability context. For example, the following key binding overrides ctrl+r to use LSP's symbol provider but only when the current view has a language server with the documentSymbolProvider capability and we're in a javascript or a typescript file:

{
    "command": "lsp_document_symbols",
    "keys": [
        "ctrl+r"
    ],
    "context": [
        {
            "key": "lsp.session_with_capability",
            "operator": "equal",
            "operand": "documentSymbolProvider"
        },
        {
            "key": "selector",
            "operator": "equal",
            "operand": "source.ts, source.js"
        }
    ]
},

Generally, you should not need to restrict your key bindings to specific scopes and just rely on checking the capability context.

Mouse map configuration#

If you want to bind some action to a mouse, open Preferences / Browser Packages from the main menu and create a sublime-mousemap file in the following location within the Packages folder:

Platform Path
Windows /User/Default (Windows).sublime-mousemap
Linux /User/Default (Linux).sublime-mousemap
Mac /User/Default (OSX).sublime-mousemap

Here is an example mouse binding that triggers LSP's "go to symbol definition" command on pressing the ctrl+left click:

[
    {
        "button": "button1",
        "count": 1,
        "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "command": "lsp_symbol_definition",
    }
]

Color scheme customizations#

Some features use TextMate scopes to control the colors (underline, background or text color) of styled regions in a document or popup. Colors can be customized by adding a rule for these scopes into your color scheme. There is an example in the official ST documentation which explains how to do that.

The following tables give an overview about the scope names used by LSP.

Document Highlights#

This feature is only available if the server has the documentHighlightProvider capability.

Highlights other occurrences of the symbol at a given cursor position.

scope DocumentHighlightKind description
markup.highlight.text.lsp Text A textual occurrence
markup.highlight.read.lsp Read Read-access of a symbol, like reading a variable
markup.highlight.write.lsp Write Write-access of a symbol, like writing to a variable

Note

If document_highlight_style is set to "fill" in the LSP settings, the highlighting color can be controlled via the "background" color from a color scheme rule for the listed scopes.

Diagnostics#

scope DiagnosticSeverity description drawn as
markup.error.lsp Error Reports an error Squiggly underlines
markup.warning.lsp Warning Reports a warning Squiggly underlines
markup.info.lsp Information Reports an information Stippled underlines
markup.info.hint.lsp Hint Reports a hint Stippled underlines

When the region of the diagnostic spans more than one line, the diagnostic is always drawn as a box.

Diagnostics will also optionally include the following scopes:

scope diagnostic tag name description
markup.unnecessary.lsp Unnecessary Unused or unnecessary code
markup.deprecated.lsp Deprecated Deprecated or obsolete code

Those scopes can be used to, for example, gray-out the text color of unused code, if the server supports that.

For example, to add a custom rule for Mariana color scheme, select UI: Customize Color Scheme from the Command Palette and add the following rule:

{
    "rules": [
        {
            "scope": "markup.unnecessary.lsp",
            "foreground": "color(rgb(255, 255, 255) alpha(0.4))",
            "background": "color(var(blue3) alpha(0.9))"
        }
    ]
}

The color scheme rule only works if the "background" color is different from the global background of the scheme. So for other color schemes, ideally pick a background color that is as close as possible, but marginally different from the original background.

Signature Help#

scope description
entity.name.function.sighelp.lsp Function name in the signature help popup
variable.parameter.sighelp.lsp Function argument in the signature help popup

Annotations#

scope description
markup.accent.codelens.lsp Accent color for code lens annotations
markup.accent.codeaction.lsp Accent color for code action annotations