summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2022-03-21 21:04:55 +1100
committerMaxime Coste <mawww@kakoune.org>2022-03-21 21:04:55 +1100
commiteae8ea8a548ef2bf9d02d542fe58b95dfce186a5 (patch)
tree2f1129c6be9f44e2040dd30ea95ab2baf3f51e7b
parent3667f8bb21c9dbca90e9894b313c3df4f865276c (diff)
parent3a856ef57b433e6c0f11247d2b2193cf782eb3be (diff)
Merge remote-tracking branch 'krobelus/ini-hash-comments'
-rw-r--r--rc/filetype/conf.kak30
-rw-r--r--rc/filetype/ini.kak2
-rw-r--r--rc/tools/comment.kak4
3 files changed, 35 insertions, 1 deletions
diff --git a/rc/filetype/conf.kak b/rc/filetype/conf.kak
new file mode 100644
index 00000000..9b715893
--- /dev/null
+++ b/rc/filetype/conf.kak
@@ -0,0 +1,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
+
+}
diff --git a/rc/filetype/ini.kak b/rc/filetype/ini.kak
index 1e922fdd..75762f6a 100644
--- a/rc/filetype/ini.kak
+++ b/rc/filetype/ini.kak
@@ -1,4 +1,4 @@
-hook global BufCreate .+\.(repo|ini|cfg|properties|desktop) %{
+hook global BufCreate .+\.ini %{
set-option buffer filetype ini
}
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 '/*'