Skip to content

Commit 18aba84

Browse files
committed
add support for stylus
1 parent fcc8129 commit 18aba84

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</a>
1111
</p>
1212

13-
Vim syntax and indent plugin for `.svelte` files. Forked from [vim-vue-plugin][3].
13+
Vim syntax and indent plugin for `.svelte` files. Forked from [vim-vue-plugin][3].
1414

1515
## Installation
1616

@@ -71,11 +71,12 @@ Set global variable to `1` to enable or `0` to disable. Ex:
7171
| g:vim_svelte_plugin_use_typescript | Enable typescript syntax for `<script lang="ts">`. | 0 |
7272
| g:vim_svelte_plugin_use_less | Enable less syntax for `<style lang="less">`. | 0 |
7373
| g:vim_svelte_plugin_use_sass | Enable scss syntax for `<style lang="scss">`(or sass for `lang="sass"`). | 0 |
74+
| g:vim_svelte_plugin_use_stylus | Enable stylus syntax for `<style lang="stylus">`. | 0 |
7475
| g:vim_svelte_plugin_has_init_indent | Initially indent one tab inside `style/script` tags. | 1 |
7576
| g:vim_svelte_plugin_use_foldexpr | Enable builtin `foldexpr` foldmethod. | 0 |
7677
| g:vim_svelte_plugin_debug | Echo debug messages in `messages` list. Useful to debug if unexpected indents occur. | 0 |
7778

78-
\*: Vim may be slow if the feature is enabled. Find a balance between syntax highlight and speed. By the way, custom syntax can be added in `~/.vim/syntax` or `$VIM/vimfiles/syntax`.
79+
\*: Vim may be slow if the feature is enabled. Find a balance between syntax highlight and speed. By the way, custom syntax can be added in `~/.vim/syntax` or `$VIM/vimfiles/syntax`.
7980

8081
**Note**
8182

syntax/svelte.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ let s:load_full_syntax = svelte#GetConfig('load_full_syntax', 0)
2222
let s:use_pug = svelte#GetConfig('use_pug', 0)
2323
let s:use_less = svelte#GetConfig('use_less', 0)
2424
let s:use_sass = svelte#GetConfig('use_sass', 0)
25+
let s:use_stylus = svelte#GetConfig('use_stylus', 0)
2526
let s:use_coffee = svelte#GetConfig('use_coffee', 0)
2627
let s:use_typescript = svelte#GetConfig('use_typescript', 0)
2728
"}}}
@@ -104,6 +105,11 @@ if s:use_less
104105
runtime! after/syntax/less.vim
105106
endif
106107

108+
" If sass is enabled, load sass syntax
109+
if s:use_stylus
110+
call s:LoadSyntax('@StylusSyntax', 'stylus')
111+
endif
112+
107113
" If sass is enabled, load sass syntax
108114
if s:use_sass
109115
call s:LoadSyntax('@SassSyntax', 'sass')
@@ -204,6 +210,10 @@ syntax region cssScssSvelteStyle fold
204210
\ start=+<style[^>]*lang="scss"[^>]*>+
205211
\ end=+</style>+
206212
\ keepend contains=@SassSyntax,svelteTag
213+
syntax region cssStylusSvelteStyle fold
214+
\ start=+<style[^>]*lang="stylus"[^>]*>+
215+
\ end=+</style>+
216+
\ keepend contains=@StylusSyntax,svelteTag
207217

208218
syntax region svelteTag
209219
\ start=+^<[^/]+ end=+>+ skip=+></+
@@ -243,6 +253,7 @@ if s:use_less
243253
\ contained containedin=cssLessSvelteStyle
244254
\ start="{" end="}"
245255
endif
256+
246257
if s:use_sass
247258
silent! syntax clear sassDefinition
248259
syntax region cssSassDefinition matchgroup=cssBraces
@@ -251,6 +262,14 @@ if s:use_sass
251262
\ start="{" end="}"
252263
endif
253264

265+
if s:use_stylus
266+
silent! syntax clear stylusDefinition
267+
syntax region cssStylusDefinition matchgroup=cssBraces
268+
\ contains=@StylusSyntax,cssStylusDefinition
269+
\ contained containedin=cssStylusSvelteStyle
270+
\ start="{" end="}"
271+
endif
272+
254273
" Avoid css syntax interference
255274
silent! syntax clear cssUnitDecorators
256275
" Have to use a different name

0 commit comments

Comments
 (0)