Skip to content
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

[BUG] lsp.servers.nil_ls: No formatter configured #2562

Open
1 task done
pagusupu opened this issue Nov 22, 2024 · 8 comments
Open
1 task done

[BUG] lsp.servers.nil_ls: No formatter configured #2562

pagusupu opened this issue Nov 22, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@pagusupu
Copy link

Field Description
Plugin lsp.servers.nil_ls
Nixpkgs unstable
  • I have read the FAQ and my bug is not listed there.

Description

after updating the newest unstable the below config doesnt work anymore, instead i get this:
[ERROR]...-format/init.lua:219 "nil_ls: -32603: No formatter configured. Set the nil.formatting.command LSP server setting."
from lsp.log

Minimal, Reproducible Example (MRE)

programs.nixvim = {
  enable = true;
  plugins = {
    lsp = {
      enable = true;
      servers.nil_ls = {
        enable = true;
        settings.formatting.command = ["${lib.getExe pkgs.alejandra}"];
      };
    };
    lsp-format.enable = true;
  };
}
@pagusupu pagusupu added the bug Something isn't working label Nov 22, 2024
@khaneliman
Copy link
Contributor

I'm using nil_ls and haven't seen this behavior, we also have unit tests setup with nil_ls that don't throw the error, and I tried using that MRE as one of the test cases. Might need more information about your configuration / setup of nixvim.

@pagusupu
Copy link
Author

my full config is here

ive also not been able to see it any logs but i get the notification asking about flake archive which only happens with the plugin default null, and my config has it set to false

@khaneliman
Copy link
Contributor

Looks like you have pkgs from stable and nixvim from unstable, curious if you see the same behavior by matching them up / not overriding nixpkgs from nixvim.

@pagusupu
Copy link
Author

settings both nixpkgs and nixvim to follow unstable (with nixvim following under the name nixpkgs specifically) still has the same result

@MattSturgeon
Copy link
Member

MattSturgeon commented Nov 22, 2024

settings both nixpkgs and nixvim to follow unstable (with nixvim following under the name nixpkgs specifically) still has the same result

Sometimes it can be difficult to pin down exactly which nixpkgs version is being used by nixvim, and just setting the flake input follows isn't always enough to change what is used.

If you're using nixvim via a wrapper module then we currently default to re-using the pkgs from the "host" configuration.

If you're using our standalone nixvim function, then it defaults to our flake input (which can be overridden using follows) but can also be explicitly specified using the pkgs argument in makeNixvimWithModule.

Maybe it's worth having a trace "pkgs version is ${pkgs.lib.trivial.release}" foo somewhere in your config? Although to ensure you use nixvim's pkgs you may need to wrap that in a module function:

programs.nixvim = { pkgs, ... }: {
  extraConfigLua = builtins.trace "pkgs version is ${pkgs.lib.trivial.release}" "";
}

If necessary, you can explicitly tell nixvim which pkgs instance to use via our nixpkgs.pkgs option. Currently this is only available on our main branch though.


Also, did you check what happens when you switch between nixvim's main branch and its nixos-24.05 branch?

@pagusupu
Copy link
Author

ive moved everything in my config back to unstable and adding the trace reports its using the correct version (25.05), and i dont think its a good idea to try using the 24.05 branch as i only moved parts of my config to stable after the release of 24.11 beta.

i also seem to use the nixpkgs.pkgs option correctly, how am i supposed to use it? im not very good with nix... i am on the main branch though.

@bpeetz
Copy link

bpeetz commented Nov 23, 2024

I've encountered the same issue, and traced it down to nixos module values leaking into the init.lua.
My init.lua, for instance, contains leaked lib.modules.mkIf attribute sets:

 395local __lspServers = {
 396   │         { extraOptions = { settings = { _type = "if", condition = true } }, name = "texlab" },
 397   │         {
 398extraOptions = {
 399settings = {
 400_type = "if",
 401condition = true,
 402content = {
 403   │                         ["rust-analyzer"] = {
 404check = { command = "clippy" },
 405typing = { autoClosingAngleBrackets = { enable = true } },
 406   │                         },
 407   │                     },
 408   │                 },
 409   │             },
 410name = "rust_analyzer",
 411   │         },
 412   │         { extraOptions = { settings = { _type = "if", condition = true } }, name = "ruff" },
                 -- and so forth.

My full config is here.

@camelpunch
Copy link

Also see this issue as described by @bpeetz. FWIW nixd formatter config, which uses the same settings path, works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants