Skip to content

Commit 0d644c4

Browse files
committed
nix: Add option to use alejandra for formatting
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.
1 parent 61a6ae5 commit 0d644c4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

nix/nix.nix

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
{ config, pkgs, ... }:
2+
let
3+
rnix-lsp-alejandra =
4+
let
5+
src = pkgs.fetchFromGitHub {
6+
owner = "nix-community";
7+
repo = "rnix-lsp";
8+
# https://github.com/nix-community/rnix-lsp/pull/89
9+
rev = "9189b50b34285b2a9de36a439f6c990fd283c9c7";
10+
sha256 = "sha256-ZnUtvwkcz7QlAiqQxhI4qVUhtVR+thLhG3wQlle7oZg=";
11+
};
12+
in
13+
pkgs.rnix-lsp.overrideAttrs (old: {
14+
inherit src;
15+
cargoDeps = old.cargoDeps.overrideAttrs (old: {
16+
inherit src;
17+
outputHash = "sha256-nT+tvOYiqjxLL+bHH/6PMPJbZDg5znaHEJol4LkCBCA=";
18+
});
19+
cargoBuildFlags = [ "--no-default-features" "--features" "alejandra" ];
20+
postInstall = ''
21+
mv $out/bin/rnix-lsp $out/bin/rnix-lsp-alejandra
22+
'';
23+
});
24+
in
225

326
{
427
programs.direnv = {
@@ -14,13 +37,15 @@
1437
programs.neovim = {
1538
extraConfig = ''
1639
let g:LanguageClient_serverCommands['nix'] = ['rnix-lsp']
40+
command! UseAlejandra call LanguageClient#shutdown()|let g:LanguageClient_serverCommands['nix'] = ['rnix-lsp-alejandra']|call LanguageClient#startServer()
1741
'';
1842
};
1943

2044
home.packages = with pkgs; [
2145
lorri
2246
nixUnstable
2347
rnix-lsp
48+
rnix-lsp-alejandra
2449
];
2550

2651
launchd = {

0 commit comments

Comments
 (0)