From ecb75f49d10fe2823b0822e4e95e53f80e426742 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 24 Oct 2025 11:39:35 +0200 Subject: [PATCH] lib/options (mkSettingsOption): allow more types for settingsOption when no sub-options are explicitly declared --- lib/options.nix | 18 +++++++++++++----- plugins/lsp/language-servers/_mk-lsp.nix | 6 ++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/options.nix b/lib/options.nix index f57feb1c..db48a242 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -329,14 +329,22 @@ rec { options ? { }, description, example ? null, + # If no sub-options are explicitly declared, settings do not need to be a submodule. + submoduleType ? options != { }, }: lib.mkOption { type = - with types; - submodule { - freeformType = attrsOf lib.nixvim.lua-types.anything; - inherit options; - }; + let + anyLuaType = lib.nixvim.lua-types.anything; + in + if submoduleType then + types.submodule { + freeformType = types.attrsOf anyLuaType; + inherit options; + } + else + assert options == { }; + anyLuaType; default = { }; inherit description; example = diff --git a/plugins/lsp/language-servers/_mk-lsp.nix b/plugins/lsp/language-servers/_mk-lsp.nix index f30d71f3..bb8efe48 100644 --- a/plugins/lsp/language-servers/_mk-lsp.nix +++ b/plugins/lsp/language-servers/_mk-lsp.nix @@ -179,6 +179,12 @@ in settings = lib.nixvim.mkSettingsOption { description = "The settings for this LSP."; options = settingsOptions; + + # Some servers declare settings sub-options without using `settingsOptions`. + # This leads the `settings` option to not be typed as a submodule. + # Hence, we force all `plugins.lsp..settings` options to be types as submodules. + # FIXME This is not ideal, but `plugins.lsp` will be dropped entirely in a few months. + submoduleType = true; }; extraOptions = mkOption {