From 132c3da8ece1f2518992257985a612690b2eeb90 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Thu, 6 Feb 2025 13:08:31 +0100 Subject: [PATCH] languages/nix: add nixd This adds the [nixd](https://github.com/nix-community/nixd) language server. --- docs/release-notes/rl-0.8.md | 4 ++++ modules/plugins/languages/nix.nix | 34 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 661aee1d..3a09171b 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -139,3 +139,7 @@ - Add `vim.languages.zig.dap` support through pkgs.lldb dap adapter. Code Inspiration from `vim.languages.clang.dap` implementation. + +[nezia1](https://github.com/nezia1) + +- Add support for [nixd](https://github.com/nix-community/nixd) language server. diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 4056a415..d6ca6d32 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -59,6 +59,40 @@ } ''; }; + + nixd = { + package = pkgs.nixd; + internalFormatter = true; + lspConfig = '' + lspconfig.nixd.setup{ + capabilities = capabilities, + ${ + if cfg.format.enable + then useFormat + else noFormat + }, + cmd = ${packageToCmd cfg.lsp.package "nixd"}, + ${optionalString cfg.format.enable '' + settings = { + nixd = { + ${optionalString (cfg.format.type == "alejandra") + '' + formatting = { + command = {"${cfg.format.package}/bin/alejandra", "--quiet"}, + }, + ''} + ${optionalString (cfg.format.type == "nixfmt") + '' + formatting = { + command = {"${cfg.format.package}/bin/nixfmt"}, + }, + ''} + }, + }, + ''} + } + ''; + }; }; defaultFormat = "alejandra";