From 01712e7f3cdedfb178470e6a73bab35e7b5f94ec Mon Sep 17 00:00:00 2001 From: John Isom Date: Mon, 27 Jul 2020 20:55:34 -0600 Subject: [PATCH] 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 , this would happen: ``` json { "foo": { | } ``` when it should have been this: ``` json { "foo": { | } ``` --- rc/filetype/json.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/filetype/json.kak b/rc/filetype/json.kak index 58f1e328..994ffc5e 100644 --- a/rc/filetype/json.kak +++ b/rc/filetype/json.kak @@ -59,8 +59,8 @@ define-command -hidden json-indent-on-new-line %< try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : json-trim-indent } - # indent after lines beginning with opener token - try %< execute-keys -draft k ^\h*[[{] j > + # indent after lines ending with opener token + try %< execute-keys -draft k [[{]\h*$ j > # deindent opener token(s) when after cursor try %< execute-keys -draft ^\h*[}\]]+\h*$ hm 1 > >