-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Consider not splitting last line of block comment (or make configurable via flag?) #225
Comments
This is a really niche and obscure use case, and I've never seen it before. However, it reminds me of KDL which has Like with #179, I'd prefer seeing this solved in the Nix language itself by adding dedicated syntax for this kind of comments. (Also, for a similar reason I dislike commenting out code with |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/formatting-team-meeting-2024-11-26/56643/1 |
That's fair, and I think a language feature to support commenting out an expression (or maybe an attribute definition, or both?) would be great! (similar feelings about nested multiline comments). In lieu of a language change like that, this weird comment format is what I've found works as a quick + dirty way to toggle a block, so I just wanted to describe a use case / papercut I ran into using the formatter with the current Nix language. It is pretty niche, which is why I was thinking about a more general-purpose In any case, thanks for taking a look/considering this! If nothing else, maybe this discussion will help inform some other formatter's implementation decisions. |
It was suggested I file a separate issue for this:
Just to propose one additional use case for
/* */
comment (non-)formatting: it's possible to toggle a block comment with a single#
using something like the following:For this kind of case I think it would be valuable to avoid splitting the final
# */
onto two lines (and maybe also the first line, but that's less important). Otherwise this "quick toggle" results in invalid syntax, e.g.I use this in my configs to quickly toggle on/off large sections of the config. I'm not sure how popular a practice it is in general, but it seems to be moderately common from a cursory search:
https://github.com/search?q=lang%3Anix+%2F%28%23+%5C*%5C%2F%7C%23+%5C%2F%5C*%29%2F&type=code
Originally posted by @ian-h-chamberlain in #179 (comment)
As pointed out by others, the use of
/* */
comments like this reduces line diffs when toggling blocks, but also cannot be used with any nested/* */
comments, since Nix does not support comment nesting like this.I also wanted to point out the RFC 1 66 specification about multiline comments, it seems to me slightly ambiguous whether this kind of format would be conformant or not:
In particular, the first point seems like it would tend to prevent the
# */
format I am referring to, but the last point's use of "may" leads me to believe it would be acceptable for a formatter to skip adding a newline after/*
(and perhaps by extension the newline before*/
?). Maybe someone who is more familiar with the intent of the RFC could comment on this?The text was updated successfully, but these errors were encountered: