Skip to content

Commit 9cbd83b

Browse files
committed
rc: Implement a Mako highlighter
1 parent 92706e6 commit 9cbd83b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

rc/mako.kak

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# https://docs.makotemplates.org/en/latest/syntax.html
2+
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
3+
4+
# Detection
5+
# ‾‾‾‾‾‾‾‾‾
6+
7+
hook global BufCreate .+\.mako %{
8+
set-option buffer filetype mako
9+
}
10+
11+
# Initialization
12+
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
13+
14+
hook global WinSetOption filetype=mako %{
15+
require-module html
16+
require-module python
17+
require-module mako
18+
19+
add-highlighter window/mako ref mako
20+
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/mako }
21+
}
22+
23+
provide-module mako %{
24+
25+
# Highlighters
26+
# ‾‾‾‾‾‾‾‾‾‾‾‾
27+
28+
add-highlighter shared/mako regions
29+
add-highlighter shared/mako/code default-region group
30+
add-highlighter shared/mako/code/ ref html
31+
32+
add-highlighter shared/mako/inline_python region '^\h*%(?!%)' $ group
33+
add-highlighter shared/mako/inline_python/ ref python
34+
add-highlighter shared/mako/inline_python/ regex ^\h*(%)\h*(?:(end(?:if|for)))? 1:meta 2:keyword
35+
36+
add-highlighter shared/mako/block_python region '^\h*<%$' '^%>\h*$' group
37+
add-highlighter shared/mako/block_python/ ref python
38+
add-highlighter shared/mako/block_python/ regex ^\h*(<%)|(%>)\h*$ 1:meta 2:meta
39+
40+
add-highlighter shared/mako/code/block_tags regex (</?%)(block|call|def|nsname|text)\b(>)? 1:meta 2:builtin 3:meta
41+
add-highlighter shared/mako/code/inline_tags regex (<%)(include|inherit|namespace|page)\b 1:meta 2:builtin
42+
43+
add-highlighter shared/mako/expression region '\$\{' '\}' group
44+
add-highlighter shared/mako/expression/ ref python
45+
add-highlighter shared/mako/expression/ regex \$\{|\} 0:value
46+
47+
add-highlighter shared/mako/block_comment region ^<%doc> </%doc>$ group
48+
add-highlighter shared/mako/block_comment/ fill documentation
49+
add-highlighter shared/mako/code/inline_comment regex ^\h*##[^\n]* 0:comment
50+
51+
}

0 commit comments

Comments
 (0)