What kind of plugin, cindent options, or alike, can I use to indent the code in two column, the first column indented based on block-depth, and the second based on the column of the assignators of the current block. So writing code like this is easy:
left col op right col
|_____________|__|____________
let obj = {
somekey : value,
nested : {
akey : value,
...
}
...
},
At least I would like to cover the following two usages.
Case 1: automatically indent user-defined operators, like = and :, to the column of the current block. Once the operator is typed vim auto indents based (a) the previous block column in the case of the first item, (b) on the current block column, or (c) on the current cursor in the case where user has tab it manually.
a
let something_a = {
here:<-- cursor
}
a autoindents like
let something_a = {
first_item : <-- cursor
b
let something_b = {
something_long_long :
second_item:<-- cursor
b autoindents like
let something_b = {
something_long_long : value,
second_item : <-- cursor
c
let something_c = {
manual_indent :<-- cursor
c autoindents like
let something_c = {
manual_indent : <-- cursor
Case 2 indent back the whole block to the further right operator, either automatically or by issuing some command. So we go from here
let something = {
here : value,
something_long_long : value,
short : value,
something_long_long_even_longer :<-- cursor
}
To there
let something = {
here : value,
something_long_long : value
short : value,
something_long_long_even_longer : value,
}
``
The expression must return the number of spaces worth of indent. [...] The evaluation of the expression must not have side effects! It must not change the text [...]
so I guess that by using the indent/*vim system you cannot achieve what I am describing, is that so? Your suggestion is not fit to be formatting while insert mode, right? So, if I were to resolve the problem as described in the question I'd need a overkill solution needing LSP or similar mechanism?:help equalprg
/formatprg
/:range!
. These are better especially when indent/ style scripts are challenging to write (though those can setup both insert-mode indents and others)