vim-polyglot/ftplugin/twig.vim

45 lines
1.2 KiB
VimL
Raw Normal View History

if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'twig') == -1
2013-09-12 11:26:31 -04:00
" Vim filetype plugin
" Language: Twig
" Maintainer: F. Gabriel Gosselin <gabrielNOSPAM@evidens.ca>
if exists("b:did_ftplugin")
finish
endif
setlocal comments=s:{#,ex:#}
setlocal formatoptions+=tcqln
" setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+
2018-06-05 16:50:18 -04:00
if exists('b:match_words')
let b:twigMatchWords = [
\ ['block', 'endblock'],
\ ['for', 'endfor'],
\ ['macro', 'endmacro'],
\ ['if', 'elseif', 'else', 'endif'],
\ ['set', 'endset']
\]
for s:element in b:twigMatchWords
let s:pattern = ''
for s:tag in s:element[:-2]
if s:pattern != ''
let s:pattern .= ':'
endif
let s:pattern .= '{%\s*\<' . s:tag . '\>\s*\%(.*=\)\@![^}]\{-}%}'
endfor
let s:pattern .= ':{%\s*\<' . s:element[-1:][0] . '\>\s*.\{-}%}'
let b:match_words .= ',' . s:pattern
endfor
endif
2016-01-28 12:14:32 -05:00
if exists("b:did_ftplugin")
let b:undo_ftplugin .= "|setlocal comments< formatoptions<"
else
let b:undo_ftplugin = "setlocal comments< formatoptions<"
endif
2013-09-12 11:26:31 -04:00
" vim:set sw=2:
endif