diff --git a/rc/filetype/coq.kak b/rc/filetype/coq.kak index 6fbc0998..5ef43c86 100644 --- a/rc/filetype/coq.kak +++ b/rc/filetype/coq.kak @@ -11,6 +11,7 @@ hook global BufCreate .*\.v %{ hook global WinSetOption filetype=coq %{ require-module coq + hook window ModeChange pop:insert:.* -group coq-trim-indent coq-trim-indent hook window InsertChar \n -group coq-indent coq-copy-indent-on-newline set-option window static_words %opt{coq_static_words} @@ -115,4 +116,12 @@ define-command -hidden coq-copy-indent-on-newline %{ } } +define-command -hidden coq-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + } diff --git a/rc/filetype/elvish.kak b/rc/filetype/elvish.kak index 29099c07..19d8d40d 100644 --- a/rc/filetype/elvish.kak +++ b/rc/filetype/elvish.kak @@ -7,6 +7,7 @@ hook global BufCreate .*\.elv %{ hook global WinSetOption filetype=elvish %< require-module elvish + hook window ModeChange pop:insert:.* -group elvish-trim-indent elvish-trim-indent hook window InsertChar \n -group elvish-insert elvish-indent hook window InsertChar [\]})] -group elvish-insert elvish-deindent hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elvish-.+ } @@ -36,6 +37,14 @@ add-highlighter shared/elvish/code/keyword_block regex \}\h+(elif|else|except|fi add-highlighter shared/elvish/code/metachar regex [*?|&\;<>()[\]{}] 0:operator +define-command -hidden elvish-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + define-command -hidden elvish-indent %< evaluate-commands -draft -itersel %< execute-keys try %< diff --git a/rc/filetype/fsharp.kak b/rc/filetype/fsharp.kak index f534c423..03aab385 100644 --- a/rc/filetype/fsharp.kak +++ b/rc/filetype/fsharp.kak @@ -15,6 +15,7 @@ hook global WinSetOption filetype=fsharp %{ require-module fsharp # indent on newline + hook window ModeChange pop:insert:.* -group fsharp-trim-indent fsharp-trim-indent hook window InsertChar \n -group fsharp-insert fsharp-insert-on-new-line hook window InsertChar \n -group fsharp-indent fsharp-indent-on-new-line @@ -125,6 +126,14 @@ add-highlighter shared/fsharp/code/ regex "\B(\(\))\B" 0:value # Commands # ‾‾‾‾‾‾‾‾ +define-command -hidden fsharp-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + define-command -hidden fsharp-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy // comments prefix and following white spaces diff --git a/rc/filetype/just.kak b/rc/filetype/just.kak index 70e2f72e..64a977ba 100644 --- a/rc/filetype/just.kak +++ b/rc/filetype/just.kak @@ -8,6 +8,7 @@ hook global BufCreate .*/?[jJ]ustfile %{ hook global WinSetOption filetype=justfile %{ require-module justfile + hook window ModeChange pop:insert:.* -group justfile-trim-indent justfile-trim-indent hook window InsertChar \n -group justfile-indent just-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window justfile-.+ } } @@ -23,6 +24,14 @@ provide-module justfile %{ # Indentation # ‾‾‾‾‾‾‾‾‾‾‾ +define-command -hidden justfile-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + define-command -hidden just-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent diff --git a/rc/filetype/makefile.kak b/rc/filetype/makefile.kak index ab752a3e..2026c745 100644 --- a/rc/filetype/makefile.kak +++ b/rc/filetype/makefile.kak @@ -13,6 +13,7 @@ hook global WinSetOption filetype=makefile %{ set-option window static_words %opt{makefile_static_words} + hook window ModeChange pop:insert:.* -group makefile-trim-indent makefile-trim-indent hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ } } @@ -50,6 +51,14 @@ evaluate-commands %sh{ # Commands # ‾‾‾‾‾‾‾‾ +define-command -hidden makefile-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + define-command -hidden makefile-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index 6a15e587..e5ed8d58 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -14,6 +14,7 @@ hook global BufCreate .*[.](markdown|md|mkd) %{ hook global WinSetOption filetype=markdown %{ require-module markdown + hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } @@ -99,6 +100,14 @@ add-highlighter shared/markdown/inline/text/ regex "\H( {2,})$" 1:+r@meta # Commands # ‾‾‾‾‾‾‾‾ +define-command -hidden markdown-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + define-command -hidden markdown-insert-on-new-line %{ try %{ execute-keys -draft -itersel k s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* y gh j P } } diff --git a/rc/filetype/pascal.kak b/rc/filetype/pascal.kak index 9d8267a4..8c70210b 100644 --- a/rc/filetype/pascal.kak +++ b/rc/filetype/pascal.kak @@ -14,6 +14,7 @@ hook global BufCreate .*\.(lpr|lfm)$ %{ hook global WinSetOption filetype=((free|object)?pascal|delphi) %[ require-module pascal + hook window ModeChange pop:insert:.* -group pascal-trim-indent pascal-trim-indent hook window InsertChar \n -group pascal-indent pascal-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pascal-.+ } set-option window static_words %opt{static_words} @@ -189,6 +190,14 @@ EOF done ¶ +define-command -hidden pascal-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + define-command -hidden pascal-indent-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # preserve previous line indent diff --git a/rc/filetype/protobuf.kak b/rc/filetype/protobuf.kak index 3d9c9fba..ba0c52a3 100644 --- a/rc/filetype/protobuf.kak +++ b/rc/filetype/protobuf.kak @@ -15,6 +15,7 @@ hook global WinSetOption filetype=protobuf %[ set-option window static_words %opt{protobuf_static_words} + hook window ModeChange pop:insert:.* -group protobuf-trim-indent protobuf-trim-indent hook -group protobuf-indent window InsertChar \n protobuf-indent-on-newline hook -group protobuf-indent window InsertChar \{ protobuf-indent-on-opening-curly-brace hook -group protobuf-indent window InsertChar \} protobuf-indent-on-closing-curly-brace @@ -66,6 +67,14 @@ evaluate-commands %sh{ # Commands # ‾‾‾‾‾‾‾‾ +define-command -hidden protobuf-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + define-command -hidden protobuf-indent-on-newline %~ evaluate-commands -draft -itersel %[ # preserve previous line indent diff --git a/rc/filetype/taskpaper.kak b/rc/filetype/taskpaper.kak index dc93b16f..94ab1b81 100644 --- a/rc/filetype/taskpaper.kak +++ b/rc/filetype/taskpaper.kak @@ -14,6 +14,7 @@ hook global BufCreate .*\.taskpaper %{ hook global WinSetOption filetype=taskpaper %{ require-module taskpaper + hook window ModeChange pop:insert:.* -group taskpaper-trim-indent taskpaper-trim-indent hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window taskpaper-.+ } } @@ -40,6 +41,14 @@ add-highlighter shared/taskpaper/ regex (([a-z]+://\S+)|((mailto:)[\w+-]+@\S+)) # Commands # ‾‾‾‾‾‾‾‾ +define-command -hidden taskpaper-trim-indent %{ + evaluate-commands -no-hooks -draft -itersel %{ + execute-keys + # remove trailing white spaces + try %{ execute-keys -draft s \h + $ d } + } +} + define-command -hidden taskpaper-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent