Replies: 2 comments
-
|
I decided I needed some of these features sooner rather than later. I've partially implemented this in this branch. It's not fully automatic, but it may end up being all we need. Key change is the introduction of the This already gets us most of the way there: // No `nl` needed
#[derive(SyntaxFmt)]
struct Item {
name: &'static str,
}
#[derive(SyntaxFmt)]
struct Block {
// nl = inner to insert appropriate newlines with the vec content
#[syntax(ind, nl = inner, pre = "{", suf = "}", sep = "")]
items: Vec<Item>,
}The most important change is removing the need for The pattern of |
Beta Was this translation helpful? Give feedback.
-
|
Now merged in #14 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
A few random thoughts that are not fully formed, but need to go somewhere.
Even with the new Indentation and Layout, handling newlines and indenting is still a fairly manual process.
Currently, to set up indenting and newlines for inner types, we use something like:
This is a little visually clunky and requires knowledge of the behaviour of the macro to know where to put newlines.
But it results in nicely formatted output (in pretty mode):
I am wondering if it would be possible to fully automate by always indenting within types by default, then giving additional options to deny newlines or indentation.
Something like this, to result in the same output:
And then if you don't want newlines and indentation:
Which would result in:
And of course, we could still support the explicit
nloptions.Another possibility would be to conditionally add newlines based on some character length, array length, line length heuristics.
Beta Was this translation helpful? Give feedback.
All reactions