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.
This commit is contained in:
Johannes Altmanninger 2022-02-09 16:13:29 +01:00
parent cc6fe5ae61
commit 3a856ef57b
2 changed files with 11 additions and 0 deletions

View File

@ -2,6 +2,13 @@ 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
}

View File

@ -45,6 +45,10 @@ hook global BufSetOption filetype=coffee %{
set-option buffer comment_block_end '###'
}
hook global BufSetOption filetype=conf %{
set-option buffer comment_line '#'
}
hook global BufSetOption filetype=css %{
set-option buffer comment_line ''
set-option buffer comment_block_begin '/*'