diff options
| author | Maxime Coste <mawww@kakoune.org> | 2020-08-17 20:03:12 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2020-08-17 20:03:12 +1000 |
| commit | 4e4a65e9440cdf7164b7a73bdff50b6c641ac2f5 (patch) | |
| tree | 02c6b732cfa342b8e5048460189ab6f55aba7cfe | |
| parent | 83685501eab65f4cfc7783dcb075f0373db956c9 (diff) | |
| parent | e0c756d9430baee8f0d53a28cf4dfe87e922ac0f (diff) | |
Merge branch 'sh-insert' of http://github.com/SeerLite/kakoune
| -rw-r--r-- | rc/filetype/kakrc.kak | 8 | ||||
| -rw-r--r-- | rc/filetype/sh.kak | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/rc/filetype/kakrc.kak b/rc/filetype/kakrc.kak index bf59cdbf..0f766d73 100644 --- a/rc/filetype/kakrc.kak +++ b/rc/filetype/kakrc.kak @@ -16,6 +16,7 @@ hook global WinSetOption filetype=kak %~ set-option window static_words %opt{kak_static_words} + hook window InsertChar \n -group kak-insert kak-insert-on-new-line hook window InsertChar \n -group kak-indent kak-indent-on-new-line hook window InsertChar [>)}\]] -group kak-indent kak-indent-on-closing-matching hook window InsertChar (?![[{(<>)}\]])[^\s\w] -group kak-indent kak-indent-on-closing-char @@ -90,10 +91,15 @@ add-highlighter shared/kakrc/single_string/escape regex "''" 0:default+b # Commands # ‾‾‾‾‾‾‾‾ -define-command -hidden kak-indent-on-new-line %~ +define-command -hidden kak-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P } + = +~ + +define-command -hidden kak-indent-on-new-line %~ + evaluate-commands -draft -itersel %= # preserve previous line indent try %{ execute-keys -draft <semicolon> K <a-&> } # cleanup trailing whitespaces from previous line diff --git a/rc/filetype/sh.kak b/rc/filetype/sh.kak index 56511903..95e62c53 100644 --- a/rc/filetype/sh.kak +++ b/rc/filetype/sh.kak @@ -7,6 +7,7 @@ hook global WinSetOption filetype=sh %{ set-option window static_words %opt{sh_static_words} hook window ModeChange pop:insert:.* -group sh-trim-indent sh-trim-indent + hook window InsertChar \n -group sh-insert sh-insert-on-new-line hook window InsertChar \n -group sh-indent sh-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sh-.+ } } @@ -78,10 +79,15 @@ define-command -hidden sh-trim-indent %{ # Of necessity, this is also fairly opinionated about indentation styles. # Doing it "properly" would require far more context awareness than we can # bring to this kind of thing. -define-command -hidden sh-indent-on-new-line %[ +define-command -hidden sh-insert-on-new-line %[ evaluate-commands -draft -itersel %[ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } + ] +] + +define-command -hidden sh-indent-on-new-line %[ + evaluate-commands -draft -itersel %[ # preserve previous line indent try %{ execute-keys -draft <semicolon> K <a-&> } # filter previous line |
