summaryrefslogtreecommitdiff
path: root/autoload/filetype/conf.kak
blob: 9b715893e2befca78f058d811ded61b353d310d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
hook global BufCreate .+\.(repo|cfg|properties|desktop) %{
    set-option buffer filetype conf
}

hook global WinCreate .+\.ini %{
    try %{
        execute-keys /^\h*#<ret>
        set-option buffer filetype conf
    }
}

hook global WinSetOption filetype=conf %{
    require-module conf
}

hook -group conf-highlight global WinSetOption filetype=conf %{
    add-highlighter window/conf ref conf
    hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/conf }
}

provide-module conf %{

add-highlighter shared/conf regions
add-highlighter shared/conf/code default-region group
add-highlighter shared/conf/comment region '(^|\h)\K#' $ fill comment

add-highlighter shared/conf/code/ regex "(?S)^\h*(\[.+?\])\h*$" 1:title
add-highlighter shared/conf/code/ regex "^\h*([^\[][^=\n]*)=([^\n]*)" 1:variable 2:value

}