Sublime Forum

How do I install LSP and CSS Language Service?

#1

How do I install and setup LSP and https://github.com/Microsoft/vscode-css-languageservice? I can’t figure out what settings I need to add to LSP settings.

0 Likes

#2

I cant find these settings?

command - specify a full paths, add arguments
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 - used both by the language servers and to select a syntax highlighter for sublime popups.
enabled - disable a language server globally, or per-project
settings - per-project settings (equivalent to VS Code’s Workspace Settings)
initializationOptions - options to send to the server at startup (rarely used)

0 Likes

#3

I don’t use node, but a config would look nearly as follows:

	"clients":
	{
		"css":
		{
			"enabled": true,
			"command": ["node", "vscode-css-languageservice"],
			"scopes": ["source.css", "source.css"],
			"syntaxes": ["Packages/CSS/CSS.sublime-syntax", "Packages/CSS3/CSS3.sublime-syntax"],
			"languageId": "css"
		}
	},

Where command is the list of command line arguments needed to start the service

scopes and syntaxes are the information LSP needs in order to know when to use this server. You need to add the values depending on the syntax you use for CSS. The example would apply to the built-in CSS package an CSS3.

0 Likes

#4

Where do you get those values from anyway? I am trying to find them on the plugin and LSP package pages but don’t see them.

0 Likes

#5

The scheme of a client configuration is defined in the LSP.sublime-settings. The “command” is the command line you need to start the server. The “scope” and “syntaxes” depend on the syntax you use for CSS. ST provides the “CSS.subliem-syntax” by default, which defines the “source.css” scope inside. This is just the way ST does highlighting and the values needed for LSP to recognize it. The source of the values is just logical thinking and abstraction of the already existing configurations.

If you open the installation dir of ST, you’ll see a folder “Packages” which contains a “CSS.sublime-package”. This is a zip file containing the CSS.sublime-syntax. The path “Packages/CSS/CSS.sublime-syntax” is the way ST addresses this file in particular or any file in any package in general.

1 Like

#6

Thank you for the explanation. Now I think I get it. :slight_smile:

0 Likes