This is a huge patch and adds formatting of indentation. It is slightly
difficult to come up with a good set of rules but I think what is here
is pretty nice. There are two types of indentation: block/hard
indentation and continuation/soft indentation.
Block indentation are context independent and are thus "hard" or
required in the sense that they always happen. Block indentation are
enabled for all `x - end` blocks where `x` is one of `begin`, `do`,
`for`, `function`, `if`, `let`, `quote`, `struct`, `try`, `while`. A
notable exception is `module`, but one idea is to indent nested modules
(in the same file).
Continuation or soft indents are context dependent in the sense that if
nested within another soft indent they extra indents are skipped. Soft
indentation applies to all expressions spanning multiple lines.
For example, newlines in operator chains:
```julia
a + b * c +
d # soft indent
```
function calls
```julia
foo(
a, b c, d # soft indent
)
```
etc.
Using JuliaSyntax.GreenNode directly have worked for a long time, but at
this point it seems that it is easier to re-package the tree in a custom
type. This will be used to attach metadata to nodes, for example.
Also include the following renames:
- s/verified_children/verified_kids/
- s/children/kids/
- s/children′/kids′/
- s/children′′/kids′′/
- s/child/kid/
- s/child′/kid′/
- s/child′′/kid′′/
The next leaf node might not be a direct grand child when nesting
operators. This patches introduces a function `replace_first_leaf` that
replaces the correct leaf.
A leading `+`/`-` is part of the float literal if there is no space in
between (in which case it becomes a call). This patch fixes the regexes
to handle this for float parsing.
It is a bit weird to not be consistent and put spaces around all
operators, but most people would agree that using no spaces for `:` and
`^` look better.
`for`-loop nodes are of kind K"=" even when using `in`. This patch fixes
the predicate for `spaces_around_assignments` to include K"in" as an
option. Note that when using `in` spaces are required, but the pass
is still useful to remove spaces when there are more than one.
This adds a pass which adds a single space between operators, for
example `a+b` -> `a + b` and `a==b` -> `a == b`. Note that comparison
chains are still left untouched (`a == b == c`) and is a todo.