Svelte Mode screenshot

Svelte Mode

Author Avatar Theme by Leafoftree
Updated: 31 Mar 2025
91 Stars

Emacs major mode for Svelte.

Overview

svelte-mode is an Emacs major mode for .svelte files. It is based on mhtml-mode and requires Emacs major version 26 or higher. This mode includes JavaScript/CSS as submodes in html-mode and supports Svelte directives and blocks. It also has support for Emmet-mode HTML/CSS detection, Pug-mode in <template lang="pug">...</template>, Coffee-mode in <script lang="coffee">...</script>, and Sass-mode in <style lang="sass">...</style>. The mode can be customized using variables such as svelte-basic-offset, svelte-tag-relative-indent, and svelte-display-submode-name. The mode also provides configuration hacks, such as closing tags for components with “reserved” names.

Features

  • Based on mhtml-mode
  • Supports Svelte directives and blocks
  • Includes JavaScript/CSS as submodes in html-mode
  • Supports Emmet-mode HTML/CSS detection
  • Supports Pug-mode in <template lang="pug">...</template>
  • Supports Coffee-mode in <script lang="coffee">...</script>
  • Supports Sass-mode in <style lang="sass">...</style>
  • Customizable variables such as svelte-basic-offset, svelte-tag-relative-indent, and svelte-display-submode-name
  • Configuration hacks for closing tags for components with “reserved” names

Installation

To install svelte-mode, you can use MELPA by running the following command in Emacs:

M-x package-install RET svelte-mode RET

Alternatively, you can install it manually by putting the files inside dotspacemacs/user-config for Spacemacs. If everything goes well, svelte-mode should be automatically enabled for .svelte files. It is recommended to stay up to date with the latest version of svelte-mode by opening an issue or a pull request.

Summary

svelte-mode is an Emacs major mode for editing .svelte files. It provides support for Svelte directives and blocks, as well as submodes for JavaScript/CSS in html-mode. It offers additional features such as Emmet-mode HTML/CSS detection and support for Pug-mode, Coffee-mode, and Sass-mode. The mode can be customized using variables, and it also provides configuration hacks for closing tags for components with “reserved” names. Overall, svelte-mode is a useful tool for developers working with Svelte in Emacs.