2023-09-08 15:11:10 +02:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
2023-09-08 15:11:10 +02:00
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-05-05 19:39:35 +02:00
|
|
|
with lib;
|
|
|
|
let
|
2023-09-08 15:11:10 +02:00
|
|
|
cfg = config.plugins.lsp.servers.nixd;
|
2024-05-05 19:39:35 +02:00
|
|
|
in
|
|
|
|
{
|
2024-05-05 19:08:52 +02:00
|
|
|
# Options:
|
|
|
|
# - https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md
|
|
|
|
# - https://github.com/nix-community/nixd/blob/main/nixd/include/nixd/Controller/Configuration.h
|
|
|
|
options = {
|
2023-09-08 15:11:10 +02:00
|
|
|
formatting = {
|
2024-05-05 19:08:52 +02:00
|
|
|
command = helpers.defaultNullOpts.mkListOf types.str ''[ "nixpkgs-fmt" ]'' ''
|
2023-09-08 15:11:10 +02:00
|
|
|
Which command you would like to do formatting.
|
2024-05-05 19:08:52 +02:00
|
|
|
Explicitly set to `["nixpkgs-fmt"]` will automatically add `pkgs.nixpkgs-fmt` to the nixvim
|
2023-09-08 15:11:10 +02:00
|
|
|
environment.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-05-05 19:08:52 +02:00
|
|
|
options =
|
|
|
|
let
|
|
|
|
provider = types.submodule {
|
|
|
|
options = {
|
|
|
|
expr = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Expression to eval. Select this attrset as eval .options";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
helpers.mkNullOrOption (with helpers.nixvimTypes; attrsOf (maybeRaw provider)) ''
|
|
|
|
Tell the language server your desired option set, for completion.
|
|
|
|
This is lazily evaluated.
|
2023-09-08 15:11:10 +02:00
|
|
|
'';
|
|
|
|
|
2024-05-05 19:08:52 +02:00
|
|
|
nixpkgs =
|
|
|
|
let
|
|
|
|
provider = types.submodule {
|
|
|
|
options = {
|
|
|
|
expr = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Expression to eval. Treat it as `import <nixpkgs> { }`";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
helpers.mkNullOrOption (helpers.nixvimTypes.maybeRaw provider) ''
|
|
|
|
This expression will be interpreted as "nixpkgs" toplevel
|
|
|
|
Nixd provides package, lib completion/information from it.
|
|
|
|
'';
|
2023-09-08 15:11:10 +02:00
|
|
|
};
|
|
|
|
|
2024-05-05 19:39:35 +02:00
|
|
|
config = mkIf cfg.enable {
|
2024-05-05 19:08:52 +02:00
|
|
|
extraPackages = optional (cfg.settings.formatting.command == [ "nixpkgs-fmt" ]) pkgs.nixpkgs-fmt;
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2023-09-08 15:11:10 +02:00
|
|
|
}
|