vim-svelte-plugin
- Purpose: A Vim syntax and indent plugin specifically designed for
.svelte
files, combining HTML, CSS, and JavaScript syntax highlighting and indentation within a single file. - Target Audience: Vim users who work with Svelte components and need proper syntax support for embedded languages in
.svelte
files.
Key Features
- Supports Svelte directives and embedded languages:
- HTML, CSS, JavaScript
- Less/Sass/Scss, Pug (with vim-pug fa-solid fa-up-right-from-square), CoffeeScript (with vim-coffee-script fa-solid fa-up-right-from-square), TypeScript (with typescript-vim fa-solid fa-up-right-from-square or yats.vim fa-solid fa-up-right-from-square)
- Built-in
foldexpr
foldmethod for code folding. - Integration with emmet-vim fa-solid fa-up-right-from-square for HTML/CSS/JavaScript detection.
- Context-aware behavior for mappings, completions, and local options based on the current tag or language subtype (e.g.,
template
,script
,style
).
Configuration
Customizable via global variables to enable/disable features like:
- Full syntax loading (
g:vim_svelte_plugin_load_full_syntax
) - Pug, CoffeeScript, TypeScript, Less, Sass, Stylus support (
g:vim_svelte_plugin_use_*
) - Initial indentation inside
style/script
tags (g:vim_svelte_plugin_has_init_indent
) - Debugging and foldmethod options.
Context Functions
GetSvelteTag()
: Returns the current tag (template
,script
,style
).GetSvelteSubtype()
: Returns the current language subtype (html
,javascript
,css
, etc.).OnChangeSvelteSubtype(subtype)
: Event listener for subtype changes, useful for setting local options dynamically.
Performance Notes
- Syntax overload can cause delays; the plugin
vimsveltepluginsyntaxindentsvelte3
Featured Stories
No featured articles here. Navigate to an article, then pick the Feature on menu button