From 04005b06b07d9415cca3e9407dae06f7b667d144 Mon Sep 17 00:00:00 2001 From: Simon Fowler Date: Thu, 20 Jun 2019 11:19:39 +1000 Subject: [PATCH 1/4] Add support for basic auto-indenting of sh code. This attempts to support a simple formatting and intentation style for plain sh syntax (and other sh-compatible code which doesn't stray too far from portable sh). The complexity of sh syntax means that we have to be opinionated - attempting to be more flexible would require extensive context awareness, and would require something more akin to a proper autoformatting tool or a language server. The formatting style used here makes use of vertical whitespace as the primary delimiter, so that code ends up looking like this: if [ $foo = "bar" ]; then thing1 else thing2 fi for i in foo bar baz; do thing1 thing2 done case "$foo" in bar) thing1;; baz) thing1 thing2 ;; esac Since the formatting style used is very opinionated the 'sh_auto_indent' option can be used to disable auto-indentation, with the default set to 'no'. --- rc/filetype/sh.kak | 140 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/rc/filetype/sh.kak b/rc/filetype/sh.kak index ae09183f9..0b518fdba 100644 --- a/rc/filetype/sh.kak +++ b/rc/filetype/sh.kak @@ -5,6 +5,10 @@ hook global BufCreate .*\.(z|ba|c|k|mk)?sh(rc|_profile)? %{ hook global WinSetOption filetype=sh %{ require-module sh set-option window static_words %opt{sh_static_words} + + hook window ModeChange insert:.* -group sh-trim-indent sh-trim-indent + hook window InsertChar \n -group sh-indent maybe-sh-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sh-.+ } } hook -group sh-highlight global WinSetOption filetype=sh %{ @@ -14,6 +18,9 @@ hook -group sh-highlight global WinSetOption filetype=sh %{ provide-module sh %[ +declare-option -docstring "attempt to automatically indent shell code. Defaults to no." \ + bool sh_auto_indent no + add-highlighter shared/sh regions add-highlighter shared/sh/code default-region group add-highlighter shared/sh/double_string region %{(? s \h+$ d } +} + +# This is at best an approximation, since shell syntax is very complex. +# Also note that this targets plain sh syntax, not bash - bash adds a whole +# other level of complexity. If your bash code is fairly portable this will +# probably work. +# +# 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 %[ + evaluate-commands -draft -itersel %[ + # copy '#' comment prefix and following white spaces + try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } + # preserve previous line indent + try %{ execute-keys -draft \; K } + # filter previous line + try %{ execute-keys -draft k : sh-trim-indent } + + # Indent loop syntax, e.g.: + # for foo in bar; do + # things + # done + # + # or: + # + # while foo; do + # things + # done + # + # or equivalently: + # + # while foo + # do + # things + # done + # + # indent after do + try %{ execute-keys -draft k do$ j } + # deindent after done + try %{ execute-keys -draft k done$ j K } + + # Indent if/then/else syntax, e.g.: + # if [ $foo = $bar ]; then + # things + # else + # other_things + # fi + # + # or equivalently: + # if [ $foo = $bar ] + # then + # things + # else + # other_things + # fi + # + # indent after then + try %{ execute-keys -draft k then$ j } + # deindent after fi + try %{ execute-keys -draft k fi$ j K } + # deindent and reindent after else - deindent the else, then back + # down and return to the previous indent level. + try %{ execute-keys -draft k else$ j } + + # Indent case syntax, e.g.: + # case "$foo" in + # bar) thing1;; + # baz) + # things + # ;; + # *) + # default_things + # ;; + # esac + # + # or equivalently: + # case "$foo" + # in + # bar) thing1;; + # esac + # + # indent after in + try %{ execute-keys -draft k in$ j } + # deindent after esac + try %{ execute-keys -draft k esac$ j K } + # indent after ) + try %{ execute-keys -draft k ^\s*\(?[^(]+[^)]\)$ j } + # deindent after ;; + try %{ execute-keys -draft k ^\s*\;\;$ j } + + # Indent compound commands as logical blocks, e.g.: + # { + # thing1 + # thing2 + # } + # + # or in a function definition: + # foo () { + # thing1 + # thing2 + # } + # + # We don't handle () delimited compond commands - these are technically very + # similar, but the use cases are quite different and much less common. + # + # Note that in this context the '{' and '}' characters are reserved + # words, and hence must be surrounded by a token separator - typically + # white space (including a newline), though technically it can also be + # ';'. Only vertical white space makes sense in this context, though, + # since the syntax denotes a logical block, not a simple compound command. + try %= execute-keys -draft k (\s|^)\{$ j = + # deindent closing } + try %= execute-keys -draft k ^\s*\}$ j K = + + ] +] + ] From ba75289eb59c55c96fbebe06cb7d7d3c2788b2da Mon Sep 17 00:00:00 2001 From: Simon Fowler Date: Fri, 24 May 2019 21:27:30 +1000 Subject: [PATCH 2/4] Simon Fowler Copyright Waiver. I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. From b2459f5ecbef3706c6a36c408453d5cacf31043f Mon Sep 17 00:00:00 2001 From: Simon Fowler Date: Sat, 29 Jun 2019 12:34:14 +1000 Subject: [PATCH 3/4] Remove the sh_auto_indent option. We now auto indent by default, with the option to disable it handled by the `diabled_hooks` mechanism. --- rc/filetype/sh.kak | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/rc/filetype/sh.kak b/rc/filetype/sh.kak index 0b518fdba..a48e6d29f 100644 --- a/rc/filetype/sh.kak +++ b/rc/filetype/sh.kak @@ -7,7 +7,7 @@ hook global WinSetOption filetype=sh %{ set-option window static_words %opt{sh_static_words} hook window ModeChange insert:.* -group sh-trim-indent sh-trim-indent - hook window InsertChar \n -group sh-indent maybe-sh-indent-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-.+ } } @@ -18,9 +18,6 @@ hook -group sh-highlight global WinSetOption filetype=sh %{ provide-module sh %[ -declare-option -docstring "attempt to automatically indent shell code. Defaults to no." \ - bool sh_auto_indent no - add-highlighter shared/sh regions add-highlighter shared/sh/code default-region group add-highlighter shared/sh/double_string region %{(? s \h+$ d } From c5dd01323507a6baceaf44471cccdcecb45ac83a Mon Sep 17 00:00:00 2001 From: Simon Fowler Date: Sun, 30 Jun 2019 12:57:59 +1000 Subject: [PATCH 4/4] Add tests. Probably overkill, but at least this is comprehensive . . . --- test/indent/sh/deindent-after-done/cmd | 1 + test/indent/sh/deindent-after-done/in | 3 +++ test/indent/sh/deindent-after-done/out | 4 ++++ test/indent/sh/deindent-after-done/rc | 3 +++ test/indent/sh/deindent-after-esac/in | 5 +++++ test/indent/sh/deindent-after-esac/out | 6 ++++++ test/indent/sh/deindent-after-esac/rc | 3 +++ test/indent/sh/deindent-after-fi/cmd | 1 + test/indent/sh/deindent-after-fi/in | 2 ++ test/indent/sh/deindent-after-fi/out | 4 ++++ test/indent/sh/deindent-after-fi/rc | 3 +++ test/indent/sh/deindent-case-option/cmd | 1 + test/indent/sh/deindent-case-option/in | 5 +++++ test/indent/sh/deindent-case-option/out | 7 +++++++ test/indent/sh/deindent-case-option/rc | 3 +++ test/indent/sh/deindent-compound-command/cmd | 1 + test/indent/sh/deindent-compound-command/in | 3 +++ test/indent/sh/deindent-compound-command/out | 4 ++++ test/indent/sh/deindent-compound-command/rc | 3 +++ test/indent/sh/deindent-one-line-case-option/cmd | 1 + test/indent/sh/deindent-one-line-case-option/in | 2 ++ test/indent/sh/deindent-one-line-case-option/out | 3 +++ test/indent/sh/deindent-one-line-case-option/rc | 3 +++ test/indent/sh/deindent-only-else/cmd | 1 + test/indent/sh/deindent-only-else/in | 3 +++ test/indent/sh/deindent-only-else/out | 4 ++++ test/indent/sh/deindent-only-else/rc | 3 +++ test/indent/sh/indent-after-do/cmd | 1 + test/indent/sh/indent-after-do/in | 1 + test/indent/sh/indent-after-do/out | 2 ++ test/indent/sh/indent-after-do/rc | 3 +++ test/indent/sh/indent-after-in/cmd | 1 + test/indent/sh/indent-after-in/in | 1 + test/indent/sh/indent-after-in/out | 2 ++ test/indent/sh/indent-after-in/rc | 3 +++ test/indent/sh/indent-after-then/cmd | 1 + test/indent/sh/indent-after-then/in | 1 + test/indent/sh/indent-after-then/out | 2 ++ test/indent/sh/indent-after-then/rc | 3 +++ test/indent/sh/indent-block-case/cmd | 1 + test/indent/sh/indent-block-case/in | 3 +++ test/indent/sh/indent-block-case/out | 5 +++++ test/indent/sh/indent-block-case/rc | 3 +++ test/indent/sh/indent-compound-command/cmd | 1 + test/indent/sh/indent-compound-command/in | 1 + test/indent/sh/indent-compound-command/out | 2 ++ test/indent/sh/indent-compound-command/rc | 3 +++ 47 files changed, 122 insertions(+) create mode 100644 test/indent/sh/deindent-after-done/cmd create mode 100644 test/indent/sh/deindent-after-done/in create mode 100644 test/indent/sh/deindent-after-done/out create mode 100644 test/indent/sh/deindent-after-done/rc create mode 100644 test/indent/sh/deindent-after-esac/in create mode 100644 test/indent/sh/deindent-after-esac/out create mode 100644 test/indent/sh/deindent-after-esac/rc create mode 100644 test/indent/sh/deindent-after-fi/cmd create mode 100644 test/indent/sh/deindent-after-fi/in create mode 100644 test/indent/sh/deindent-after-fi/out create mode 100644 test/indent/sh/deindent-after-fi/rc create mode 100644 test/indent/sh/deindent-case-option/cmd create mode 100644 test/indent/sh/deindent-case-option/in create mode 100644 test/indent/sh/deindent-case-option/out create mode 100644 test/indent/sh/deindent-case-option/rc create mode 100644 test/indent/sh/deindent-compound-command/cmd create mode 100644 test/indent/sh/deindent-compound-command/in create mode 100644 test/indent/sh/deindent-compound-command/out create mode 100644 test/indent/sh/deindent-compound-command/rc create mode 100644 test/indent/sh/deindent-one-line-case-option/cmd create mode 100644 test/indent/sh/deindent-one-line-case-option/in create mode 100644 test/indent/sh/deindent-one-line-case-option/out create mode 100644 test/indent/sh/deindent-one-line-case-option/rc create mode 100644 test/indent/sh/deindent-only-else/cmd create mode 100644 test/indent/sh/deindent-only-else/in create mode 100644 test/indent/sh/deindent-only-else/out create mode 100644 test/indent/sh/deindent-only-else/rc create mode 100644 test/indent/sh/indent-after-do/cmd create mode 100644 test/indent/sh/indent-after-do/in create mode 100644 test/indent/sh/indent-after-do/out create mode 100644 test/indent/sh/indent-after-do/rc create mode 100644 test/indent/sh/indent-after-in/cmd create mode 100644 test/indent/sh/indent-after-in/in create mode 100644 test/indent/sh/indent-after-in/out create mode 100644 test/indent/sh/indent-after-in/rc create mode 100644 test/indent/sh/indent-after-then/cmd create mode 100644 test/indent/sh/indent-after-then/in create mode 100644 test/indent/sh/indent-after-then/out create mode 100644 test/indent/sh/indent-after-then/rc create mode 100644 test/indent/sh/indent-block-case/cmd create mode 100644 test/indent/sh/indent-block-case/in create mode 100644 test/indent/sh/indent-block-case/out create mode 100644 test/indent/sh/indent-block-case/rc create mode 100644 test/indent/sh/indent-compound-command/cmd create mode 100644 test/indent/sh/indent-compound-command/in create mode 100644 test/indent/sh/indent-compound-command/out create mode 100644 test/indent/sh/indent-compound-command/rc diff --git a/test/indent/sh/deindent-after-done/cmd b/test/indent/sh/deindent-after-done/cmd new file mode 100644 index 000000000..2bc67f432 --- /dev/null +++ b/test/indent/sh/deindent-after-done/cmd @@ -0,0 +1 @@ +gei diff --git a/test/indent/sh/deindent-after-done/in b/test/indent/sh/deindent-after-done/in new file mode 100644 index 000000000..aba228048 --- /dev/null +++ b/test/indent/sh/deindent-after-done/in @@ -0,0 +1,3 @@ +while true; do + thing1 + done diff --git a/test/indent/sh/deindent-after-done/out b/test/indent/sh/deindent-after-done/out new file mode 100644 index 000000000..029beac98 --- /dev/null +++ b/test/indent/sh/deindent-after-done/out @@ -0,0 +1,4 @@ +while true; do + thing1 +done + diff --git a/test/indent/sh/deindent-after-done/rc b/test/indent/sh/deindent-after-done/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/deindent-after-done/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/deindent-after-esac/in b/test/indent/sh/deindent-after-esac/in new file mode 100644 index 000000000..0264f1733 --- /dev/null +++ b/test/indent/sh/deindent-after-esac/in @@ -0,0 +1,5 @@ +case $foo in + bar) + thing1 + thing2 + ;; diff --git a/test/indent/sh/deindent-after-esac/out b/test/indent/sh/deindent-after-esac/out new file mode 100644 index 000000000..391200395 --- /dev/null +++ b/test/indent/sh/deindent-after-esac/out @@ -0,0 +1,6 @@ +case $foo in + bar) + thing1 + thing2 + ;; +esac diff --git a/test/indent/sh/deindent-after-esac/rc b/test/indent/sh/deindent-after-esac/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/deindent-after-esac/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/deindent-after-fi/cmd b/test/indent/sh/deindent-after-fi/cmd new file mode 100644 index 000000000..edb2652bb --- /dev/null +++ b/test/indent/sh/deindent-after-fi/cmd @@ -0,0 +1 @@ +geifi diff --git a/test/indent/sh/deindent-after-fi/in b/test/indent/sh/deindent-after-fi/in new file mode 100644 index 000000000..060389abf --- /dev/null +++ b/test/indent/sh/deindent-after-fi/in @@ -0,0 +1,2 @@ +if [ $foo ]; then + thing1 diff --git a/test/indent/sh/deindent-after-fi/out b/test/indent/sh/deindent-after-fi/out new file mode 100644 index 000000000..6df449ca1 --- /dev/null +++ b/test/indent/sh/deindent-after-fi/out @@ -0,0 +1,4 @@ +if [ $foo ]; then + thing1 +fi + diff --git a/test/indent/sh/deindent-after-fi/rc b/test/indent/sh/deindent-after-fi/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/deindent-after-fi/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/deindent-case-option/cmd b/test/indent/sh/deindent-case-option/cmd new file mode 100644 index 000000000..1a5f223e3 --- /dev/null +++ b/test/indent/sh/deindent-case-option/cmd @@ -0,0 +1 @@ +gei;;*) diff --git a/test/indent/sh/deindent-case-option/in b/test/indent/sh/deindent-case-option/in new file mode 100644 index 000000000..06c64dac9 --- /dev/null +++ b/test/indent/sh/deindent-case-option/in @@ -0,0 +1,5 @@ +case $foo in + bar) thing1;; + baz) + thing1 + thing2 diff --git a/test/indent/sh/deindent-case-option/out b/test/indent/sh/deindent-case-option/out new file mode 100644 index 000000000..7d9a6fa69 --- /dev/null +++ b/test/indent/sh/deindent-case-option/out @@ -0,0 +1,7 @@ +case $foo in + bar) thing1;; + baz) + thing1 + thing2 + ;; + *) diff --git a/test/indent/sh/deindent-case-option/rc b/test/indent/sh/deindent-case-option/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/deindent-case-option/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/deindent-compound-command/cmd b/test/indent/sh/deindent-compound-command/cmd new file mode 100644 index 000000000..2bc67f432 --- /dev/null +++ b/test/indent/sh/deindent-compound-command/cmd @@ -0,0 +1 @@ +gei diff --git a/test/indent/sh/deindent-compound-command/in b/test/indent/sh/deindent-compound-command/in new file mode 100644 index 000000000..a82d0f494 --- /dev/null +++ b/test/indent/sh/deindent-compound-command/in @@ -0,0 +1,3 @@ +foo () { + thing1 + } diff --git a/test/indent/sh/deindent-compound-command/out b/test/indent/sh/deindent-compound-command/out new file mode 100644 index 000000000..70841a6b3 --- /dev/null +++ b/test/indent/sh/deindent-compound-command/out @@ -0,0 +1,4 @@ +foo () { + thing1 +} + diff --git a/test/indent/sh/deindent-compound-command/rc b/test/indent/sh/deindent-compound-command/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/deindent-compound-command/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/deindent-one-line-case-option/cmd b/test/indent/sh/deindent-one-line-case-option/cmd new file mode 100644 index 000000000..22e452950 --- /dev/null +++ b/test/indent/sh/deindent-one-line-case-option/cmd @@ -0,0 +1 @@ +geibaz) diff --git a/test/indent/sh/deindent-one-line-case-option/in b/test/indent/sh/deindent-one-line-case-option/in new file mode 100644 index 000000000..08e8d55b5 --- /dev/null +++ b/test/indent/sh/deindent-one-line-case-option/in @@ -0,0 +1,2 @@ +case $foo in + bar) thing1;; diff --git a/test/indent/sh/deindent-one-line-case-option/out b/test/indent/sh/deindent-one-line-case-option/out new file mode 100644 index 000000000..b0d854a5c --- /dev/null +++ b/test/indent/sh/deindent-one-line-case-option/out @@ -0,0 +1,3 @@ +case $foo in + bar) thing1;; + baz) diff --git a/test/indent/sh/deindent-one-line-case-option/rc b/test/indent/sh/deindent-one-line-case-option/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/deindent-one-line-case-option/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/deindent-only-else/cmd b/test/indent/sh/deindent-only-else/cmd new file mode 100644 index 000000000..d6c743f9c --- /dev/null +++ b/test/indent/sh/deindent-only-else/cmd @@ -0,0 +1 @@ +geibaz diff --git a/test/indent/sh/deindent-only-else/in b/test/indent/sh/deindent-only-else/in new file mode 100644 index 000000000..8b287fd40 --- /dev/null +++ b/test/indent/sh/deindent-only-else/in @@ -0,0 +1,3 @@ +if [ $foo ]; then + bar + else diff --git a/test/indent/sh/deindent-only-else/out b/test/indent/sh/deindent-only-else/out new file mode 100644 index 000000000..75d8b0fa8 --- /dev/null +++ b/test/indent/sh/deindent-only-else/out @@ -0,0 +1,4 @@ +if [ $foo ]; then + bar +else + baz diff --git a/test/indent/sh/deindent-only-else/rc b/test/indent/sh/deindent-only-else/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/deindent-only-else/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/indent-after-do/cmd b/test/indent/sh/indent-after-do/cmd new file mode 100644 index 000000000..0bc4727fd --- /dev/null +++ b/test/indent/sh/indent-after-do/cmd @@ -0,0 +1 @@ +geithing1 diff --git a/test/indent/sh/indent-after-do/in b/test/indent/sh/indent-after-do/in new file mode 100644 index 000000000..48ec3642b --- /dev/null +++ b/test/indent/sh/indent-after-do/in @@ -0,0 +1 @@ +while true; do diff --git a/test/indent/sh/indent-after-do/out b/test/indent/sh/indent-after-do/out new file mode 100644 index 000000000..210ac4092 --- /dev/null +++ b/test/indent/sh/indent-after-do/out @@ -0,0 +1,2 @@ +while true; do + thing1 diff --git a/test/indent/sh/indent-after-do/rc b/test/indent/sh/indent-after-do/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/indent-after-do/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/indent-after-in/cmd b/test/indent/sh/indent-after-in/cmd new file mode 100644 index 000000000..e3f54ff43 --- /dev/null +++ b/test/indent/sh/indent-after-in/cmd @@ -0,0 +1 @@ +geibar) diff --git a/test/indent/sh/indent-after-in/in b/test/indent/sh/indent-after-in/in new file mode 100644 index 000000000..a94d1a3c5 --- /dev/null +++ b/test/indent/sh/indent-after-in/in @@ -0,0 +1 @@ +case $foo in diff --git a/test/indent/sh/indent-after-in/out b/test/indent/sh/indent-after-in/out new file mode 100644 index 000000000..a3be70a09 --- /dev/null +++ b/test/indent/sh/indent-after-in/out @@ -0,0 +1,2 @@ +case $foo in + bar) diff --git a/test/indent/sh/indent-after-in/rc b/test/indent/sh/indent-after-in/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/indent-after-in/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/indent-after-then/cmd b/test/indent/sh/indent-after-then/cmd new file mode 100644 index 000000000..0bc4727fd --- /dev/null +++ b/test/indent/sh/indent-after-then/cmd @@ -0,0 +1 @@ +geithing1 diff --git a/test/indent/sh/indent-after-then/in b/test/indent/sh/indent-after-then/in new file mode 100644 index 000000000..c640fe4ff --- /dev/null +++ b/test/indent/sh/indent-after-then/in @@ -0,0 +1 @@ +if [ $foo ]; then diff --git a/test/indent/sh/indent-after-then/out b/test/indent/sh/indent-after-then/out new file mode 100644 index 000000000..060389abf --- /dev/null +++ b/test/indent/sh/indent-after-then/out @@ -0,0 +1,2 @@ +if [ $foo ]; then + thing1 diff --git a/test/indent/sh/indent-after-then/rc b/test/indent/sh/indent-after-then/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/indent-after-then/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/indent-block-case/cmd b/test/indent/sh/indent-block-case/cmd new file mode 100644 index 000000000..3598c36a8 --- /dev/null +++ b/test/indent/sh/indent-block-case/cmd @@ -0,0 +1 @@ +geithing1thing2 diff --git a/test/indent/sh/indent-block-case/in b/test/indent/sh/indent-block-case/in new file mode 100644 index 000000000..b0d854a5c --- /dev/null +++ b/test/indent/sh/indent-block-case/in @@ -0,0 +1,3 @@ +case $foo in + bar) thing1;; + baz) diff --git a/test/indent/sh/indent-block-case/out b/test/indent/sh/indent-block-case/out new file mode 100644 index 000000000..06c64dac9 --- /dev/null +++ b/test/indent/sh/indent-block-case/out @@ -0,0 +1,5 @@ +case $foo in + bar) thing1;; + baz) + thing1 + thing2 diff --git a/test/indent/sh/indent-block-case/rc b/test/indent/sh/indent-block-case/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/indent-block-case/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh diff --git a/test/indent/sh/indent-compound-command/cmd b/test/indent/sh/indent-compound-command/cmd new file mode 100644 index 000000000..0bc4727fd --- /dev/null +++ b/test/indent/sh/indent-compound-command/cmd @@ -0,0 +1 @@ +geithing1 diff --git a/test/indent/sh/indent-compound-command/in b/test/indent/sh/indent-compound-command/in new file mode 100644 index 000000000..957b235ed --- /dev/null +++ b/test/indent/sh/indent-compound-command/in @@ -0,0 +1 @@ +foo () { diff --git a/test/indent/sh/indent-compound-command/out b/test/indent/sh/indent-compound-command/out new file mode 100644 index 000000000..43b16506a --- /dev/null +++ b/test/indent/sh/indent-compound-command/out @@ -0,0 +1,2 @@ +foo () { + thing1 diff --git a/test/indent/sh/indent-compound-command/rc b/test/indent/sh/indent-compound-command/rc new file mode 100644 index 000000000..4795bd804 --- /dev/null +++ b/test/indent/sh/indent-compound-command/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/sh.kak" +set buffer filetype sh