From df37195ea8d16f8b155d36e8d3cc90c74ab6e2a1 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Thu, 12 Jun 2025 18:30:52 -0400 Subject: [PATCH] AutoYADM commit: 2025-06-12 18:30:52 --- .config/kak/autoload/filetype/just.kak | 79 +++++++++++++++++++ .config/kak/autoload/stdlib/filetype/just.kak | 1 - 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 .config/kak/autoload/filetype/just.kak delete mode 120000 .config/kak/autoload/stdlib/filetype/just.kak diff --git a/.config/kak/autoload/filetype/just.kak b/.config/kak/autoload/filetype/just.kak new file mode 100644 index 00000000..b7f4b106 --- /dev/null +++ b/.config/kak/autoload/filetype/just.kak @@ -0,0 +1,79 @@ +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .*/?[jJ]ustfile %{ + set-option buffer filetype just +} + +hook global WinSetOption filetype=just %{ + require-module justfile + + hook window ModeChange pop:insert:.* -group justfile-trim-indent justfile-trim-indent + hook window InsertChar \n -group justfile-insert just-insert-on-new-line + hook window InsertChar \n -group justfile-indent just-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window justfile-.+ } +} + +hook -group justfile-highlight global WinSetOption filetype=just %{ + add-highlighter window/justfile ref justfile + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/justfile } +} + + +provide-module justfile %{ + +# Indentation +# ‾‾‾‾‾‾‾‾‾‾‾ + +define-command -hidden justfile-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys x + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + +define-command -hidden just-insert-on-new-line %{ + # copy '#' comment prefix and following white spaces + try %{ execute-keys -draft k x s ^\h*//\h* y jgh P } +} + +define-command -hidden just-indent-on-new-line %{ + evaluate-commands -draft -itersel %{ + # preserve previous line indent + try %{ execute-keys -draft K } + # cleanup trailing white spaces on previous line + try %{ execute-keys -draft kx s \h+$ "_d } + } +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +add-highlighter shared/justfile regions + +add-highlighter shared/justfile/content default-region group +add-highlighter shared/justfile/content/recipe regex '^@?([\w-]+)([^\n]*):(?!=)([^\n]*)' 1:function 2:meta 3:keyword +add-highlighter shared/justfile/content/assignments regex ^([\w-]+\h*:=\h*[^\n]*) 1:meta +add-highlighter shared/justfile/content/operator regex '((^@|:=|=|\+|\(|\)))' 1:operator +add-highlighter shared/justfile/content/strings regions +add-highlighter shared/justfile/content/strings/double region '"' (?