Open devmattrick opened 1 year ago
I think, as you are using nil for your formatting, the issue is more appropriate for the nil repo. https://github.com/oxalica/nil/issues/70 already exists there to track this issue. You can use "command": ["nix", "fmt", "--", "-"]
, if the formatter of the flake your editing supports stdin→stdout formatting when given -
as its first positional argument (which is what the above "command"
value is accomplishing). https://github.com/NixOS/nix/pull/8063 defines this API so in the future all nix formatters for use with flakes should hopefully comply with it (if they don't already).
@hcsch , maybe unrelated, but do you think your comment in anyway relates to the issue I observed? #413
This is kinda a specific issue that I'm having but I was hoping to use the
nix fmt
command to format my flake. The only problem is that my flake.nix file is not in the root directory of my project; instead it's nested in anix/
directory, since I also want to include some non-nix stuff in this specific repository.I have my Nix IDE plugin set up like so:
The language server is working fine, but when I save a Nix file, I get an error in the output:
The issue is that my
flake.nix
(and all other.nix
files) are in thenix/
directory of this project. I don't know if this is possible but I think the desired behavior of this would be to run the formatter command relative to the.nix
file I'm saving instead of the VSCode project root.Thanks for the help!
EDIT: It seems like
nix fmt
also doesn't accept input from stdin.nix fmt
might need to be special cased since it will format the entire flake on save, which would probably be undesirable. It doesn't look like there's an easy way to tellnix fmt
to "only format this one file" from what I can tell from the documentation.