From 0d644c401bc4aeab36adf00fbb430f593014fb37 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Tue, 6 Dec 2022 12:32:51 +0100 Subject: [PATCH] nix: Add option to use alejandra for formatting Applying patch from https://github.com/nix-community/rnix-lsp/pull/89 directly on top of current rnix-lsp and providing UseAlejandra command to switch to in when Vim is already running. --- nix/nix.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/nix/nix.nix b/nix/nix.nix index 57231e8..2a70f4c 100644 --- a/nix/nix.nix +++ b/nix/nix.nix @@ -1,4 +1,27 @@ { config, pkgs, ... }: +let + rnix-lsp-alejandra = + let + src = pkgs.fetchFromGitHub { + owner = "nix-community"; + repo = "rnix-lsp"; + # https://github.com/nix-community/rnix-lsp/pull/89 + rev = "9189b50b34285b2a9de36a439f6c990fd283c9c7"; + sha256 = "sha256-ZnUtvwkcz7QlAiqQxhI4qVUhtVR+thLhG3wQlle7oZg="; + }; + in + pkgs.rnix-lsp.overrideAttrs (old: { + inherit src; + cargoDeps = old.cargoDeps.overrideAttrs (old: { + inherit src; + outputHash = "sha256-nT+tvOYiqjxLL+bHH/6PMPJbZDg5znaHEJol4LkCBCA="; + }); + cargoBuildFlags = [ "--no-default-features" "--features" "alejandra" ]; + postInstall = '' + mv $out/bin/rnix-lsp $out/bin/rnix-lsp-alejandra + ''; + }); +in { programs.direnv = { @@ -14,6 +37,7 @@ programs.neovim = { extraConfig = '' let g:LanguageClient_serverCommands['nix'] = ['rnix-lsp'] + command! UseAlejandra call LanguageClient#shutdown()|let g:LanguageClient_serverCommands['nix'] = ['rnix-lsp-alejandra']|call LanguageClient#startServer() ''; }; @@ -21,6 +45,7 @@ lorri nixUnstable rnix-lsp + rnix-lsp-alejandra ]; launchd = {