1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-29 10:02:57 +03:00

Change indentation rules in json.kak to be much more intuitive for nested objects

As it was before, when you had this (| = cursor):

``` json
{
  "foo": {|
}
```

and hit <ret>, this would happen:

``` json
{
  "foo": {
  |
}
```

when it should have been this:
``` json
{
  "foo": {
    |
}
```
This commit is contained in:
John Isom 2020-07-27 20:55:34 -06:00
parent 9dd292d100
commit 01712e7f3c

View File

@ -59,8 +59,8 @@ define-command -hidden json-indent-on-new-line %<
try %{ execute-keys -draft <semicolon> K <a-&> }
# filter previous line
try %{ execute-keys -draft k : json-trim-indent <ret> }
# indent after lines beginning with opener token
try %< execute-keys -draft k <a-x> <a-k> ^\h*[[{] <ret> j <a-gt> >
# indent after lines ending with opener token
try %< execute-keys -draft k <a-x> <a-k> [[{]\h*$ <ret> j <a-gt> >
# deindent opener token(s) when after cursor
try %< execute-keys -draft <a-x> <a-k>^\h*[}\]]+\h*$<ret> hm <a-S> 1<a-&> >
>