mirror of
https://github.com/posva/vim-vue.git
synced 2025-12-08 02:14:43 +08:00
Merge pull request #23 from adriaanzon/indent
Add indent and ftplugin files
This commit is contained in:
10
ftplugin/vue.vim
Normal file
10
ftplugin/vue.vim
Normal 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
39
indent/vue.vim
Normal 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
|
||||
Reference in New Issue
Block a user