This patch simplifies the verbose output a bit and fixes various cases
where an error message would be printed before the file info line
instead of after.
This patch improves the command line argument parsing to handle more
edge cases related to input files and directories (such as e.g. empty
directories).
This patch adds a quick start section to the README with copy-pasteable
setup commands. Closes#80. Also removes some discussion about shell
alias and the `-m` flag and instead recommend using the shell script
wrapper.
This patch implements a new command line argument `--verbose` which
enables verbose ouutput. Runic is now silent by default so `--verbose`
re-enables the verbose file printing from previous releases.
This patch also adds a progress prefix to each file of the form
`[file/nfiles]` to verbose output.
This patch implements the `--lines=a:b` command line argument for
limiting the formatting to the line range `a:b`. Multiple ranges are
supported. Closes#114.
This patch make some changes to the README:
- Use name instead of URL for installation instructions
- Create a new section on adopting Runic for a code base
- Add a suggested README badge (closes#108).
This patch removes an assertion about whitespace after the `function`
keyword in the indent pass. The core issue is the
`is_longform_anon_function` predicate which is wrong for the testcases,
but the assert is not needed since we can just use the next
non-whitespace noce as the signature in all cases. Fixes#109.
Running testsuite *without* asserts takes roughly 150% or the time to
run it *with* asserts, probably because the compiler is helped by some
of the checks. The toggling is unused anyway, so delete it.
This patch changes the parsed syntax tree normalization with the goal of
simplifying the formatting code. JuliaSyntax is not very consistent with
where whitespace ends up which make formatting tricky since you always
have to "peek" into the next node (sometimes multiple levels) to check
if the next leaf is e.g. whitespace. This patch reworks the
normalization to "bubble up" whitespace so that all nodes start and end
with a non-whitespace node.
For example, given `a + b * c`, the output from JuliaSyntax is:
```
[call]
Identifier
Whitespace
+
[call]
Whitespace
Identifier
Whitespace
*
Whitespace
Identifier
```
and now after normalization the leading whitespace of the `*`-call is
bubbled up:
```
[call]
Identifier
Whitespace
+
Whitespace
[call]
Identifier
Whitespace
*
Whitespace
Identifier
```
As seen from the diff, this make it possible to remove a lot of
complicated code that were necessary to handle the random whitespace
placement. In particular, there is no need to peek into the nodes to
check for whitespace.
As a bonus, this fixes two issues:
- `global\n\n x = 1` would previously not indent correctly because we
had to double-peek (first into the `=` node, then into the LHS node).
- `runic: (off|on) toggling within array literals. Previously the
toggle comments would end up inside the `row` nodes so in the tree
they weren't on the same "level" which is required for the toggling.
Behavior of `..` is more tricky than `:`. Sometimes the space is
required like in e.g. `a .. -b` which, formatted as `a..-b`, would give
`ParseError: invalid operator ..-`.
This reverts commit 7d26dcf268.
This patch relaxes the toggle comments `# runic: (off|on)` such that the
comment may contain more than just the toggle comment. This is useful
when combining with other "pragmas" such as e.g. Literate.jl line
filters. For example, the following now also toggles formatting:
```julia
\# runic: off #src
not = formatted #src
\# runic: on #src
```
This doesn't cost much (5 % perf hit for some large files) and can catch
some errors. Note that it isn't possible/trivial to compare the trees
since the formatter make changes to it.