From 866f0e2f51f14c6e3bfbc340779523327448b6a9 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 30 Apr 2024 21:14:10 +0200 Subject: [PATCH] plugins/lsp/nil-ls: refactor options --- .../lsp/language-servers/nil_ls-settings.nix | 78 ++++++++++++------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/plugins/lsp/language-servers/nil_ls-settings.nix b/plugins/lsp/language-servers/nil_ls-settings.nix index c02911464..60ac43550 100644 --- a/plugins/lsp/language-servers/nil_ls-settings.nix +++ b/plugins/lsp/language-servers/nil_ls-settings.nix @@ -1,42 +1,58 @@ { lib, helpers }: -# Options: -# - https://github.com/oxalica/nil/blob/main/docs/configuration.md?plain=1# +# All available settings are documented here: +# https://github.com/oxalica/nil/blob/main/docs/configuration.md with lib; { formatting = { - command = helpers.defaultNullOpts.mkListOf types.str "null" '' - External formatter command (with arguments). - It should accepts file content in stdin and print the formatted code into stdout. - ''; + command = helpers.defaultNullOpts.mkListOf' { + type = types.str; + default = null; + description = '' + External formatter command (with arguments). + It should accepts file content in stdin and print the formatted code into stdout. + ''; + example = [ "nixpkgs-fmt" ]; + }; }; diagnostics = { - ignored = helpers.defaultNullOpts.mkListOf types.str "[]" '' + ignored = helpers.defaultNullOpts.mkListOf types.str [ ] '' Ignored diagnostic kinds. The kind identifier is a snake_cased_string usually shown together with the diagnostic message. ''; - excludedFiles = helpers.defaultNullOpts.mkListOf types.str "[]" '' - Files to exclude from showing diagnostics. Useful for generated files. - It accepts an array of paths. Relative paths are joint to the workspace root. - Glob patterns are currently not supported. - ''; + excludedFiles = helpers.defaultNullOpts.mkListOf' { + type = types.str; + default = [ ]; + description = '' + Files to exclude from showing diagnostics. Useful for generated files. + It accepts an array of paths. Relative paths are joint to the workspace root. + Glob patterns are currently not supported. + ''; + example = [ "Cargo.nix" ]; + }; }; nix = { - binary = helpers.defaultNullOpts.mkStr "nix" '' - The path to the `nix` binary. - ''; + binary = helpers.defaultNullOpts.mkStr' { + default = "nix"; + description = "The path to the `nix` binary."; + example = "/run/current-system/sw/bin/nix"; + }; - maxMemoryMB = helpers.defaultNullOpts.mkInt 2560 '' - The heap memory limit in MiB for `nix` evaluation. - Currently it only applies to flake evaluation when `autoEvalInputs` is enabled, and only works - for Linux. - Other `nix` invocations may be also applied in the future. - `null` means no limit. - As a reference, `nix flake show --legacy nixpkgs` usually requires about 2GiB memory. - ''; + maxMemoryMB = helpers.defaultNullOpts.mkUnsignedInt' { + default = 2560; + example = 1024; + description = '' + The heap memory limit in MiB for `nix` evaluation. + Currently it only applies to flake evaluation when `autoEvalInputs` is enabled, and only works + for Linux. + Other `nix` invocations may be also applied in the future. + `null` means no limit. + As a reference, `nix flake show --legacy nixpkgs` usually requires about 2GiB memory. + ''; + }; flake = { autoArchive = helpers.defaultNullOpts.mkBool false '' @@ -51,13 +67,17 @@ with lib; The evaluation result is used to improve completion, but may cost lots of time and/or memory. ''; - nixpkgsInputName = helpers.defaultNullOpts.mkStr "nixpkgs" '' - The input name of nixpkgs for NixOS options evaluation. + nixpkgsInputName = helpers.defaultNullOpts.mkStr' { + default = "nixpkgs"; + example = "nixos"; + description = '' + The input name of nixpkgs for NixOS options evaluation. - The options hierarchy is used to improve completion, but may cost lots of time and/or memory. - If this value is `null` or is not found in the workspace flake's inputs, NixOS options are - not evaluated. - ''; + The options hierarchy is used to improve completion, but may cost lots of time and/or memory. + If this value is `null` or is not found in the workspace flake's inputs, NixOS options are + not evaluated. + ''; + }; }; }; }