Skip to content

Commit 6be28a9

Browse files
committed
plugins/lsp/nixd: refactor
1 parent f14aa75 commit 6be28a9

File tree

3 files changed

+51
-67
lines changed

3 files changed

+51
-67
lines changed

plugins/lsp/language-servers/default.nix

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
config,
55
pkgs,
66
...
7-
}@args:
7+
}:
88
with lib;
99
let
10-
nixdSettings = import ./nixd.nix args;
11-
1210
servers = [
1311
{
1412
name = "ansiblels";
@@ -408,7 +406,10 @@ let
408406
description = "nixd for Nix";
409407
package = pkgs.nixd;
410408
settings = cfg: { nixd = cfg; };
411-
settingsOptions = nixdSettings.options;
409+
settingsOptions = import ./nixd-settings.nix { inherit lib helpers; };
410+
extraConfig = cfg: {
411+
extraPackages = optional (cfg.settings.formatting.command == [ "nixpkgs-fmt" ]) pkgs.nixpkgs-fmt;
412+
};
412413
}
413414
{
414415
name = "nushell";
@@ -683,6 +684,4 @@ in
683684
./rust-analyzer.nix
684685
./svelte.nix
685686
];
686-
687-
config = lib.mkMerge [ nixdSettings.config ];
688687
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{ lib, helpers }:
2+
# Options:
3+
# - https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md
4+
# - https://github.com/nix-community/nixd/blob/main/nixd/include/nixd/Controller/Configuration.h
5+
with lib;
6+
{
7+
formatting = {
8+
command = helpers.defaultNullOpts.mkListOf types.str ''[ "nixpkgs-fmt" ]'' ''
9+
Which command you would like to do formatting.
10+
Explicitly set to `["nixpkgs-fmt"]` will automatically add `pkgs.nixpkgs-fmt` to the nixvim
11+
environment.
12+
'';
13+
};
14+
15+
options =
16+
let
17+
provider = types.submodule {
18+
options = {
19+
expr = mkOption {
20+
type = types.str;
21+
description = "Expression to eval. Select this attrset as eval .options";
22+
};
23+
};
24+
};
25+
in
26+
helpers.mkNullOrOption (with helpers.nixvimTypes; attrsOf (maybeRaw provider)) ''
27+
Tell the language server your desired option set, for completion.
28+
This is lazily evaluated.
29+
'';
30+
31+
nixpkgs =
32+
let
33+
provider = types.submodule {
34+
options = {
35+
expr = mkOption {
36+
type = types.str;
37+
description = "Expression to eval. Treat it as `import <nixpkgs> { }`";
38+
};
39+
};
40+
};
41+
in
42+
helpers.mkNullOrOption (helpers.nixvimTypes.maybeRaw provider) ''
43+
This expression will be interpreted as "nixpkgs" toplevel
44+
Nixd provides package, lib completion/information from it.
45+
'';
46+
}

plugins/lsp/language-servers/nixd.nix

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)