💡 Sublime Text syntax highlighting for Svelte components
  • Svelte 82.2%
  • mdsvex 15.1%
  • TypeScript 1.4%
  • JavaScript 1.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Cornelius Ukena 99f76ff8bd
fix: recognize Svelte modules and nested each assertions (#52)
fix: recognize Svelte modules and nested each assertions
2026-09-13 00:44:09 -05:00
.github/workflows fix: recognize Svelte modules and nested each assertions 2026-09-13 00:40:41 -05:00
Completions chore: use syntax-test-action dummy_syntaxes input and tidy files 2026-08-14 23:46:57 -05:00
Embeddings fix: recognize Svelte modules and nested each assertions 2026-09-13 00:40:41 -05:00
media Svelte 5 snippet and misc updates 2024-03-23 11:25:45 -05:00
tests fix: recognize Svelte modules and nested each assertions 2026-09-13 00:40:41 -05:00
.gitattributes Exclude tests/ from sublime-package 2024-09-27 22:56:58 +02:00
JavaScript (Svelte).sublime-syntax fix: recognize Svelte modules and nested each assertions 2026-09-13 00:40:41 -05:00
LICENSE Initial commit 2018-04-24 12:07:42 -05:00
MDSVEX.sublime-settings Add MDSVEX syntax 2026-02-22 20:19:49 +01:00
MDSVEX.sublime-syntax Merge branch 'master' into fix/mdsvex-link-destination-interpolation 2026-08-15 00:09:09 -05:00
README.md fix: recognize Svelte modules and nested each assertions 2026-09-13 00:40:41 -05:00
Svelte.sublime-syntax feat: support modern Svelte 5 syntax 2026-08-23 21:02:49 -05:00
TypeScript (Svelte).sublime-syntax fix: recognize Svelte modules and nested each assertions 2026-09-13 00:40:41 -05:00

Svelte Syntax Highlighting

Sublime Text syntax highlighting for Svelte components, reactive JavaScript and TypeScript modules, and MDSVEX documents.

Install

  • Via Package Control: search for Svelte.
  • Manual: clone this repo into a folder named Svelte inside your Sublime Packages folder. Use Preferences → Browse Packages to find it.

Requires Sublime Text 4, build 4143 or newer. CI tests builds 4143, 4152, 4169, 4180, and the latest development build.

Supported files and features

Files Syntax in the picker
.svelte Svelte
.svelte.js JavaScript (Svelte)
.svelte.ts TypeScript (Svelte)
.svx, .mdsv, .mdsvex MDSVEX

Svelte highlighting includes runes, TypeScript template expressions, script generics, snippets, render and attachment tags, declaration tags, event attributes, comments between attributes, member components, boundaries, and markup await. Legacy blocks and directives remain supported.

MDSVEX combines Markdown with Svelte components and expressions, including expressions in link and image destinations. For projects configured to use .md files, select MDSVEX manually or use Open all with current extension as… in the syntax menu.

This package provides syntax highlighting. For diagnostics, navigation, and language-server completions, install LSP and LSP-svelte separately.


Supported Scripts

TypeScript
<script lang="typescript"></script>
<!-- or -->
<script type="text/typescript"></script>

or

<script lang="ts"></script>

type="application/typescript" is also supported. Use lang="ts" for the short language name; type="text/ts" is not recognized.

CoffeeScript
<script lang="coffeescript"></script>
<!-- or -->
<script type="text/coffeescript"></script>
LiveScript
<script lang="livescript"></script>
<!-- or -->
<script type="text/livescript"></script>
Babel
<script lang="babel"></script>
<!-- or -->
<script type="text/babel"></script>

Supported Styles

Sass
<style lang="sass"></style>
<!-- or -->
<style type="text/sass"></style>
Sass (SCSS)
<style lang="scss"></style>
<!-- or -->
<style type="text/scss"></style>
Less
<style lang="less"></style>
<!-- or -->
<style type="text/less"></style>
Stylus
<style lang="stylus"></style>
<!-- or -->
<style type="text/stylus"></style>
PostCSS
<style lang="postcss"></style>
<!-- or -->
<style type="text/postcss"></style>

JavaScript, TypeScript, and CSS use Sublime Text's bundled syntaxes. Install the corresponding syntax packages for other languages, such as Sass and Less. This package does not install or run preprocessors.

Testing

Tests in tests/ assert the scopes assigned by Sublime Text's syntax engine. To run them locally:

  1. Install this checkout as Packages/Svelte and install the syntax dependencies for the embedded languages used by the tests.
  2. Open a syntax_test_* file or a .sublime-syntax file from this package.
  3. Choose Tools → Build System → Syntax Tests, then Tools → Build. Use Tools → Build Results → Next Result to navigate failures.

See Sublime's syntax testing documentation for assertion syntax. Native tests use the installed Sublime build and packages; Docker is not required.

CI runs the full five-build matrix on syntax or test changes, every Monday at 07:23 UTC, and through Run workflow in GitHub Actions. Historical jobs pin default packages, Less, and Sass to compatible refs; the latest job tracks their upstream branches. CI supplies empty syntaxes for CoffeeScript, LiveScript, PostCSS, SugarSS, and Stylus, so it checks embedding boundaries without validating those languages' internal highlighting. Use the workflow configuration when reproducing a particular CI environment.

Known limitations

The lookahead that distinguishes TypeScript assertions from the as in an each block supports three levels of bracket nesting. It does not skip string literals or see a later as on another line. Keep chained assertions and the loop's as on one line, or parenthesize the source assertion, for example {#each (items as Item[]) as item}.


Special Thanks

Huge thanks to the Vue.js folks for their Vue Syntax Highlight package from which a ton of solutions for this package came.

And, obviously, the biggest thanks to Rich Harris for making something as awesome as Svelte.

License

MIT