Squashed 'vim/bundle/vue/' content from commit e306929b2
git-subtree-dir: vim/bundle/vue git-subtree-split: e306929b27bea08ab505de7a4617e642b56b6dcd
commit
9a2a307086
@ -0,0 +1,2 @@
|
|||||||
|
FROM alpine:3.7
|
||||||
|
RUN apk add --no-cache make vim git
|
@ -0,0 +1,24 @@
|
|||||||
|
# posva/vim-make
|
||||||
|
|
||||||
|
Small docker image with vim, make and git
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd .circleci
|
||||||
|
docker rmi vim-make # remove old image
|
||||||
|
docker build -t vim-make .
|
||||||
|
docker run -it vim-make /bin/date
|
||||||
|
docker commit $(docker ps -lq) vim-make
|
||||||
|
docker push posva/vim-make:0.3 # replace the tag with a new one
|
||||||
|
docker container rm $(docker ps -lq) # remove container
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cleaning
|
||||||
|
|
||||||
|
To remove old images and containers, use `docker images` and `docker ps -a`.
|
||||||
|
Then remove them with `docker rmi <image>` and `docker container rm <container>`
|
||||||
|
|
||||||
|
## Update `config.yml`
|
||||||
|
|
||||||
|
Make sure to update the tag in the `image` section of `.config.yml`
|
@ -0,0 +1,15 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
docker:
|
||||||
|
- image: posva/vim-make:0.2
|
||||||
|
|
||||||
|
working_directory: ~/repo
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
|
||||||
|
- run: make dependencies
|
||||||
|
- run: make test
|
@ -0,0 +1 @@
|
|||||||
|
/pack
|
@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015 Evan Sheehan, Eduardo San Martin Morote
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
@ -0,0 +1,28 @@
|
|||||||
|
test: dependencies
|
||||||
|
vim -u test/vimrc -c 'Vader! test/*.vader'
|
||||||
|
|
||||||
|
test-nvim: dependencies
|
||||||
|
VADER_OUTPUT_FILE=/dev/stderr nvim -u test/vimrc -c 'Vader! test/*.vader' --headless
|
||||||
|
|
||||||
|
dependencies = \
|
||||||
|
'junegunn/vader.vim' \
|
||||||
|
'cakebaker/scss-syntax.vim' \
|
||||||
|
'digitaltoad/vim-pug' \
|
||||||
|
'groenewege/vim-less' \
|
||||||
|
'kchmck/vim-coffee-script' \
|
||||||
|
'leafgarland/typescript-vim' \
|
||||||
|
'slm-lang/vim-slm' \
|
||||||
|
'wavded/vim-stylus' \
|
||||||
|
'scrooloose/nerdcommenter'
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
test -L pack/testing/start/vim-vue && exit 0; \
|
||||||
|
mkdir -p pack/testing/start; \
|
||||||
|
cd pack/testing/start; \
|
||||||
|
for repo in $(dependencies); do git clone https://github.com/$$repo.git; done; \
|
||||||
|
ln -s ../../.. vim-vue
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf pack
|
||||||
|
|
||||||
|
.PHONY: test test-nvim dependencies clean
|
@ -0,0 +1 @@
|
|||||||
|
au BufNewFile,BufRead *.vue,*.wpy setf vue
|
@ -0,0 +1,19 @@
|
|||||||
|
" Vim filetype plugin
|
||||||
|
" Language: Vue.js
|
||||||
|
" Maintainer: Eduardo San Martin Morote
|
||||||
|
" Author: Adriaan Zonnenberg
|
||||||
|
|
||||||
|
if exists('b:did_ftplugin')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
runtime! ftplugin/html.vim
|
||||||
|
|
||||||
|
setlocal suffixesadd+=.vue
|
||||||
|
|
||||||
|
if !exists('g:no_plugin_maps') && !exists('g:no_vue_maps')
|
||||||
|
nnoremap <silent> <buffer> [[ :call search('^<\(template\<Bar>script\<Bar>style\)', 'bW')<CR>
|
||||||
|
nnoremap <silent> <buffer> ]] :call search('^<\(template\<Bar>script\<Bar>style\)', 'W')<CR>
|
||||||
|
nnoremap <silent> <buffer> [] :call search('^</\(template\<Bar>script\<Bar>style\)', 'bW')<CR>
|
||||||
|
nnoremap <silent> <buffer> ][ :call search('^</\(template\<Bar>script\<Bar>style\)', 'W')<CR>
|
||||||
|
endif
|
@ -0,0 +1,64 @@
|
|||||||
|
" Vim indent file
|
||||||
|
" Language: Vue.js
|
||||||
|
" Maintainer: Eduardo San Martin Morote
|
||||||
|
" Author: Adriaan Zonnenberg
|
||||||
|
|
||||||
|
if exists('b:did_indent')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! s:get_indentexpr(language)
|
||||||
|
unlet! b:did_indent
|
||||||
|
execute 'runtime! indent/' . a:language . '.vim'
|
||||||
|
return &indentexpr
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" The order is important here, tags without attributes go last.
|
||||||
|
" HTML is left out, it will be used when there is no match.
|
||||||
|
let s:languages = [
|
||||||
|
\ { 'name': 'pug', 'pairs': ['<template lang="pug"', '</template>'] },
|
||||||
|
\ { 'name': 'stylus', 'pairs': ['<style lang="stylus"', '</style>'] },
|
||||||
|
\ { 'name': 'css', 'pairs': ['<style', '</style>'] },
|
||||||
|
\ { 'name': 'coffee', 'pairs': ['<script lang="coffee"', '</script>'] },
|
||||||
|
\ { 'name': 'javascript', 'pairs': ['<script', '</script>'] },
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
for s:language in s:languages
|
||||||
|
" Set 'indentexpr' if the user has an indent file installed for the language
|
||||||
|
if strlen(globpath(&rtp, 'indent/'. s:language.name .'.vim'))
|
||||||
|
let s:language.indentexpr = s:get_indentexpr(s:language.name)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
let s:html_indent = s:get_indentexpr('html')
|
||||||
|
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
setlocal indentexpr=GetVueIndent()
|
||||||
|
|
||||||
|
if exists('*GetVueIndent')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! GetVueIndent()
|
||||||
|
for language in s:languages
|
||||||
|
let opening_tag_line = searchpair(language.pairs[0], '', language.pairs[1], 'bWr')
|
||||||
|
|
||||||
|
if opening_tag_line
|
||||||
|
execute 'let indent = ' . get(language, 'indentexpr', -1)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
if exists('l:indent')
|
||||||
|
if (opening_tag_line == prevnonblank(v:lnum - 1) || opening_tag_line == v:lnum)
|
||||||
|
\ || getline(v:lnum) =~ '\v^\s*\</(script|style|template)'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
" Couldn't find language, fall back to html
|
||||||
|
execute 'let indent = ' . s:html_indent
|
||||||
|
endif
|
||||||
|
|
||||||
|
return indent
|
||||||
|
endfunction
|
@ -0,0 +1,132 @@
|
|||||||
|
# vim-vue [![CircleCI](https://img.shields.io/circleci/project/github/posva/vim-vue.svg)](https://circleci.com/gh/posva/vim-vue)
|
||||||
|
|
||||||
|
Vim syntax highlighting for [Vue
|
||||||
|
components](https://vuejs.org/v2/guide/single-file-components.html).
|
||||||
|
|
||||||
|
This was initially forked from
|
||||||
|
[darthmall/vim-vue](https://github.com/darthmall/vim-vue). I already have an
|
||||||
|
implementation for this but found his code much cleaner. That's why I created a
|
||||||
|
new version instead of a PR.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Install with [Vundle](https://github.com/VundleVim/Vundle.vim)
|
||||||
|
|
||||||
|
```viml
|
||||||
|
Plugin 'posva/vim-vue'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install with [Pathogen](https://github.com/tpope/vim-pathogen)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~/.vim/bundle && \
|
||||||
|
git clone https://github.com/posva/vim-vue.git
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install without a plugin manager (Vim 8)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/posva/vim-vue.git ~/.vim/pack/plugins/start/vim-vue
|
||||||
|
```
|
||||||
|
|
||||||
|
### Integration with [Syntastic](https://github.com/scrooloose/syntastic) or [ALE](https://github.com/w0rp/ale)
|
||||||
|
|
||||||
|
Currently only `eslint` is available. Please make sure
|
||||||
|
[eslint](http://eslint.org/) and
|
||||||
|
[eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue) are installed
|
||||||
|
and properly [configured](https://github.com/vuejs/eslint-plugin-vue#rocket-usage):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm i -g eslint eslint-plugin-vue
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
If your language is not getting highlighted open an issue or a PR with the fix.
|
||||||
|
You only need to add a line to the `syntax/vue.vim` file.
|
||||||
|
|
||||||
|
Don't forget to write [Vader](https://github.com/junegunn/vader.vim) tests for
|
||||||
|
the code you write. You can run the tests by executing `make test` in the
|
||||||
|
terminal.
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
### Where is Jade?
|
||||||
|
|
||||||
|
[Jade has been renamed to pug](https://github.com/pugjs/jade/issues/2184).
|
||||||
|
Therefore you have to replace all your `jade` occurrences with `pug`. The new
|
||||||
|
plugin for `pug` can be found on [the same repository](https://github.com/digitaltoad/vim-pug)
|
||||||
|
(the name has already been updated).
|
||||||
|
|
||||||
|
### My syntax highlighting stops working randomly
|
||||||
|
|
||||||
|
This is because Vim tries to highlight text in an efficient way. Especially in
|
||||||
|
files that include multiple languages, it can get confused. To work around
|
||||||
|
this, you can run `:syntax sync fromstart` when it happens.
|
||||||
|
|
||||||
|
You can also setup an autocmd for this, so that every time a Vue file is
|
||||||
|
opened, `:syntax sync fromstart` will be executed pre-emptively:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
autocmd FileType vue syntax sync fromstart
|
||||||
|
```
|
||||||
|
|
||||||
|
See `:h :syn-sync-first` and [this article](http://vim.wikia.com/wiki/Fix_syntax_highlighting)
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
### How can I use existing configuration/plugins in Vue files?
|
||||||
|
|
||||||
|
If you already have some configuration for filetypes like html, css and
|
||||||
|
javascript (e.g. linters, completion), an easy way to use them in Vue files is
|
||||||
|
by setting compound filetypes like this:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html.javascript.css
|
||||||
|
```
|
||||||
|
|
||||||
|
:warning: This may cause problems, because some plugins will then treat the
|
||||||
|
whole buffer as html/javascript/css instead of only the part inside the tags.
|
||||||
|
Ideally, you should configure everything that you want to use in Vue files
|
||||||
|
individually.
|
||||||
|
|
||||||
|
### How to use commenting functionality with multiple languages in Vue files?
|
||||||
|
|
||||||
|
#### [caw.vim](https://github.com/tyru/caw.vim)
|
||||||
|
|
||||||
|
caw.vim features built-in support for file context through [context_filetype.vim](https://github.com/Shougo/context_filetype.vim). Just install both plugins and context-aware commenting will work in most files. The fenced code is detected by predefined regular expressions.
|
||||||
|
|
||||||
|
#### [NERDCommenter](https://github.com/scrooloose/nerdcommenter)
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>
|
||||||
|
To use NERDCommenter with Vue files, you can use its "hooks" feature to
|
||||||
|
temporarily change the filetype. <em>Click for an example.</em>
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
```vim
|
||||||
|
let g:ft = ''
|
||||||
|
function! NERDCommenter_before()
|
||||||
|
if &ft == 'vue'
|
||||||
|
let g:ft = 'vue'
|
||||||
|
let stack = synstack(line('.'), col('.'))
|
||||||
|
if len(stack) > 0
|
||||||
|
let syn = synIDattr((stack)[0], 'name')
|
||||||
|
if len(syn) > 0
|
||||||
|
exe 'setf ' . substitute(tolower(syn), '^vue_', '', '')
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
function! NERDCommenter_after()
|
||||||
|
if g:ft == 'vue'
|
||||||
|
setf vue
|
||||||
|
let g:ft = ''
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### _Vim slows down when using this plugin_ How can I fix that?
|
||||||
|
|
||||||
|
Add `let g:vue_disable_pre_processors=1` in your .vimrc to disable checking for prepocessors. When checking for preprocessor languages, multiple syntax highlighting checks are done, which can slow down vim. This variable prevents vim-vue from supporting **every** pre-processor language highlighting.
|
@ -0,0 +1,63 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
" Language: Vue.js
|
||||||
|
" Maintainer: Eduardo San Martin Morote
|
||||||
|
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
runtime! syntax/html.vim
|
||||||
|
syntax clear htmlTagName
|
||||||
|
syntax match htmlTagName contained "\<[a-zA-Z0-9:-]*\>"
|
||||||
|
unlet! b:current_syntax
|
||||||
|
|
||||||
|
""
|
||||||
|
" Get the pattern for a HTML {name} attribute with {value}.
|
||||||
|
function! s:attr(name, value)
|
||||||
|
return a:name . '=\("\|''\)[^\1]*' . a:value . '[^\1]*\1'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
""
|
||||||
|
" Check whether a syntax file for a given {language} exists.
|
||||||
|
function! s:syntax_available(language)
|
||||||
|
return !empty(globpath(&runtimepath, 'syntax/' . a:language . '.vim'))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
""
|
||||||
|
" Register {language} for a given {tag}. If [attr_override] is given and not
|
||||||
|
" empty, it will be used for the attribute pattern.
|
||||||
|
function! s:register_language(language, tag, ...)
|
||||||
|
let attr_override = a:0 ? a:1 : ''
|
||||||
|
let attr = !empty(attr_override) ? attr_override : s:attr('lang', a:language)
|
||||||
|
|
||||||
|
if s:syntax_available(a:language)
|
||||||
|
execute 'syntax include @' . a:language . ' syntax/' . a:language . '.vim'
|
||||||
|
unlet! b:current_syntax
|
||||||
|
execute 'syntax region vue_' . a:language
|
||||||
|
\ 'keepend'
|
||||||
|
\ 'start=/<' . a:tag . '\>\_[^>]*' . attr . '\_[^>]*>/'
|
||||||
|
\ 'end="</' . a:tag . '>"me=s-1'
|
||||||
|
\ 'contains=@' . a:language . ',vueSurroundingTag'
|
||||||
|
\ 'fold'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
if !exists("g:vue_disable_pre_processors") || !g:vue_disable_pre_processors
|
||||||
|
call s:register_language('less', 'style')
|
||||||
|
call s:register_language('pug', 'template', s:attr('lang', '\%(pug\|jade\)'))
|
||||||
|
call s:register_language('slm', 'template')
|
||||||
|
call s:register_language('handlebars', 'template')
|
||||||
|
call s:register_language('haml', 'template')
|
||||||
|
call s:register_language('typescript', 'script', '\%(lang=\("\|''\)[^\1]*\(ts\|typescript\)[^\1]*\1\|ts\)')
|
||||||
|
call s:register_language('coffee', 'script')
|
||||||
|
call s:register_language('stylus', 'style')
|
||||||
|
call s:register_language('sass', 'style')
|
||||||
|
call s:register_language('scss', 'style')
|
||||||
|
endif
|
||||||
|
|
||||||
|
syn region vueSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
|
||||||
|
syn keyword htmlSpecialTagName contained template
|
||||||
|
syn keyword htmlArg contained scoped ts
|
||||||
|
syn match htmlArg "[@v:][-:.0-9_a-z]*\>" contained
|
||||||
|
|
||||||
|
let b:current_syntax = "vue"
|
@ -0,0 +1,15 @@
|
|||||||
|
" Vue configuration for Syntastic
|
||||||
|
|
||||||
|
if exists('g:loaded_syntastic_vue_eslint_checker')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:loaded_syntastic_vue_eslint_checker = 1
|
||||||
|
|
||||||
|
runtime! syntax_checkers/javascript/eslint.vim
|
||||||
|
|
||||||
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||||
|
\ 'filetype': 'vue',
|
||||||
|
\ 'name': 'eslint',
|
||||||
|
\ 'redirect': 'javascript/eslint'
|
||||||
|
\ })
|
@ -0,0 +1,13 @@
|
|||||||
|
Given vue (Arbitrary HTML tag names):
|
||||||
|
<list></list>
|
||||||
|
<FormItem></FormItem>
|
||||||
|
<form-item><form-item>
|
||||||
|
<h1></h1>
|
||||||
|
<foo:bar></foo:bar>
|
||||||
|
|
||||||
|
Execute (The valid combinations get highlighted, since Vue does not enforce the W3C rules for custom tag names):
|
||||||
|
AssertEqual 'htmlTagName', SyntaxOf('list')
|
||||||
|
AssertEqual 'htmlTagName', SyntaxOf('FormItem')
|
||||||
|
AssertEqual 'htmlTagName', SyntaxOf('form-item')
|
||||||
|
AssertEqual 'htmlTagName', SyntaxOf('h1')
|
||||||
|
AssertEqual 'htmlTagName', SyntaxOf('foo:bar')
|
@ -0,0 +1,135 @@
|
|||||||
|
#
|
||||||
|
# HTML
|
||||||
|
#
|
||||||
|
Given vue (An unindented html template):
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Hello
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
Do (Indent the whole buffer):
|
||||||
|
gg=G
|
||||||
|
|
||||||
|
Expect (The html template got indented):
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Hello
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
Given vue (Template tag inside a template):
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<template v-if="loading">
|
||||||
|
Loading...
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
Do (Indent the whole buffer):
|
||||||
|
gg=G
|
||||||
|
|
||||||
|
Expect (It didn't get unindented):
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<template v-if="loading">
|
||||||
|
Loading...
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
#
|
||||||
|
# JavaScript
|
||||||
|
#
|
||||||
|
Given vue (An unindented JavaScript region):
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
foo() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
Do (Indent the whole buffer):
|
||||||
|
gg=G
|
||||||
|
|
||||||
|
Expect vue (The JavaScript region got indented):
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
foo() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
#
|
||||||
|
# CSS
|
||||||
|
#
|
||||||
|
Given vue (An unindented css region):
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: tomato;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Do (Indent the whole buffer):
|
||||||
|
gg=G
|
||||||
|
|
||||||
|
Expect vue (The css region got indented):
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: tomato;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Pug
|
||||||
|
#
|
||||||
|
Given vue (Empty Pug region):
|
||||||
|
<template lang="pug">
|
||||||
|
</template>
|
||||||
|
|
||||||
|
Do (Insert list items):
|
||||||
|
o
|
||||||
|
ul\<CR>
|
||||||
|
li Item A\<CR>
|
||||||
|
li Item B
|
||||||
|
|
||||||
|
Expect:
|
||||||
|
<template lang="pug">
|
||||||
|
ul
|
||||||
|
li Item A
|
||||||
|
li Item B
|
||||||
|
</template>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Stylus
|
||||||
|
#
|
||||||
|
Given vue (Empty Stylus region):
|
||||||
|
<style lang="stylus">
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Do (Insert some styles):
|
||||||
|
o
|
||||||
|
body\<CR>
|
||||||
|
font-size: 14px\<CR>
|
||||||
|
\<CR>\<C-d>
|
||||||
|
h1\<CR>
|
||||||
|
font-size: 30px\<CR>
|
||||||
|
display: block
|
||||||
|
|
||||||
|
Expect:
|
||||||
|
<style lang="stylus">
|
||||||
|
body
|
||||||
|
font-size: 14px
|
||||||
|
|
||||||
|
h1
|
||||||
|
font-size: 30px
|
||||||
|
display: block
|
||||||
|
</style>
|
@ -0,0 +1,40 @@
|
|||||||
|
Execute (Configure NERDCommenter to support Vue files):
|
||||||
|
let g:ft = ''
|
||||||
|
function! NERDCommenter_before()
|
||||||
|
if &ft == 'vue'
|
||||||
|
let g:ft = 'vue'
|
||||||
|
let stack = synstack(line('.'), col('.'))
|
||||||
|
if len(stack) > 0
|
||||||
|
let syn = synIDattr((stack)[0], 'name')
|
||||||
|
if len(syn) > 0
|
||||||
|
exe 'setf ' . substitute(tolower(syn), '^vue_', '', '')
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
function! NERDCommenter_after()
|
||||||
|
if g:ft == 'vue'
|
||||||
|
setf vue
|
||||||
|
let g:ft = ''
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
Given vue:
|
||||||
|
<template>
|
||||||
|
<div></div>
|
||||||
|
</template>
|
||||||
|
<style>
|
||||||
|
.glitters { color: gold }
|
||||||
|
<style>
|
||||||
|
|
||||||
|
Do:
|
||||||
|
j\cc
|
||||||
|
3j\cc
|
||||||
|
|
||||||
|
Expect:
|
||||||
|
<template>
|
||||||
|
<!--<div></div>-->
|
||||||
|
</template>
|
||||||
|
<style>
|
||||||
|
/*.glitters { color: gold }*/
|
||||||
|
<style>
|
@ -0,0 +1,183 @@
|
|||||||
|
#
|
||||||
|
# HTML
|
||||||
|
#
|
||||||
|
Given vue (HTML template without lang attribute):
|
||||||
|
<template>
|
||||||
|
<div></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'htmlTag', SyntaxAt(2, 3)
|
||||||
|
AssertEqual 'htmlTag', SyntaxAt(1, 1)
|
||||||
|
AssertEqual 'htmlSpecialTagName', SyntaxAt(1, 2)
|
||||||
|
|
||||||
|
|
||||||
|
Given vue (Template tag inside a template):
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<template v-if="loading">
|
||||||
|
Loading...
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
Execute (Syntax doesn't stop at the first closing template tag):
|
||||||
|
AssertEqual 'htmlEndTag', SyntaxAt(6, 3)
|
||||||
|
|
||||||
|
#
|
||||||
|
# JavaScript
|
||||||
|
#
|
||||||
|
Given vue:
|
||||||
|
<script>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'javaScriptLineComment', SyntaxAt(2, 1)
|
||||||
|
AssertEqual 'htmlScriptTag', SyntaxAt(1, 1)
|
||||||
|
|
||||||
|
|
||||||
|
Given vue (Script tag with misc. attributes and newline):
|
||||||
|
<script type="text/babel"
|
||||||
|
lang="babel"
|
||||||
|
>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'javaScriptLineComment', SyntaxAt(4, 1)
|
||||||
|
AssertEqual 'htmlArg', SyntaxAt(2, 9)
|
||||||
|
AssertEqual 'htmlScriptTag', SyntaxAt(1, 1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# CSS
|
||||||
|
#
|
||||||
|
Given vue (CSS region without lang attribute):
|
||||||
|
<style>
|
||||||
|
/**/
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'cssComment', SyntaxAt(2, 1)
|
||||||
|
AssertEqual 'htmlTag', SyntaxAt(1, 1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Pug
|
||||||
|
#
|
||||||
|
Given vue (Pug template):
|
||||||
|
<template lang="pug">
|
||||||
|
p #{name}'s Pug source code!
|
||||||
|
</template>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'htmlTagName', SyntaxAt(2, 1)
|
||||||
|
AssertEqual 'pugInterpolationDelimiter', SyntaxAt(2, 3)
|
||||||
|
AssertEqual 'vueSurroundingTag', SyntaxAt(1, 1)
|
||||||
|
|
||||||
|
|
||||||
|
Given vue (Pug template using their former name):
|
||||||
|
<template lang="jade">
|
||||||
|
p #{name}'s Pug source code!
|
||||||
|
</template>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'htmlTagName', SyntaxAt(2, 1)
|
||||||
|
AssertEqual 'pugInterpolationDelimiter', SyntaxAt(2, 3)
|
||||||
|
|
||||||
|
#
|
||||||
|
# SCSS
|
||||||
|
#
|
||||||
|
Given vue (SCSS region):
|
||||||
|
<style lang="scss">
|
||||||
|
$green: #42b983;
|
||||||
|
|
||||||
|
button {
|
||||||
|
background-color: $green;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'scssVariable', SyntaxOf('$green', 1)
|
||||||
|
AssertEqual 'scssVariable', SyntaxOf('$green', 2)
|
||||||
|
AssertEqual 'vueSurroundingTag', SyntaxAt(1, 1)
|
||||||
|
|
||||||
|
|
||||||
|
Given vue (SCSS region with newline after tag name):
|
||||||
|
<style
|
||||||
|
lang="scss"
|
||||||
|
>
|
||||||
|
$green: #42b983
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'scssVariable', SyntaxOf('$green')
|
||||||
|
AssertEqual 'vueSurroundingTag', SyntaxAt(1, 1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Sass
|
||||||
|
#
|
||||||
|
Given vue (Sass region):
|
||||||
|
<style lang="sass">
|
||||||
|
$green: #42b983
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'sassVariable', SyntaxAt(2, 1)
|
||||||
|
AssertEqual 'vueSurroundingTag', SyntaxAt(1, 1)
|
||||||
|
|
||||||
|
|
||||||
|
Given vue (Sass region with modifier):
|
||||||
|
<style lang="sass?indentedSyntax">
|
||||||
|
$green: #42b983
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'sassVariable', SyntaxAt(2, 1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Stylus
|
||||||
|
#
|
||||||
|
Given vue (Sass region):
|
||||||
|
<style lang="stylus">
|
||||||
|
@import 'variables'
|
||||||
|
|
||||||
|
body
|
||||||
|
font: 12px Helvetica, Arial, sans-serif
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'stylusImport', SyntaxAt(2, 1)
|
||||||
|
AssertEqual 'cssTagName', SyntaxAt(4, 1)
|
||||||
|
AssertEqual 'vueSurroundingTag', SyntaxAt(1, 1)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# TypeScript
|
||||||
|
#
|
||||||
|
Given vue (Typescript region using "ts" as name):
|
||||||
|
<script lang="ts">
|
||||||
|
@Component({})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'typescriptDecorators', SyntaxAt(2, 1)
|
||||||
|
AssertEqual 'vueSurroundingTag', SyntaxAt(1, 1)
|
||||||
|
|
||||||
|
|
||||||
|
Given vue (Typescript region using "typescript" as name):
|
||||||
|
<script lang="typescript">
|
||||||
|
@Component({})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'typescriptDecorators', SyntaxAt(2, 1)
|
||||||
|
|
||||||
|
|
||||||
|
Given vue (Typescript region using "ts" attribute):
|
||||||
|
<script ts>
|
||||||
|
@Component({})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'typescriptDecorators', SyntaxAt(2, 1)
|
||||||
|
AssertEqual 'htmlArg', SyntaxAt(1, 9)
|
@ -0,0 +1,13 @@
|
|||||||
|
set nocompatible
|
||||||
|
|
||||||
|
let &packpath = expand('<sfile>:p:h:h')
|
||||||
|
|
||||||
|
" Remove first and last entry from runtimepath, to prevent loading plugins from ~/.vim
|
||||||
|
let &runtimepath = substitute(&runtimepath, '\v^.{-},(.*),.*$', '\1', '')
|
||||||
|
|
||||||
|
filetype plugin indent on
|
||||||
|
syntax on
|
||||||
|
|
||||||
|
set expandtab
|
||||||
|
set shiftwidth=2
|
||||||
|
set softtabstop=2
|
Loading…
Reference in New Issue