@@ -72,7 +72,6 @@ color desert
7272" set cursorcolumn
7373set cursorline
7474set term = xterm
75- au FileType volt set ft = html
7675
7776" search
7877set incsearch
@@ -117,7 +116,7 @@ autocmd FileType ruby setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=12
117116autocmd FileType php setlocal tabstop = 4 shiftwidth = 4 softtabstop = 4 textwidth = 120
118117autocmd FileType coffee,javascript setlocal tabstop = 2 shiftwidth = 2 softtabstop = 2 textwidth = 120
119118autocmd 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
121120autocmd FileType sass,scss,css setlocal tabstop = 2 shiftwidth = 2 softtabstop = 2 textwidth = 120
122121
123122" syntax support
@@ -346,7 +345,16 @@ function! s:align()
346345endfunction
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