Diff
1diff --git a/lib/cli.zsh b/lib/cli.zsh
2index d1896f18dcbe65782ad2089465c23700f01b2752..38a84840cf015eaa3cfd3458abe92aeccbb0ddb5 100644
3--- a/lib/cli.zsh
4+++ b/lib/cli.zsh
5@@ -344,20 +344,40 @@ function _omz::plugin::enable {
6 next
7 }
8
9-# if plugins=() is in multiline form, enable multi flag
10+# if plugins=() is in multiline form, enable multi flag and indent by default with 2 spaces
11 /^[ \t]*plugins=\(/ {
12 multi=1
13+ indent=\" \"
14+ print \$0
15+ next
16 }
17
18 # if multi flag is enabled and we find a valid closing parenthesis,
19-# add new plugins and disable multi flag
20+# add new plugins with proper indent and disable multi flag
21 multi == 1 && /^[^#]*\)/ {
22 multi=0
23- sub(/\)/, \" $add_plugins&\")
24+ split(\"$add_plugins\",p,\" \")
25+ for (i in p) {
26+ print indent p[i]
27+ }
28 print \$0
29 next
30 }
31
32+# if multi flag is enabled and we didnt find a closing parenthesis,
33+# get the indentation level to match when adding plugins
34+multi == 1 && /^[^#]*/ {
35+ indent=\"\"
36+ for (i = 1; i <= length(\$0); i++) {
37+ char=substr(\$0, i, 1)
38+ if (char == \" \" || char == \"\t\") {
39+ indent = indent char
40+ } else {
41+ break
42+ }
43+ }
44+}
45+
46 { print \$0 }
47 "
48