-
Notifications
You must be signed in to change notification settings - Fork 26
typstfmt Folds the Parameter List in Function Call even if line_wrap = false
is Specified
#160
Comments
Hello :) line_wrap only talks about markup, the fact that you're confused means the name should be changed. you're right that the formatting you've given is awful. Could you share your config file? |
Sure! My config file contains only one line which is line_wrap = false The global config contains indent_space = 2
max_line_length = 80
experimental_args_breaking_consecutive = false
line_wrap = true |
Another example, I think it is the same issue so I'll leave it here: Consider the following snippet #show: project.with(
title: "Seitenkanalangriffe auf
Openc906 und Openc910
RISC-V Prozessoren",
authors: ((
name: "Pablo Ovelleiro Corral",
degree: "Master Praktische Informatik",
email: "[email protected]",
matriculation: "0000000",
)),
logo: "uni-logo.svg",
abstract: "abstract.typ"
) Running typstfmt with the default config, formats it into this: #show: project.with(title: "Seitenkanalangriffe auf
Openc906 und Openc910
RISC-V Prozessoren", authors: ((
name: "Pablo Ovelleiro Corral",
degree: "Master Praktische Informatik",
email: "[email protected]",
matriculation: "0000000",
)), logo: "uni-logo.svg", abstract: "abstract.typ") I would argue that is a much worse format. Is there any chance we could comma-separated parameters to stay on their own lines while being indented? |
I would say @pinpox 's example is definitely worse. @astrale-sharp I suggest that we can add an option to control the behavior of parameter lists (as well as array lists, and other comma-separated things). For example, we can add FYR: this is what Intellij IDEA does |
Hey there, still very unavailable unfortunately, still ready to review PR quickly |
@astrale-sharp I think I could create a simple PR that work around this issue. Which branch should I work on though? |
that's lovely thanks! |
That's Great! Will do later |
Feel free to let me know if there is something I can help test and thanks for taking the time to do this :) |
I experience the same problem in formatting dictionaries. #let dictionary = (
key1: ("word1","word2"),
key2: 1,
key3: [
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras malesuada justo id arcu molestie, eget suscipit ipsum eleifend. Aliquam id urna egestas, dictum velit vel, rutrum ipsum. Nunc egestas finibus turpis et accumsan. Cras commodo, nisl sed cursus mattis, diam leo suscipit diam, ac pellentesque dolor erat ut justo. Vestibulum finibus lorem at augue commodo, et congue nisl volutpat. In hendrerit finibus felis, at auctor ligula rhoncus in. Sed feugiat, velit at vestibulum egestas, mauris sapien rutrum enim, at euismod nisi sem sit amet diam. Aliquam ullamcorper et nunc at aliquam. Proin at mi vitae purus euismod gravida id viverra risus. Donec a maximus massa. Sed hendrerit tristique ipsum vel facilisis. Ut scelerisque rutrum urna, non maximus neque cursus feugiat. Quisque pharetra lorem diam, eu venenatis tellus vestibulum eu. Mauris sagittis enim eros. In nec tincidunt libero.
Aliquam vitae ultrices nibh. Etiam dictum tempus felis ut egestas. Pellentesque odio arcu, blandit a blandit ac, tempus at lectus. Ut at ultricies nulla. Nunc risus lectus, luctus a risus eget, ullamcorper rutrum enim. Sed viverra imperdiet arcu, in ultrices metus egestas nec. Suspendisse ornare nulla ut tristique fermentum. Curabitur rutrum arcu vitae ex dignissim ornare vel consectetur mi. Praesent sit amet varius ipsum. Suspendisse potenti.
Fusce sit amet leo tristique, posuere nunc sed, interdum purus. Mauris quis faucibus arcu, in auctor eros. Suspendisse consequat mattis eleifend. Vivamus sed nibh non arcu sollicitudin eleifend ac quis arcu. Cras luctus interdum felis in molestie. Quisque vel sem mauris. Nam vitae placerat odio. Curabitur fringilla scelerisque felis in tincidunt.
],
key4: [$12$]
) The result, after formatting, is definitely worse than before: #let dictionary = (
key1: ("word1", "word2"), key2: 1, key3: [
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras malesuada justo id arcu molestie, eget suscipit ipsum eleifend. Aliquam id urna egestas, dictum velit vel, rutrum ipsum. Nunc egestas finibus turpis et accumsan. Cras commodo, nisl sed cursus mattis, diam leo suscipit diam, ac pellentesque dolor erat ut justo. Vestibulum finibus lorem at augue commodo, et congue nisl volutpat. In hendrerit finibus felis, at auctor ligula rhoncus in. Sed feugiat, velit at vestibulum egestas, mauris sapien rutrum enim, at euismod nisi sem sit amet diam. Aliquam ullamcorper et nunc at aliquam. Proin at mi vitae purus euismod gravida id viverra risus. Donec a maximus massa. Sed hendrerit tristique ipsum vel facilisis. Ut scelerisque rutrum urna, non maximus neque cursus feugiat. Quisque pharetra lorem diam, eu venenatis tellus vestibulum eu. Mauris sagittis enim eros. In nec tincidunt libero.
Aliquam vitae ultrices nibh. Etiam dictum tempus felis ut egestas. Pellentesque odio arcu, blandit a blandit ac, tempus at lectus. Ut at ultricies nulla. Nunc risus lectus, luctus a risus eget, ullamcorper rutrum enim. Sed viverra imperdiet arcu, in ultrices metus egestas nec. Suspendisse ornare nulla ut tristique fermentum. Curabitur rutrum arcu vitae ex dignissim ornare vel consectetur mi. Praesent sit amet varius ipsum. Suspendisse potenti.
Fusce sit amet leo tristique, posuere nunc sed, interdum purus. Mauris quis faucibus arcu, in auctor eros. Suspendisse consequat mattis eleifend. Vivamus sed nibh non arcu sollicitudin eleifend ac quis arcu. Cras luctus interdum felis in molestie. Quisque vel sem mauris. Nam vitae placerat odio. Curabitur fringilla scelerisque felis in tincidunt.
], key4: [$12$],
) If I set Please also note that a comma is added after the last key. I don't know if it is intended. |
Did you manage to get something working ? |
I managed to achieve a relatively good result but I am a little bit busy these days. I will try to get it done in early April |
Strangely enough, this behaviour does not appear when using typstfmt in the vscode typst-lsp plugin. It seems that they're using 0.2.7, so I'm wondering if this is a bug that crept in during 0.2.8 or 0.2.9. See nvarner/typst-lsp/Cargo.toml#L81. It's worth noting that when formatted using the lsp, it will revert to the first image below. ImagesFormatted with typst-lsp's typstfmt integration: Formatted with typstfmt from the commandline: |
Describe the bug
typstfmt remove custom line breaks in function calls even with
line_wrap
setting tofalse
.To Reproduce
Given a function call, for example
#figure( fletcher.diagram( node-outset: .5em, node-stroke: .075em, node((+1, 0), [variable], radius: 3em), node((+1.25, .75), [const], radius: 3em), edge((0, 0), (+1, 0), "=>"), edge((0.25, .75), (+1, 0), "->"), edge((0.25, .75), (+1.25, .75), "=>"), node((+0, 0), [pointer to \ variable], radius: 3em), node((-1, 0), [pointer to \ pointer to \ variable], radius: 3em), node((-.75, .75), [pointer to \ pointer to \ const], radius: 3em), node((+0.25, .75), [pointer to \ const], radius: 3em), edge((-1, 0), (+0, 0), "=>"), edge((-.75, .75), (+0, 0), "-X->"), edge((-.75, .75), (+0.25, .75), "=>"), ) )
with the default configuration plus
line_wrap = false
, typstfmt formats this piece of code into#figure( fletcher.diagram( node-outset: .5em, node-stroke: .075em, node((+1, 0), [variable], radius: 3em), node((+1.25, .75), [const], radius: 3em), edge((0, 0), (+1, 0), "=>"), edge((0.25, .75), (+1, 0), "->"), edge((0.25, .75), (+1.25, .75), "=>"), node((+0, 0), [pointer to \ variable], radius: 3em), node((-1, 0), [pointer to \ pointer to \ variable], radius: 3em), node((-.75, .75), [pointer to \ pointer to \ const], radius: 3em), node((+0.25, .75), [pointer to \ const], radius: 3em), edge((-1, 0), (+0, 0), "=>"), edge((-.75, .75), (+0, 0), "-X->"), edge((-.75, .75), (+0.25, .75), "=>"), ), )
which, in my perspective, worse than before.
I've tried various combination of options, but all yields unsatisfied result. I believe that we could prevent line breaking in function calls if
line_wrap = false
is specified, or add an extra option to handle this.I noticed that there was a similar issue #134, however, that pull request seems to be closed?
The text was updated successfully, but these errors were encountered: