Skip to content

Commit f4bb44f

Browse files
fix
1 parent 1ceb581 commit f4bb44f

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

myVim/.vim/vimrc

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ color desert
7272
"set cursorcolumn
7373
set cursorline
7474
set term=xterm
75-
au FileType volt set ft=html
7675

7776
" search
7877
set incsearch
@@ -117,7 +116,7 @@ autocmd FileType ruby setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=12
117116
autocmd FileType php setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120
118117
autocmd FileType coffee,javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
119118
autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120
120-
autocmd FileType html,htmldjango,xhtml,haml setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=0
119+
autocmd FileType html,volt,htmldjango,xhtml,haml setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=0
121120
autocmd FileType sass,scss,css setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
122121

123122
" syntax support
@@ -346,7 +345,16 @@ function! s:align()
346345
endfunction
347346

348347
" 支持volt模板语法高亮
349-
au BufRead,BufNewFile *.twig,*.swig set filetype=htmljinja
350-
au BufNewFile,BufRead *.jinja set filetype=htmljinja
351-
au BufNewFile,BufRead *.jinja2 set filetype=htmljinja
352-
au BufNewFile,BufRead *.volt set filetype=htmljinja
348+
fun! s:SelectHTML()
349+
let n = 1
350+
while n < 50 && n < line("$")
351+
if getline(n) =~ '{%\s*\(extends\|block\|macro\|set\|if\|for\|include\|trans\)\>' " check for jinja
352+
set ft=jinja
353+
return
354+
endif
355+
let n = n + 1
356+
endwhile
357+
endfun
358+
autocmd BufNewFile,BufRead *.html,*.htm call s:SelectHTML()
359+
autocmd BufNewFile,BufRead *.j2,*.volt,*.jinja2,*.jinja set ft=jinja
360+

0 commit comments

Comments
 (0)