The Svelte Language Server, and official extensions which use it
Svelte Language Tools contains a library implementing the Language Server Protocol (LSP). LSP powers the VSCode extension, which is also hosted in this repository. Additionally, LSP is capable of powering plugins for numerous other IDEs.
A .svelte file would look something like this:
<script>
let count = $state(1);
let doubled = $derived(count * 2);
let quadrupled = $derived(doubled * 2);
function handleClick() {
count += 1;
}
</script>
<button onclick="{handleClick}">Count: {count}</button>
<p>{count} * 2 = {doubled}</p>
<p>{doubled} * 2 = {quadrupled}</p>
Which is a mix of HTMLx and vanilla JavaScript (but with additional runtime behavior coming from the svelte compiler).
This repo contains the tools which provide editor integrations for Svelte files like this.
Contributions are encouraged and always welcome. Read the contribution guide for more info and help us out!
Svelte is an MIT-licensed open source project with its ongoing development made possible entirely by the support of awesome volunteers. If you'd like to support their efforts, please consider:
Funds donated via Open Collective will be used for compensating expenses related to Svelte's development such as hosting costs. If sufficient donations are received, funds may also be used to support Svelte's development more directly.
svelte2tsxgood first issue 또는 help wanted 이슈가 없습니다.
Svelte Language Tools provides IDE support for Svelte files through the Language Server Protocol (LSP). It powers the VSCode extension and enables Svelte support in numerous other IDEs.
The Open Source Guides website has a collection of resources for individuals, communities, and companies. These resources help people who want to learn how to run and contribute to open source projects. Contributors and people new to open source alike will find the following guides especially useful:
There are many ways to contribute to Svelte Language Tools, and many of them do not involve writing any code. Here's a few ideas to get started:
Contributions are very welcome. If you think you need help planning your contribution, please reach out to us on Discord and let us know you are looking for a bit of help.
This is a monorepo managed with pnpm workspaces. Install pnpm globally with:
npm i -g pnpm
Clone the repository and install dependencies:
git clone git@github.com:sveltejs/language-tools.git
cd language-tools
pnpm install
pnpm bootstrap
To build all packages:
pnpm build
To watch for changes:
pnpm watch
packages/language-server - The language server for Svelte.packages/svelte-vscode - The official VSCode extension for Sveltepackages/svelte2tsx - Converts .svelte files into legal TypeScript/JSX. Want to see how it's transformed? Check out this REPLpackages/svelte-check - CLI tool for type checking and diagnosticspackages/language-server/src/server.ts - Language server entry pointpackages/language-server/src/plugins/ - Language service plugins (TypeScript, Svelte, CSS, HTML)packages/svelte2tsx/src/svelte2tsx/index.ts - Svelte to TSX transformationpackages/svelte-vscode/src/extension.ts - VSCode extension entry pointflowchart LR
%% IDEs
VSC[IDE: VSCode + Svelte for VS Code extension]
click VSC "https://github.com/sveltejs/language-tools/tree/master/packages/svelte-vscode" "Svelte for VSCode extension"
%% Tools
CLI[CLI: svelte-check]
click CLI "https://github.com/sveltejs/language-tools/tree/master/packages/svelte-check" "A command line tool to get diagnostics for Svelte code"
%% Svelte - Extensions
VSC_TSSP[typescript-svelte-plugin]
click VSC_TSSP "https://github.com/sveltejs/language-tools/tree/master/packages/typescript-plugin" "A TypeScript plugin for Svelte intellisense"
%% Svelte - Packages
SVELTE_LANGUAGE_SERVER["svelte-language-server"]
SVELTE_COMPILER_SERVICE["svelte2tsx"]
TS_SERVICE["TS/JS intellisense using TypeScript language service"]
SVELTE_SERVICE["Svelte intellisense using Svelte compiler"]
click SVELTE_LANGUAGE_SERVER "https://github.com/sveltejs/language-tools/tree/master/packages/language-server" "A language server adhering to the LSP"
click SVELTE_COMPILER_SERVICE "https://github.com/sveltejs/language-tools/tree/master/packages/language-server/src/plugins/svelte" "Transforms Svelte code into JSX/TSX code"
click TS_SERVICE "https://github.com/sveltejs/language-tools/tree/master/packages/language-server/src/plugins/typescript"
click SVELTE_SERVICE "https://github.com/sveltejs/language-tools/tree/master/packages/language-server/src/plugins/svelte"
%% External Packages
HTML_SERVICE[HTML intellisense using vscode-html-languageservice]
CSS_SERVICE[CSS intellisense using vscode-css-languageservice]
VSC_TS[vscode-typescript-language-features]
click HTML_SERVICE "https://github.com/microsoft/vscode-html-languageservice"
click CSS_SERVICE "https://github.com/microsoft/vscode-css-languageservice"
click VSC_TS "https://github.com/microsoft/vscode/tree/main/extensions/typescript-language-features"
subgraph EMBEDDED_SERVICES[Embedded Language Services]
direction LR
TS_SERVICE
SVELTE_SERVICE
HTML_SERVICE
CSS_SERVICE
end
VSC -- Language Server Protocol --> SVELTE_LANGUAGE_SERVER
CLI -- Only using diagnostics feature --> SVELTE_LANGUAGE_SERVER
VSC -- includes --> VSC_TS
VSC_TS -- loads --> VSC_TSSP
VSC_TSSP -- uses --> SVELTE_COMPILER_SERVICE
TS_SERVICE