mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-08 21:54:46 +08:00
Support fold-syntax foldmethod
This commit is contained in:
14
README.md
14
README.md
@@ -34,8 +34,8 @@ Supports
|
|||||||
- Vue directives.
|
- Vue directives.
|
||||||
- Pug with [vim-pug][4] (see Configuration).
|
- Pug with [vim-pug][4] (see Configuration).
|
||||||
- Less/Sass/Scss (see Configuration).
|
- Less/Sass/Scss (see Configuration).
|
||||||
- [vim-emmet][10] HTML/CSS/JavaScript filetype detection.
|
- A builtin 'expr' foldmethod (see Configuration).
|
||||||
- A builtin foldexpr fold method.
|
- [emmet-vim][10] HTML/CSS/JavaScript filetype detection.
|
||||||
- `.wpy` files from [WePY][6].
|
- `.wpy` files from [WePY][6].
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
@@ -54,12 +54,14 @@ Ex:
|
|||||||
| `g:vim_vue_plugin_use_sass` | Enable sass/scss syntax for `<style lang="sass">`(or scss). | 0 |
|
| `g:vim_vue_plugin_use_sass` | Enable sass/scss syntax for `<style lang="sass">`(or scss). | 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 fold method. | 1 |
|
| `g:vim_vue_plugin_use_foldexpr` | Enable builtin foldexpr fold method. | 0 |
|
||||||
| `g:vim_vue_plugin_debug` | Echo debug messages in `messages` list. Useful to debug if unexpected indents occur. | 0 |
|
| `g:vim_vue_plugin_debug` | Echo debug messages in `messages` list. Useful to debug if unexpected indents occur. | 0 |
|
||||||
|
|
||||||
\*: Vim may be slow if the feature is enabled. Find a balance between syntax highlight and speed. By the way, custom syntax could be added in `~/.vim/syntax` or `$VIM/vimfiles/syntax`.
|
\*: Vim may be slow if the feature is enabled. Find a balance between syntax highlight and speed. By the way, custom syntax could be added in `~/.vim/syntax` or `$VIM/vimfiles/syntax`.
|
||||||
|
|
||||||
**Note**: `filetype` used to be set to `javascript.vue`, which caused `javascript` syntax to be loaded multiple times and a significant delay. Now it is `vue` so autocmds and other settings for `javascript` have to be manually enabled for `vue`.
|
### Note
|
||||||
|
- `filetype` used to be set to `javascript.vue`, which caused `javascript` syntax to be loaded multiple times and a significant delay. Now it is `vue` so autocmds and other settings for `javascript` have to be manually enabled for `vue`.
|
||||||
|
- `g:vim_vue_plugin_use_foldexpr` default value used to be `1`, but there are other foldmethod choices. So it's changed to `0`.
|
||||||
|
|
||||||
## Screenshot
|
## Screenshot
|
||||||
|
|
||||||
@@ -89,9 +91,9 @@ function! InsertColon()
|
|||||||
endfunction
|
endfunction
|
||||||
```
|
```
|
||||||
|
|
||||||
### vim-emmet
|
### emmet-vim
|
||||||
|
|
||||||
Currently vim-emmet works regarding your HTML/CSS/JavaScript emmet settings, but it depends on how vim-emmet gets `filetype` and may change in the future. Feel free to report an issue if any problem appears.
|
Currently emmet-vim works regarding your HTML/CSS/JavaScript emmet settings, but it depends on how emmet-vim gets `filetype` and may change in the future. Feel free to report an issue if any problem appears.
|
||||||
|
|
||||||
## Acknowledgments & Refs
|
## Acknowledgments & Refs
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
" Config {{{
|
" Config {{{
|
||||||
"
|
"
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
let s:use_foldexpr = !exists("g:vim_vue_plugin_use_foldexpr")
|
let s:use_foldexpr = exists("g:vim_vue_plugin_use_foldexpr")
|
||||||
\ || g:vim_vue_plugin_use_foldexpr == 1
|
\ && g:vim_vue_plugin_use_foldexpr == 1
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
if !s:use_foldexpr | finish | endif
|
if !s:use_foldexpr | finish | endif
|
||||||
|
|||||||
@@ -141,40 +141,40 @@ syntax match htmlArg '\v<data(-[.a-z0-9]+)+>' containedin=@HTMLSyntax
|
|||||||
"
|
"
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" All start with html/javascript/css for vim-emmet type detection
|
" All start with html/javascript/css for vim-emmet type detection
|
||||||
syntax region htmlVueTemplate
|
syntax region htmlVueTemplate fold
|
||||||
\ start=+<template\(\s.\{-}\)\?>+
|
\ start=+<template\(\s.\{-}\)\?>+
|
||||||
\ end=+</template>\ze\n\(^$\n\)*<script>+
|
\ end=+</template>\ze\n\(^$\n\)*<script>+
|
||||||
\ keepend
|
\ keepend
|
||||||
\ contains=@HTMLSyntax
|
\ contains=@HTMLSyntax
|
||||||
syntax region htmlVueTemplate
|
syntax region htmlVueTemplate fold
|
||||||
\ start=+<template\(\s.\{-}\)\?>+
|
\ start=+<template\(\s.\{-}\)\?>+
|
||||||
\ end=+^</template>+
|
\ end=+^</template>+
|
||||||
\ keepend
|
\ keepend
|
||||||
\ contains=@HTMLSyntax
|
\ contains=@HTMLSyntax
|
||||||
|
|
||||||
syntax region pugVueTemplate
|
syntax region pugVueTemplate fold
|
||||||
\ start=+<template lang="pug"\(\s.\{-}\)\?>+
|
\ start=+<template lang="pug"\(\s.\{-}\)\?>+
|
||||||
\ end=+</template>+
|
\ end=+</template>+
|
||||||
\ keepend contains=@PugSyntax,vueTag
|
\ keepend contains=@PugSyntax,vueTag
|
||||||
|
|
||||||
syntax region javascriptVueScript
|
syntax region javascriptVueScript fold
|
||||||
\ start=+<script\(\s.\{-}\)\?>+
|
\ start=+<script\(\s.\{-}\)\?>+
|
||||||
\ end=+</script>+
|
\ end=+</script>+
|
||||||
\ keepend contains=@htmlJavaScript,jsImport,jsExport,vueTag
|
\ keepend contains=@htmlJavaScript,jsImport,jsExport,vueTag
|
||||||
|
|
||||||
syntax region cssVueStyle
|
syntax region cssVueStyle fold
|
||||||
\ start=+<style\(\s.\{-}\)\?>+
|
\ start=+<style\(\s.\{-}\)\?>+
|
||||||
\ end=+</style>+
|
\ end=+</style>+
|
||||||
\ keepend contains=@htmlCss,vueTag
|
\ keepend contains=@htmlCss,vueTag
|
||||||
syntax region cssLessVueStyle
|
syntax region cssLessVueStyle fold
|
||||||
\ start=+<style lang="less"\(\s.\{-}\)\?>+
|
\ start=+<style lang="less"\(\s.\{-}\)\?>+
|
||||||
\ end=+</style>+
|
\ end=+</style>+
|
||||||
\ keepend contains=@LessSyntax,vueTag
|
\ keepend contains=@LessSyntax,vueTag
|
||||||
syntax region cssSassVueStyle
|
syntax region cssSassVueStyle fold
|
||||||
\ start=+<style lang="sass"\(\s.\{-}\)\?>+
|
\ start=+<style lang="sass"\(\s.\{-}\)\?>+
|
||||||
\ end=+</style>+
|
\ end=+</style>+
|
||||||
\ keepend contains=@SassSyntax,vueTag
|
\ keepend contains=@SassSyntax,vueTag
|
||||||
syntax region cssScssVueStyle
|
syntax region cssScssVueStyle fold
|
||||||
\ start=+<style lang="scss"\(\s.\{-}\)\?>+
|
\ start=+<style lang="scss"\(\s.\{-}\)\?>+
|
||||||
\ end=+</style>+
|
\ end=+</style>+
|
||||||
\ keepend contains=@SassSyntax,vueTag
|
\ keepend contains=@SassSyntax,vueTag
|
||||||
|
|||||||
Reference in New Issue
Block a user