Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Formatter #724

Merged
merged 152 commits into from Jul 8, 2017
Merged

Code Formatter #724

merged 152 commits into from Jul 8, 2017

Conversation

KronicDeth
Copy link
Owner

@KronicDeth KronicDeth commented Jul 7, 2017

Resolves #98

Changelog

Enhancements

  • Code Formatter
    • do block lines are indented
    • do blocks end as the last argument of a no parentheses call unindents to the start of the call
    • If one clause of a multi-clause anonymous function wraps, all clauses wrap.
    • Indent after else
    • Indent map and struct keys
    • All keys wrap if any key wraps
    • No spaces around...
      • .
    • Spaces around...
      • and
      • in
      • or
      • when
    • Configure spaces around...
      • =
      • <- and \\
      • !=, ==, =~, !==, and ===
      • <, <=, >=, and >
      • + and -
      • * and /
      • Unary +, -, !, ^, and ~~~
      • ->
      • ::
      • |
      • || and |||
      • && and &&&
      • <~, |>, ~>, <<<, <<~, <|>, <~>, >>>, and ~>>
      • ..
      • ^^^
      • ++, --, .., <>
      • =>
    • Configure spaces before...
      • ,
    • No space after...
      • @
    • Spaces after...
      • not
      • fn
      • after
      • catch
      • rescue
      • key:
    • Configure space after...
      • &
      • ,
    • Configure spaces within...
      • { }
      • << >>
      • [ ]
      • ( )
    • No space around / in &NAME/ARITY and &QUALIFIER.NAME/ARITY
    • when wraps when its right operand wraps, so that guards start with when on a newline when they are too long.
    • Align |> at start of indented line for pipelines
    • Align end with start of call instead of start of line for do blocks in pipelines
    • Indent list elements when wrapped
    • Indent tuple elements when wrapped
    • Align type definition to right of ::
    • Align guard to right of when when guards span multiple lines
    • Align two operator (++, --, .., <>) operands, so that <> binaries are multiple lines align their starts instead of using continuation indent and being indented relative to first operand.
    • Align pipe | operands, so that alternates in types and specs are aligned instead of continuation indented relative to the first operand.
    • Comments in spec (that is above operands to | align with the operands
    • Remove newlines from pipelines, so that all pipelines start with an initial value or call and each |> is the start of a successive line.
    • Key exclusivity: if an association operation or keyword key is already on a line, the container value automatically has it's elements wrapped if there is nested associations or keyword pairs, so that two levels of keys are not on the same line.
    • Indent bit string (<< >>) elements when wrapped

Don't build a Block for SIGNIFICANT_WHITE_SPACE ASTNodes since
Whitespace class will consume them.
`not` must be a separate token (NOT_OPERATOR) from the symbolic unary
operators (UNARY_OPERATOR) as the symbolic operators in most styles have
no space around them, but `not`, being a word, requires a space so that
it doesn't merge with its argument to form an IDENTIFIER.
END_OF_EXPRESSION was being treated as an EOL if its first child was an
EOL, but this was a bug because I forgot that it could include COMMENT
interleaved with EOL because COMMENT never appears in Elixir.bnf, which
was using to make Block.
Allow to configure whether there is a space after capture operator, but
prevent & before another & from being combined and forming a &&.
Space around || and ||| is customizable, but space around `or` is fixed
to 1 space to prevent fusion with surrounding identifiers.
Always 1 space around `and`.  Space around `&&` and `&&&` is
configurable.
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
Repository owner deleted a comment Jul 7, 2017
@KronicDeth KronicDeth merged commit d372045 into master Jul 8, 2017
@KronicDeth KronicDeth deleted the 98 branch July 8, 2017 01:33
@KronicDeth KronicDeth added this to the v5.1.1 milestone Jul 8, 2017
KronicDeth added a commit that referenced this pull request Jul 8, 2017
@KronicDeth KronicDeth mentioned this pull request Jul 8, 2017
KronicDeth added a commit that referenced this pull request Jul 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant