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.
|
||||
- Pug with [vim-pug][4] (see Configuration).
|
||||
- Less/Sass/Scss (see Configuration).
|
||||
- [vim-emmet][10] HTML/CSS/JavaScript filetype detection.
|
||||
- A builtin foldexpr fold method.
|
||||
- A builtin 'expr' foldmethod (see Configuration).
|
||||
- [emmet-vim][10] HTML/CSS/JavaScript filetype detection.
|
||||
- `.wpy` files from [WePY][6].
|
||||
|
||||
## 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_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_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 |
|
||||
|
||||
\*: 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
|
||||
|
||||
@@ -89,9 +91,9 @@ function! InsertColon()
|
||||
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
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
" Config {{{
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let s:use_foldexpr = !exists("g:vim_vue_plugin_use_foldexpr")
|
||||
\ || g:vim_vue_plugin_use_foldexpr == 1
|
||||
let s:use_foldexpr = exists("g:vim_vue_plugin_use_foldexpr")
|
||||
\ && g:vim_vue_plugin_use_foldexpr == 1
|
||||
"}}}
|
||||
|
||||
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
|
||||
syntax region htmlVueTemplate
|
||||
syntax region htmlVueTemplate fold
|
||||
\ start=+<template\(\s.\{-}\)\?>+
|
||||
\ end=+</template>\ze\n\(^$\n\)*<script>+
|
||||
\ keepend
|
||||
\ contains=@HTMLSyntax
|
||||
syntax region htmlVueTemplate
|
||||
syntax region htmlVueTemplate fold
|
||||
\ start=+<template\(\s.\{-}\)\?>+
|
||||
\ end=+^</template>+
|
||||
\ keepend
|
||||
\ contains=@HTMLSyntax
|
||||
|
||||
syntax region pugVueTemplate
|
||||
syntax region pugVueTemplate fold
|
||||
\ start=+<template lang="pug"\(\s.\{-}\)\?>+
|
||||
\ end=+</template>+
|
||||
\ keepend contains=@PugSyntax,vueTag
|
||||
|
||||
syntax region javascriptVueScript
|
||||
syntax region javascriptVueScript fold
|
||||
\ start=+<script\(\s.\{-}\)\?>+
|
||||
\ end=+</script>+
|
||||
\ keepend contains=@htmlJavaScript,jsImport,jsExport,vueTag
|
||||
|
||||
syntax region cssVueStyle
|
||||
syntax region cssVueStyle fold
|
||||
\ start=+<style\(\s.\{-}\)\?>+
|
||||
\ end=+</style>+
|
||||
\ keepend contains=@htmlCss,vueTag
|
||||
syntax region cssLessVueStyle
|
||||
syntax region cssLessVueStyle fold
|
||||
\ start=+<style lang="less"\(\s.\{-}\)\?>+
|
||||
\ end=+</style>+
|
||||
\ keepend contains=@LessSyntax,vueTag
|
||||
syntax region cssSassVueStyle
|
||||
syntax region cssSassVueStyle fold
|
||||
\ start=+<style lang="sass"\(\s.\{-}\)\?>+
|
||||
\ end=+</style>+
|
||||
\ keepend contains=@SassSyntax,vueTag
|
||||
syntax region cssScssVueStyle
|
||||
syntax region cssScssVueStyle fold
|
||||
\ start=+<style lang="scss"\(\s.\{-}\)\?>+
|
||||
\ end=+</style>+
|
||||
\ keepend contains=@SassSyntax,vueTag
|
||||
|
||||
Reference in New Issue
Block a user