Merge pull request #23 from adriaanzon/indent

Add indent and ftplugin files
This commit is contained in:
Eduardo San Martin Morote
2016-08-21 23:42:17 +02:00
committed by GitHub
2 changed files with 49 additions and 0 deletions

10
ftplugin/vue.vim Normal file
View File

@@ -0,0 +1,10 @@
" 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

39
indent/vue.vim Normal file
View File

@@ -0,0 +1,39 @@
" Vim indent file
" Language: Vue.js
" Maintainer: Eduardo San Martin Morote
" Author: Adriaan Zonnenberg
if exists("b:did_indent")
finish
endif
" Load indent files for required languages
for language in ['stylus', 'pug', 'css', 'javascript', 'html']
unlet! b:did_indent
exe "runtime! indent/".language.".vim"
exe "let s:".language."indent = &indentexpr"
endfor
let b:did_indent = 1
setlocal indentexpr=GetVueIndent()
if exists("*GetVueIndent")
finish
endif
function! GetVueIndent()
if searchpair('<template lang="pug"', '', '</template>', 'bWr')
exe "let indent = ".s:pugindent
elseif searchpair('<style lang="stylus"', '', '</style>', 'bWr')
exe "let indent = ".s:stylusindent
elseif searchpair('<style', '', '</style>', 'bWr')
exe "let indent = ".s:cssindent
elseif searchpair('<script', '', '</script>', 'bWr')
exe "let indent = ".s:javascriptindent
else
exe "let indent = ".s:htmlindent
endif
return indent > -1 ? indent : s:htmlindent
endfunction