Skip to content

Commit

Permalink
nix: Add option to use alejandra for formatting
Browse files Browse the repository at this point in the history
Applying patch from nix-community/rnix-lsp#89
directly on top of current rnix-lsp and providing UseAlejandra command
to switch to in when Vim is already running.
  • Loading branch information
YorikSar committed Dec 6, 2022
1 parent 61a6ae5 commit 0d644c4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions nix/nix.nix
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -14,13 +37,15 @@
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()
'';
};

home.packages = with pkgs; [
lorri
nixUnstable
rnix-lsp
rnix-lsp-alejandra
];

launchd = {
Expand Down

0 comments on commit 0d644c4

Please sign in to comment.