summaryrefslogblamecommitdiffstats
path: root/ftplugin/twig.vim
blob: 1380d1c3279d97e66fe6973c448c9f31841318ee (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
                                          

        
 







                                                            



                                                             




















                                                                             




                                                             

               
if has_key(g:polyglot_is_disabled, 'twig')
  finish
endif

" 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\\+

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

if exists("b:did_ftplugin")
  let b:undo_ftplugin .= "|setlocal comments< formatoptions<"
else
  let b:undo_ftplugin = "setlocal comments< formatoptions<"
endif

" vim:set sw=2: