forked from evidens/vim-twig
-
Notifications
You must be signed in to change notification settings - Fork 15
/
filetype.vim
34 lines (28 loc) · 826 Bytes
/
filetype.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
if exists("did_load_filetypes")
finish
endif
let g:vim_twig_filetype_detected = 1
augroup filetypedetect
au BufRead,BufNewFile *.twig call s:Setf(expand('<amatch>'))
augroup END
function! s:Setf(filename)
" Check verbose as in autoload/gzip.vim .
let prefix = (&verbose < 8) ? 'silent!' : ''
" Use the base filename to set the filetype, but save autocommands for
" later, so that we do not execute them twice.
let ei_save = &eventignore
set eventignore=FileType
try
let basefile = fnamemodify(a:filename, ':r')
execute prefix 'doau BufRead' basefile
finally
let &eventignore = ei_save
endtry
if !strlen(&ft)
" Default to HTML twig template.
let ft = 'html.twig'
else
let ft = &ft . (&ft =~ '\<twig\>' ? '' : '.twig')
endif
execute prefix 'set filetype=' . ft
endfun