Stop mangling my comment formatting!
Closed this issue · 6 comments
Description
I do not think that nixfmt
should "format" comments at all, especially not messing with the indentation of lines contained within /*
and */
.
I know there are other opinionated issues here that require some degree of customization, and nixfmt
is designed to not be customized. I understand that you don't want a config file or command line flags for this reason, however, some of the opinionated formatting is way too strict. For example, 0.007
("seven thousandths") gets formatted as 0.7e-3
("seven tenths times ten to the power of three") and that's far less readable.
I think you should add a config file or command line flags.
Small example input
{
/*
$ nix eval 'path:.#overlays' | sed 's/<|>/"/g' | nixfmt
---
There is an overlay for each package:
- fork-awesome
- idlehack
- ja-netfilter
- nerdfonts-symbols
- proton-ge-custom
- prtsc
- ttf-ms-win11
- zsh-plugins
Then there are collections/utilities also available as overlays:
- lib = extra functions merged into `pkgs`
- allowUnfree - override `meta.license` of certain packages
- oraclejdk - overrides `oraclejdk` to not `requireFile`
- default - all packages from this flake
- updates - some small updates/fixes for certain packages
*/
overlays = let packageOverlays = import ./packages/overlays.nix lib;
in import ./overlays lib packageOverlays;
/*
$ nix eval 'path:.#packages.x86_64-linux' --apply 'builtins.attrNames' | nixfmt
[
"fork-awesome"
"idlehack"
"ja-netfilter"
"nerdfonts-symbols"
"proton-ge-custom"
"prtsc"
"ttf-ms-win11"
"zsh-auto-notify"
"zsh-autocomplete"
"zsh-autopair"
"zsh-autosuggestions"
"zsh-edit"
"zsh-fast-syntax-highlighting"
"zsh-window-title"
]
*/
packages =
eachSystem (system: import ./packages { inherit lib system nixpkgs; });
}
Expected output
Unchanged.
Actual output
{
/* $ nix eval 'path:.#overlays' | sed 's/<|>/"/g' | nixfmt
---
There is an overlay for each package:
- fork-awesome
- idlehack
- ja-netfilter
- nerdfonts-symbols
- proton-ge-custom
- prtsc
- ttf-ms-win11
- zsh-plugins
Then there are collections/utilities also available as overlays:
- lib = extra functions merged into `pkgs`
- allowUnfree - override `meta.license` of certain packages
- oraclejdk - overrides `oraclejdk` to not `requireFile`
- default - all packages from this flake
- updates - some small updates/fixes for certain packages
*/
overlays = let packageOverlays = import ./packages/overlays.nix lib;
in import ./overlays lib packageOverlays;
/* $ nix eval 'path:.#packages.x86_64-linux' --apply 'builtins.attrNames' | nixfmt
[
"fork-awesome"
"idlehack"
"ja-netfilter"
"nerdfonts-symbols"
"proton-ge-custom"
"prtsc"
"ttf-ms-win11"
"zsh-auto-notify"
"zsh-autocomplete"
"zsh-autopair"
"zsh-autosuggestions"
"zsh-edit"
"zsh-fast-syntax-highlighting"
"zsh-window-title"
]
*/
packages =
eachSystem (system: import ./packages { inherit lib system nixpkgs; });
}
Interesting. Nixfmt has the freedom to change the global indentation level of a comment, e.g. by changing where the content starts relative to /*
. However, the relative indentation of the lines should definitely preserved. This is somehow not the case. From a first glance at the code it should already be doing the correct thing, I'll investigate
Oh, I also cannot reproduce it on my branch, so it does make sense. Please try this again on #118 and report back
@piegamesde I missed your reply ages ago. Since #118 has been merged, the problem has not changed.
The comment handling has been completely reworked again since last December, and is now in accordance with the RFC text.
I don't recognize the validity of the RFC text.
I don't recognize the validity of the RFC text.
I'm sorry, but that's your problem. The RFC is merged, move on or stay behind.