Turn off all context sensitive alignment in Brittany. #56
Labels
No Label
blocked: dependency
blocked: info-needed
bug
duplicate
enhancement
fixed in HEAD
help wanted
hs:arrows
hs:brackets
hs:classes
hs:comments
hs:do-notation
hs:guards
hs:lists
hs:operators
hs:patterns
hs:records
hs:types
invalid
language extension support
layouting
needs confirmation
priority: high
priority: low
question
revisit before next release
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: hexagoxel/brittany#56
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Hey @lspitzner, I think
brittany
is a fantastic project, but I'm having trouble getting it to behave the way I'd like. I was able to disable most context sensitive alignment, but I can't seem to rid the world of it. My config is:But I still get code like this:
Is there any way to turn this off completely?
No, this is not implemented (yet). I see you set
lconfig_indentPolicy = IndentPolicyLeft
already, and that setting is planned to do exactly what you want, but I fear the field is currently ignored entirely.(This is related to #54, the implementation of which similarly would disable certain layouting alternatives based on config.)
In a way, implementing this depends on #30 because otherwise we cannot easily write tests for this.
I make no promises as to when I will find time to work on this.
@lspitzner Are you open to pull requests? Is there an easy way to contribute to this project?
Certainly, PR is welcome. Not sure how hard the DSL is to understand, although "conditionally disabling" is on the easier side..
Any necessary changes should be in the
Language.Haskell.Brittany.Internal.Layouters.*
modules.Layouters.Expr
, because that contains the code for the example you mentioned.docAlt [x, y]
withdocAltFilter [(,) _ x, (,) _ y]
where the holes depend on stuff read from the config.HsApp
, where the comments should clearly point out the different layouts, so you should see which one to disable.Unfortunately not all stuff is documented that clearly yet.. another indicator is the usage of
docSetBaseY
, which roughly expresses "take the current column, and use it as base indentation for every syntax node below" - the thing you do not want.Maybe it is best if I implement the HsApp case, and you can see which other cases require attention and apply the same treatment to those? The main work for this really is finding the right places to disable, not the disabling itself.. Give me a sec.
@eborden I have pushed a start to the
indentpolicyleft
branch. Commit d019c044197fad9bf2a3e91eed4b36ec17e6771f is the important bit. The other commit just indents the whole thing a bit.. the diff probably looks scarier than necessary :-)(And forgive me if the layouting of the
brittany
source itself is not very consistent there - I have gotten lazy when it comes to formatting manually, andbrittany
cannot cope with the CPP bits required for ghc-8.0/8.2 support..)Awesome, I'll take a look. Hopefully I can be helpful.