From 3a856ef57b433e6c0f11247d2b2193cf782eb3be Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 9 Feb 2022 16:13:29 +0100 Subject: [PATCH] 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. --- rc/filetype/conf.kak | 7 +++++++ rc/tools/comment.kak | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/rc/filetype/conf.kak b/rc/filetype/conf.kak index 8288a0ba..9b715893 100644 --- a/rc/filetype/conf.kak +++ b/rc/filetype/conf.kak @@ -2,6 +2,13 @@ hook global BufCreate .+\.(repo|cfg|properties|desktop) %{ set-option buffer filetype conf } +hook global WinCreate .+\.ini %{ + try %{ + execute-keys /^\h*# + set-option buffer filetype conf + } +} + hook global WinSetOption filetype=conf %{ require-module conf } diff --git a/rc/tools/comment.kak b/rc/tools/comment.kak index 8d3ee798..1094fbba 100644 --- a/rc/tools/comment.kak +++ b/rc/tools/comment.kak @@ -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 '/*'