summaryrefslogtreecommitdiff
path: root/rc/filetype/protobuf.kak
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2022-05-08 15:01:25 +0200
committerJohannes Altmanninger <aclopte@gmail.com>2022-05-29 08:23:33 +0200
commit6f28178b91cbecd1bb8f92b9731c9e85c915abdf (patch)
treef933ec8e71aaf284677702f2ff441465fc986b9c /rc/filetype/protobuf.kak
parent19806a4b4c4480d3fb4421b9b77622a85d7f3b99 (diff)
rc filetype: add trim-indent hooks to all languages that have indent hooks
An indent hook automatically adds whitespace, so it seems prudent to add the hook to remove unwanted whitespace again. This is what we do in most languages already.
Diffstat (limited to 'rc/filetype/protobuf.kak')
-rw-r--r--rc/filetype/protobuf.kak9
1 files changed, 9 insertions, 0 deletions
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 <a-x>
+ # remove trailing white spaces
+ try %{ execute-keys -draft s \h + $ <ret> d }
+ }
+}
+
define-command -hidden protobuf-indent-on-newline %~
evaluate-commands -draft -itersel %[
# preserve previous line indent