.vue support and highlighting
This commit is contained in:
parent
b6131e0868
commit
6e79c843b5
|
@ -149,7 +149,8 @@ hi! def link scssCondition CRCssAlt
|
||||||
|
|
||||||
" CSS definitions
|
" CSS definitions
|
||||||
hi! def link cssNoise CRNoise
|
hi! def link cssNoise CRNoise
|
||||||
hi! def link cssBraces CRNoise
|
hi! def link cssBraces CssNoise
|
||||||
|
hi! def link cssAttrComma CssNoise
|
||||||
|
|
||||||
hi! def link cssMediaKeyword CRScssMediaKeyword
|
hi! def link cssMediaKeyword CRScssMediaKeyword
|
||||||
hi! def link cssKeyFrameSelector scssSelectorName
|
hi! def link cssKeyFrameSelector scssSelectorName
|
||||||
|
@ -158,10 +159,13 @@ hi! def link cssStringQ CRCssBaseDark
|
||||||
hi! def link cssStringQQ cssStringQ
|
hi! def link cssStringQQ cssStringQ
|
||||||
|
|
||||||
hi! def link cssTagName CRCssSelectorBright
|
hi! def link cssTagName CRCssSelectorBright
|
||||||
|
hi! def link cssStyle CRCssAlt
|
||||||
hi! def link cssProp CRCssAlt
|
hi! def link cssProp CRCssAlt
|
||||||
hi! def link cssAttr scssAttribute
|
hi! def link cssAttr scssAttribute
|
||||||
|
hi! def link cssAttrRegion cssAttr
|
||||||
hi! def link cssPseudoClassId CRCssSelectorDark
|
hi! def link cssPseudoClassId CRCssSelectorDark
|
||||||
hi! def link cssMediaType CRCssSelectorDark
|
hi! def link cssMediaType CRCssSelectorDark
|
||||||
|
hi! def link cssVendor cssNoise
|
||||||
|
|
||||||
hi! def link CRCssValue CRCssBase
|
hi! def link CRCssValue CRCssBase
|
||||||
hi! def link cssColor CRCssBaseBright
|
hi! def link cssColor CRCssBaseBright
|
||||||
|
@ -180,6 +184,7 @@ hi! def link htmlTitle CRHtmlAlt
|
||||||
hi! def link htmlTag CRNoise
|
hi! def link htmlTag CRNoise
|
||||||
hi! def link htmlEndTag htmlTag
|
hi! def link htmlEndTag htmlTag
|
||||||
hi! def link htmlTagName CRHtmlBase
|
hi! def link htmlTagName CRHtmlBase
|
||||||
|
hi! def link htmlTagN CRHtmlBaseBright
|
||||||
hi! def link htmlSpecialTagName CRHtmlSpecial
|
hi! def link htmlSpecialTagName CRHtmlSpecial
|
||||||
hi! def link htmlArg CRHtmlBaseDark
|
hi! def link htmlArg CRHtmlBaseDark
|
||||||
hi! def link htmlScriptTag htmlArg
|
hi! def link htmlScriptTag htmlArg
|
||||||
|
@ -221,8 +226,10 @@ hi! def link jsVariableDef Identifier
|
||||||
hi! def link jsFuncCall Identifier
|
hi! def link jsFuncCall Identifier
|
||||||
hi! def link jsGlobalObjects IdentifierDark
|
hi! def link jsGlobalObjects IdentifierDark
|
||||||
hi! def link jsGlobalNodeObjects jsGlobalObjects
|
hi! def link jsGlobalNodeObjects jsGlobalObjects
|
||||||
|
hi! def link jsObject IdentifierBright
|
||||||
hi! def link jsObjectKey Identifier
|
hi! def link jsObjectKey Identifier
|
||||||
hi! def link jsObjectValue IdentifierDark
|
hi! def link jsObjectValue IdentifierDark
|
||||||
|
hi! def link jsModuleKeyword Identifier
|
||||||
|
|
||||||
" json definitions
|
" json definitions
|
||||||
hi! def link jsonKeyword Identifier
|
hi! def link jsonKeyword Identifier
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
" Vim syntax file
|
||||||
|
" Language: Vue.js
|
||||||
|
" Maintainer: Eduardo San Martin Morote
|
||||||
|
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
runtime! syntax/html_custom.vim
|
||||||
|
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('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')
|
||||||
|
call s:register_language('less', '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"
|
10
vimrc
10
vimrc
|
@ -67,6 +67,11 @@ Plugin 'shawncplus/phpcomplete.vim'
|
||||||
" https://github.com/joseluis/wordpress.vim-generator
|
" https://github.com/joseluis/wordpress.vim-generator
|
||||||
"Plugin 'dsawardekar/wordpress.vim'
|
"Plugin 'dsawardekar/wordpress.vim'
|
||||||
" disabled - doesn't support universal ctags?
|
" disabled - doesn't support universal ctags?
|
||||||
|
" vim-vue
|
||||||
|
" https://github.com/posva/vim-vue
|
||||||
|
Plugin 'posva/vim-vue'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" All of your Plugins must be added before the following line
|
" All of your Plugins must be added before the following line
|
||||||
call vundle#end() " required
|
call vundle#end() " required
|
||||||
|
@ -224,7 +229,7 @@ set showmode
|
||||||
" set custom syntax highlighting
|
" set custom syntax highlighting
|
||||||
autocmd BufNewFile,BufRead *.html set syntax=html_custom
|
autocmd BufNewFile,BufRead *.html set syntax=html_custom
|
||||||
autocmd BufNewFile,BufRead *.php set syntax=php_custom
|
autocmd BufNewFile,BufRead *.php set syntax=php_custom
|
||||||
|
autocmd BufNewFile,BufRead *.vue set syntax=vue_custom
|
||||||
|
|
||||||
" fix higlight problems such as vertical-align etc
|
" fix higlight problems such as vertical-align etc
|
||||||
augroup VimCSS3Syntax
|
augroup VimCSS3Syntax
|
||||||
|
@ -268,6 +273,9 @@ nnoremap <leader>p :echom SyntaxItem()<CR>
|
||||||
|
|
||||||
" plugins stuff
|
" plugins stuff
|
||||||
|
|
||||||
|
" vue-vim
|
||||||
|
" disable preprocessor checking for vue files - increases speed
|
||||||
|
let g:vue_disable_pre_processors=1
|
||||||
|
|
||||||
" MUcomplete
|
" MUcomplete
|
||||||
set completeopt+=menuone
|
set completeopt+=menuone
|
||||||
|
|
Loading…
Reference in New Issue