# https://twig.symfony.com/doc/3.x/templates.html # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](twig) %{ set-option buffer filetype twig } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=twig %[ require-module twig hook window ModeChange pop:insert:.* -group twig-trim-indent twig-trim-indent hook window InsertChar \n -group twig-insert twig-insert-on-new-line hook window InsertChar \n -group twig-indent twig-indent-on-new-line hook window InsertChar '>' -group twig-indent twig-indent-on-greater-than hook window InsertChar '#' -group twig-auto-close twig-auto-close-delim hook window InsertChar '%' -group twig-auto-close twig-auto-close-delim set-option buffer extra_word_chars '_' '-' hook -once -always window WinSetOption filetype=.* %{ remove-hooks window twig-.+ } ] hook -group twig-highlight global WinSetOption filetype=twig %{ add-highlighter window/twig ref twig hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/twig } } provide-module twig %[ require-module html # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/twig regions add-highlighter shared/twig/core default-region group add-highlighter shared/twig/comment region \{# [#]\} fill comment add-highlighter shared/twig/delim region \{([%]-?|\{) (-?[%]|\})\} regions add-highlighter shared/twig/core/ ref html add-highlighter shared/twig/delim/base default-region group add-highlighter shared/twig/delim/double_string region '"' (?hH\h*\{lyp execute-keys hihi ] ] ] define-command -hidden twig-insert-on-new-line %[ evaluate-commands -draft -itersel %/ execute-keys try %[ execute-keys -draft kx^\h*\{\[%#\{\]\h+$ execute-keys -draft jghd ] / ] ]