- Listlike expressions (e.g. tuples, calls, paren-blocks, vectors) that
span multiple lines now always require a leading and a trailing
newline (and thus a trailing comma from previous listlike spacing
code). For example
```diff
-f(a,
- b)
+f(
+ a,
+ b,
+)
```
- Listlike expressions are now hard indents instead of the
soft/continuation style from before. This looks better.
- Vectors (K"vect" and K"ref") are now spaced like lists.
- Fix some bugs in spaces-around-operators when there where hidden
newlines at the beginning of the call chain.
Closes#9.
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.