fix(nix): drop none-ls formatter#1324
Conversation
nixd already provides formatting builtin: https://github.com/nix-community/nixd/blob/2c25600cb9c91bc06fe8676c044814dc30435274/nixd/docs/configuration.md?plain=1#L62 <!-- ps-id: 1fa3237e-80c0-4325-a86a-cda8aa832f3a -->
Review ChecklistDoes this PR follow the [Contribution Guidelines](development guidelines)? Following is a partial checklist: Proper conventional commit scoping:
|
|
We are currently avoiding nixfmt until it becoms stable. See the tracking issue: #883 |
|
We have nixfmt in 24.11, so it is stable? Also this doesn't replace alejandra it let nixd handle the configuration. People can still configure nixd to use alejandra. It just sets the default. |
My PR sets the formatter as alejandra.As for the stability of nixfmt, check their github repo. They call it not yet stable. :) |
If nixd is active this doesn't work because nixd does the formatting not non-ls. So this is a no-op. Same is true for nil-ls. This pull request is not about alejandra vs nixfmt. You can still use alejandra after that. |
|
thanks for the pr. whats will be the default formatter after the merge? edit: so i guess it will be nixfmt or nixfmt-rfc-style depends what you have installed |
|
How to change the formatter now? I tried adding the following to the astrolsp config: return {
"AstroNvim/astrolsp",
---@type AstroLSPOpts
opts = {
---@diagnostic disable: missing-fields
config = {
nixd = {
formatting = { command = { "alejandra" } },
},
},
},
}But there seem to be no effect. Trying to format a nix file leads to the following error message in the lsp log ( Though, it could be because nixd configuration is broken in general, as with vanilla astronvim configuration (from the template repo), with the nix pack enabled, I see the following error in the lsp log after opening a nix file: |
You can set it in your flake.nix |
|
According to nix-community/nixd#496, nixd doesn't support getting formatter configuration from flake.nix |
|
what you wanna do? setting a different formatter? because nixd does have build in formating configuration and sets it to nix-fmt, if you want that, then just use the code from above |
|
https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md#configuration-overview nixd has a configuration file. |
You are right. I gotta double check the behaviour in nixd some other day and come back to you. |
Yes, I wanted to use alejandra instead of the default nixfmt. As @Mic92 pointed out, nixd can be configured, including the formatter. The problem is that my configuration doesn't have any effect. It feels like there is a problem in the initial configuration process somewhere between astrolsp and nixd, but I don't possess skills to debug this further. Probably, this is not the right place for me for reporting this issue, I just thought that maybe some of you happen to use non-default formatter with nixd and knows how to configure it in astronvim. Where should I create an issue (astrolsp → nixd) instead? |
astrolsp is using the settings I apply to it, so it doesnt seem to be the issue. |
nixd already provides formatting builtin:
https://github.com/nix-community/nixd/blob/2c25600cb9c91bc06fe8676c044814dc30435274/nixd/docs/configuration.md?plain=1#L62
📑 Description
ℹ Additional Information