mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-08 13:44:46 +08:00
Add skeleton stylus support
This commit is contained in:
@@ -44,7 +44,7 @@ Since `.vue` is a combination of CSS, HTML and JavaScript, so is `vim-vue-plugin
|
|||||||
Supports
|
Supports
|
||||||
|
|
||||||
- Vue directives.
|
- Vue directives.
|
||||||
- Less/Sass/Scss, Pug with [vim-pug][4], Coffee with [vim-coffee-script][11], TypeScript with [typescript-vim][14] or [yats.vim][15].^
|
- Less/Sass/Scss, Pug with [vim-pug][4], Coffee with [vim-coffee-script][11], TypeScript with [typescript-vim][14] or [yats.vim][15], Stylus with [vim-stylus][16].^
|
||||||
- A builtin `foldexpr` foldmethod.^
|
- A builtin `foldexpr` foldmethod.^
|
||||||
- [emmet-vim][10] HTML/CSS/JavaScript filetype detection.
|
- [emmet-vim][10] HTML/CSS/JavaScript filetype detection.
|
||||||
- `.wpy` files from [WePY][6].
|
- `.wpy` files from [WePY][6].
|
||||||
@@ -65,6 +65,7 @@ Set global variable to `1` to enable or `0` to disable. Ex:
|
|||||||
| `g:vim_vue_plugin_use_typescript` | Enable typescript syntax for `<script lang="ts">`. | 0 |
|
| `g:vim_vue_plugin_use_typescript` | Enable typescript syntax for `<script lang="ts">`. | 0 |
|
||||||
| `g:vim_vue_plugin_use_less` | Enable less syntax for `<style lang="less">`. | 0 |
|
| `g:vim_vue_plugin_use_less` | Enable less syntax for `<style lang="less">`. | 0 |
|
||||||
| `g:vim_vue_plugin_use_sass` | Enable scss syntax for `<style lang="scss">`(or sass fo `lang="sass"`). | 0 |
|
| `g:vim_vue_plugin_use_sass` | Enable scss syntax for `<style lang="scss">`(or sass fo `lang="sass"`). | 0 |
|
||||||
|
| `g:vim_vue_plugin_use_stylus` | Enable stylus syntax for `<style lang="stylus">`. | 0 |
|
||||||
| `g:vim_vue_plugin_has_init_indent` | Initially indent one tab inside `style/script` tags. | 0 for `.vue`. 1 for `.wpy` |
|
| `g:vim_vue_plugin_has_init_indent` | Initially indent one tab inside `style/script` tags. | 0 for `.vue`. 1 for `.wpy` |
|
||||||
| `g:vim_vue_plugin_highlight_vue_attr` | Highlight vue attribute value as expression instead of string. | 0 |
|
| `g:vim_vue_plugin_highlight_vue_attr` | Highlight vue attribute value as expression instead of string. | 0 |
|
||||||
| `g:vim_vue_plugin_use_foldexpr` | Enable builtin `foldexpr` foldmethod. | 0 |
|
| `g:vim_vue_plugin_use_foldexpr` | Enable builtin `foldexpr` foldmethod. | 0 |
|
||||||
@@ -149,3 +150,4 @@ This plugin is under [The Unlicense][8]. Other than this, `lib/indent/*` files a
|
|||||||
[13]: https://svelte.dev/
|
[13]: https://svelte.dev/
|
||||||
[14]: https://github.com/leafgarland/typescript-vim
|
[14]: https://github.com/leafgarland/typescript-vim
|
||||||
[15]: https://github.com/HerringtonDarkholme/yats.vim
|
[15]: https://github.com/HerringtonDarkholme/yats.vim
|
||||||
|
[16]: https://github.com/iloginow/vim-stylus
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ let s:use_pug = exists("g:vim_vue_plugin_use_pug")
|
|||||||
\ && g:vim_vue_plugin_use_pug == 1
|
\ && g:vim_vue_plugin_use_pug == 1
|
||||||
let s:use_sass = exists("g:vim_vue_plugin_use_sass")
|
let s:use_sass = exists("g:vim_vue_plugin_use_sass")
|
||||||
\ && g:vim_vue_plugin_use_sass == 1
|
\ && g:vim_vue_plugin_use_sass == 1
|
||||||
|
let s:use_stylus = exists("g:vim_vue_plugin_use_stylus")
|
||||||
|
\ && g:vim_vue_plugin_use_stylus == 1
|
||||||
let s:use_coffee = exists("g:vim_vue_plugin_use_coffee")
|
let s:use_coffee = exists("g:vim_vue_plugin_use_coffee")
|
||||||
\ && g:vim_vue_plugin_use_coffee == 1
|
\ && g:vim_vue_plugin_use_coffee == 1
|
||||||
let s:use_typescript = exists("g:vim_vue_plugin_use_typescript")
|
let s:use_typescript = exists("g:vim_vue_plugin_use_typescript")
|
||||||
@@ -82,6 +84,11 @@ if s:use_sass
|
|||||||
runtime! indent/sass.vim
|
runtime! indent/sass.vim
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if s:use_stylus
|
||||||
|
unlet! b:did_indent
|
||||||
|
runtime! indent/stylus.vim
|
||||||
|
endif
|
||||||
|
|
||||||
if s:use_coffee
|
if s:use_coffee
|
||||||
unlet! b:did_indent
|
unlet! b:did_indent
|
||||||
runtime! indent/coffee.vim
|
runtime! indent/coffee.vim
|
||||||
@@ -156,6 +163,9 @@ function! GetVueIndent()
|
|||||||
elseif s:SynSASS(cursyn)
|
elseif s:SynSASS(cursyn)
|
||||||
call vue#Log('syntax: sass')
|
call vue#Log('syntax: sass')
|
||||||
let ind = GetSassIndent()
|
let ind = GetSassIndent()
|
||||||
|
elseif s:SynStylus(cursyn)
|
||||||
|
call vue#Log('syntax: stylus')
|
||||||
|
let ind = GetStylusIndent()
|
||||||
elseif s:SynStyle(cursyn)
|
elseif s:SynStyle(cursyn)
|
||||||
call vue#Log('syntax: style')
|
call vue#Log('syntax: style')
|
||||||
let ind = GetCSSIndent()
|
let ind = GetCSSIndent()
|
||||||
@@ -218,6 +228,10 @@ function! s:SynSASS(syn)
|
|||||||
return a:syn ==? 'cssSassVueStyle'
|
return a:syn ==? 'cssSassVueStyle'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:SynStylus(syn)
|
||||||
|
return a:syn ==? 'cssStylusVueStyle'
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:SynStyle(syn)
|
function! s:SynStyle(syn)
|
||||||
return a:syn =~? 'VueStyle'
|
return a:syn =~? 'VueStyle'
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ let s:use_less = exists("g:vim_vue_plugin_use_less")
|
|||||||
\ && g:vim_vue_plugin_use_less == 1
|
\ && g:vim_vue_plugin_use_less == 1
|
||||||
let s:use_sass = exists("g:vim_vue_plugin_use_sass")
|
let s:use_sass = exists("g:vim_vue_plugin_use_sass")
|
||||||
\ && g:vim_vue_plugin_use_sass == 1
|
\ && g:vim_vue_plugin_use_sass == 1
|
||||||
|
let s:use_stylus = exists("g:vim_vue_plugin_use_stylus")
|
||||||
|
\ && g:vim_vue_plugin_use_stylus == 1
|
||||||
let s:use_coffee = exists("g:vim_vue_plugin_use_coffee")
|
let s:use_coffee = exists("g:vim_vue_plugin_use_coffee")
|
||||||
\ && g:vim_vue_plugin_use_coffee == 1
|
\ && g:vim_vue_plugin_use_coffee == 1
|
||||||
let s:use_typescript = exists("g:vim_vue_plugin_use_typescript")
|
let s:use_typescript = exists("g:vim_vue_plugin_use_typescript")
|
||||||
@@ -121,6 +123,12 @@ if s:use_sass
|
|||||||
runtime! after/syntax/sass.vim
|
runtime! after/syntax/sass.vim
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" If stylus is enabled, load stylus syntax
|
||||||
|
if s:use_stylus
|
||||||
|
call s:LoadSyntax('@StylusSyntax', 'stylus')
|
||||||
|
runtime! after/syntax/stylus.vim
|
||||||
|
endif
|
||||||
|
|
||||||
" If CoffeeScript is enabled, load the syntax. Keep name consistent with
|
" If CoffeeScript is enabled, load the syntax. Keep name consistent with
|
||||||
" vim-coffee-script/after/html.vim
|
" vim-coffee-script/after/html.vim
|
||||||
if s:use_coffee
|
if s:use_coffee
|
||||||
@@ -188,6 +196,10 @@ syntax region cssScssVueStyle fold
|
|||||||
\ start=+<style[^>]*lang=["']scss["'][^>]*>+
|
\ start=+<style[^>]*lang=["']scss["'][^>]*>+
|
||||||
\ end=+</style>+
|
\ end=+</style>+
|
||||||
\ keepend contains=@SassSyntax,vueTag
|
\ keepend contains=@SassSyntax,vueTag
|
||||||
|
syntax region cssStylusVueStyle fold
|
||||||
|
\ start=+<style[^>]*lang=["']stylus["'][^>]*>+
|
||||||
|
\ end=+</style>+
|
||||||
|
\ keepend contains=@StylusSyntax,vueTag
|
||||||
|
|
||||||
syntax region vueTag fold
|
syntax region vueTag fold
|
||||||
\ start=+^<[^/]+ end=+>+ skip=+></+
|
\ start=+^<[^/]+ end=+>+ skip=+></+
|
||||||
@@ -219,7 +231,7 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Style
|
" Style
|
||||||
" Redefine (less|sass)Definition to highlight <style> correctly and
|
" Redefine (less|sass|stylus)Definition to highlight <style> correctly and
|
||||||
" enable emmet-vim css type.
|
" enable emmet-vim css type.
|
||||||
if s:use_less
|
if s:use_less
|
||||||
silent! syntax clear lessDefinition
|
silent! syntax clear lessDefinition
|
||||||
@@ -233,6 +245,12 @@ if s:use_sass
|
|||||||
\ contained containedin=cssSassVueStyle,cssScssVueStyle
|
\ contained containedin=cssSassVueStyle,cssScssVueStyle
|
||||||
\ start="{" end="}"
|
\ start="{" end="}"
|
||||||
endif
|
endif
|
||||||
|
if s:use_stylus
|
||||||
|
silent! syntax clear stylusDefinition
|
||||||
|
syntax region cssStylusDefinition matchgroup=cssBraces contains=@StylusSyntax
|
||||||
|
\ contained containedin=cssStylusVueStyle
|
||||||
|
\ start="{" end="}"
|
||||||
|
endif
|
||||||
|
|
||||||
" Avoid css syntax interference
|
" Avoid css syntax interference
|
||||||
silent! syntax clear cssUnitDecorators
|
silent! syntax clear cssUnitDecorators
|
||||||
@@ -240,12 +258,12 @@ silent! syntax clear cssUnitDecorators
|
|||||||
syntax match cssUnitDecorators2
|
syntax match cssUnitDecorators2
|
||||||
\ /\(#\|-\|+\|%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|ch\|rem\|vh\|vw\|vmin\|vmax\|dpi\|dppx\|dpcm\|Hz\|kHz\|s\|ms\|deg\|grad\|rad\)\ze\(;\|$\)/
|
\ /\(#\|-\|+\|%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|ch\|rem\|vh\|vw\|vmin\|vmax\|dpi\|dppx\|dpcm\|Hz\|kHz\|s\|ms\|deg\|grad\|rad\)\ze\(;\|$\)/
|
||||||
\ contained
|
\ contained
|
||||||
\ containedin=cssAttrRegion,sassCssAttribute,lessCssAttribute
|
\ containedin=cssAttrRegion,sassCssAttribute,lessCssAttribute,stylusCssAttribute
|
||||||
|
|
||||||
silent! syntax clear cssKeyFrameProp
|
silent! syntax clear cssKeyFrameProp
|
||||||
syn match cssKeyFrameProp2 /\d*%\|from\|to/
|
syn match cssKeyFrameProp2 /\d*%\|from\|to/
|
||||||
\ contained nextgroup=cssDefinition
|
\ contained nextgroup=cssDefinition
|
||||||
\ containedin=cssAttrRegion,sassCssAttribute,lessCssAttribute
|
\ containedin=cssAttrRegion,sassCssAttribute,lessCssAttribute,stylusCssAttribute
|
||||||
|
|
||||||
" Coffee
|
" Coffee
|
||||||
if s:use_coffee
|
if s:use_coffee
|
||||||
@@ -284,6 +302,7 @@ syntax sync match styleHighlight groupthere cssVueStyle "<style"
|
|||||||
syntax sync match styleHighlight groupthere cssLessVueStyle "<style[^>]*lang=["']less["'][^>]*>"
|
syntax sync match styleHighlight groupthere cssLessVueStyle "<style[^>]*lang=["']less["'][^>]*>"
|
||||||
syntax sync match styleHighlight groupthere cssSassVueStyle "<style[^>]*lang=["']sass["'][^>]*>"
|
syntax sync match styleHighlight groupthere cssSassVueStyle "<style[^>]*lang=["']sass["'][^>]*>"
|
||||||
syntax sync match styleHighlight groupthere cssScssVueStyle "<style[^>]*lang=["']scss["'][^>]*>"
|
syntax sync match styleHighlight groupthere cssScssVueStyle "<style[^>]*lang=["']scss["'][^>]*>"
|
||||||
|
syntax sync match styleHighlight groupthere cssStylusVueStyle "<style[^>]*lang=["']stylus["'][^>]*>"
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
let b:current_syntax = 'vue'
|
let b:current_syntax = 'vue'
|
||||||
|
|||||||
Reference in New Issue
Block a user