From 904cec3c4a329cf89fc3219d359239910d61f3f6 Mon Sep 17 00:00:00 2001 From: thing1 Date: Tue, 28 Jan 2025 09:14:32 +0000 Subject: init commit --- autoload/filetype/tcl.kak | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 autoload/filetype/tcl.kak (limited to 'autoload/filetype/tcl.kak') diff --git a/autoload/filetype/tcl.kak b/autoload/filetype/tcl.kak new file mode 100644 index 0000000..5823eb5 --- /dev/null +++ b/autoload/filetype/tcl.kak @@ -0,0 +1,79 @@ +hook global BufCreate .*[.](tcl) %{ + set-option buffer filetype tcl +} + +hook global WinSetOption filetype=tcl %{ + require-module tcl + + hook window ModeChange pop:insert:.* -group tcl-trim-indent tcl-trim-indent + hook window InsertChar \n -group tcl-insert tcl-insert-on-new-line + hook window InsertChar \n -group tcl-indent tcl-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window tcl-.+ } +} + +hook -group tcl-highlight global WinSetOption filetype=tcl %{ + add-highlighter window/tcl ref tcl + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/tcl } +} + +# Using non-ascii characters here so that we can use the '[' command +provide-module tcl %§ + +add-highlighter shared/tcl regions +add-highlighter shared/tcl/code default-region group +add-highlighter shared/tcl/comment region (? d } +} + +define-command -hidden tcl-insert-on-new-line %[ + # Copy '#' comment prefix and following white spaces + try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } +] + +define-command -hidden tcl-indent-on-new-line %¶ + evaluate-commands -draft -itersel %@ + # Preserve previous line indent + try %{ execute-keys -draft K } + + # Filter previous line + try %{ execute-keys -draft k : tcl-trim-indent } + + # Indent after { + try %= execute-keys -draft , k x (\s|^)\{$ j = + @ +¶ +§ -- cgit v1.2.3