Overview
The Svelte Language Server is a language server protocol implementation that provides language-specific support for the Svelte framework. It allows editor and addon developers to add features such as diagnostics, auto-complete, and formatting to any editor without reinventing the wheel.
Features
- Diagnostic messages: Provides warning and error messages specific to Svelte.
- Svelte specific formatting: Supports formatting code using the prettier-plugin-svelte.
- HTML support: Includes support for HTML code using the vscode-html-languageservice.
- Hover info: Provides information on hover for Svelte code.
- Autocompletions: Offers suggestions for code completions.
- Emmet support: Integration with Emmet for faster HTML and CSS coding.
- Symbols in Outline panel: Displays symbols in the outline panel for easy navigation.
- CSS / SCSS / LESS support: Supports CSS, SCSS, and LESS code using the vscode-css-languageservice.
- TypeScript / JavaScript support: Provides diagnostics, hover info, formatting, symbols, and code actions for TypeScript and JavaScript using TypeScript.
Installation
To use the Svelte Language Server, you need to install a plugin for your editor. Currently, the following editors are supported:
VS Code
- Open VS Code
- Go to the extensions panel (Ctrl + Shift + X)
- Search for “Svelte Language Server” and click install
Atom
- Open Atom
- Go to the package manager (Ctrl + Shift + P)
- Search for “Svelte Language Server” and click install
(Neo)Vim
- Open (Neo)Vim
- Install a plugin manager if you don’t have one already (e.g., Plug, Vundle)
- Add the following line to your vimrc:
Plug 'sveltejs/language-tools', { 'do': 'yarn install --lock-file', 'for': 'svelte' }
- Run
:PlugInstall to install the plugin
Summary
The Svelte Language Server is a powerful tool for Svelte developers that allows for language-specific features and smart support in any editor. With support for diagnostics, formatting, autocompletions, and more, it enhances the development experience for Svelte projects. By providing a plugin for popular editors like VS Code, Atom, and (Neo)Vim, it ensures easy installation and usage for developers.