summaryrefslogtreecommitdiffstats
path: root/indent/vue.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2017-02-02 21:49:51 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2017-02-02 21:49:51 +0100
commitcc868aee51c3880f08832cca0bf1351334d61794 (patch)
treee66ecd0ead35e53dd16283d6757410cd276bcb83 /indent/vue.vim
parent39036a553f353ffb70ec4ad25c0789567fb3518d (diff)
downloadvim-polyglot-cc868aee51c3880f08832cca0bf1351334d61794.tar.gz
vim-polyglot-cc868aee51c3880f08832cca0bf1351334d61794.zip
Add vue support, closes #160
Diffstat (limited to 'indent/vue.vim')
-rw-r--r--indent/vue.vim45
1 files changed, 45 insertions, 0 deletions
diff --git a/indent/vue.vim b/indent/vue.vim
new file mode 100644
index 00000000..e754ff6b
--- /dev/null
+++ b/indent/vue.vim
@@ -0,0 +1,45 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vue') == -1
+
+" 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', 'coffee']
+ 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 lang="coffee"', '', '</script>', 'bWr')
+ exe "let indent = ".s:coffeeindent
+ elseif searchpair('<script', '', '</script>', 'bWr')
+ exe "let indent = ".s:javascriptindent
+ else
+ exe "let indent = ".s:htmlindent
+ endif
+
+ return indent > -1 ? indent : s:htmlindent
+endfunction
+
+endif