summaryrefslogtreecommitdiff
path: root/rc/filetype/makefile.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/makefile.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/makefile.kak')
-rw-r--r--rc/filetype/makefile.kak9
1 files changed, 9 insertions, 0 deletions
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 <a-x>
+ # remove trailing white spaces
+ try %{ execute-keys -draft s \h + $ <ret> d }
+ }
+}
+
define-command -hidden makefile-indent-on-new-line %{
evaluate-commands -draft -itersel %{
# preserve previous line indent