1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-02 00:46:42 +03:00
kakoune/rc/filetype/conf.kak
Johannes Altmanninger 3a856ef57b rc conf: treat ini files as conf if they contain a #-comment
*.ini files traditionally use ; but for example the "foot" terminal's
foot.ini uses #. Add a hack to treat ini files as "conf" filetype
if they contain a #-comment (very slim chance of false positives).
This requires to explicitly set comment_line to the default #,
because we set the "ini" filetype earlier.
2022-02-19 17:31:55 +01:00

31 lines
841 B
Plaintext

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
}