diff --git a/rc/filetype/fish.kak b/rc/filetype/fish.kak index 80c677b9..1946e889 100644 --- a/rc/filetype/fish.kak +++ b/rc/filetype/fish.kak @@ -15,6 +15,7 @@ hook global WinSetOption filetype=fish %{ require-module fish hook window InsertChar .* -group fish-indent fish-indent-on-char + hook window InsertChar \n -group fish-insert fish-insert-on-new-line hook window InsertChar \n -group fish-indent fish-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fish-.+ } @@ -64,10 +65,15 @@ define-command -hidden fish-indent-on-char %{ } } -define-command -hidden fish-indent-on-new-line %{ +define-command -hidden fish-insert-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*#\h* y jgh P } + } +} + +define-command -hidden fish-indent-on-new-line %{ + evaluate-commands -no-hooks -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line