summaryrefslogtreecommitdiffstats
path: root/ftplugin/twig.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ftplugin/twig.vim')
-rw-r--r--ftplugin/twig.vim21
1 files changed, 21 insertions, 0 deletions
diff --git a/ftplugin/twig.vim b/ftplugin/twig.vim
index 8fa94a41..fc406dba 100644
--- a/ftplugin/twig.vim
+++ b/ftplugin/twig.vim
@@ -12,6 +12,27 @@ 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