From 3722f88c5da34c0c891108774f8e22ff7f26aea8 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Mon, 28 Apr 2025 18:02:00 +0100 Subject: [PATCH] modules/lsp: move server module to dedicated file --- modules/lsp/default.nix | 53 +++-------------------------------------- modules/lsp/server.nix | 50 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 50 deletions(-) create mode 100644 modules/lsp/server.nix diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index 49291ddc..2e52fcb7 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -4,57 +4,10 @@ ... }: let - inherit (lib) mkOption types; + inherit (lib) types; inherit (lib.nixvim) toLuaObject; cfg = config.lsp; - - serverType = types.submodule { - options = { - enable = lib.mkEnableOption "the language server"; - - activate = lib.mkOption { - type = types.bool; - description = '' - Whether to call `vim.lsp.enable()` for this server. - ''; - default = true; - example = false; - }; - - package = lib.mkOption { - type = with types; nullOr package; - default = null; - description = '' - Package to use for this language server. - - Alternatively, the language server should be available on your `$PATH`. - ''; - }; - - config = mkOption { - type = with types; attrsOf anything; - description = '' - Configurations for each language server. - ''; - default = { }; - example = { - cmd = [ - "clangd" - "--background-index" - ]; - root_markers = [ - "compile_commands.json" - "compile_flags.txt" - ]; - filetypes = [ - "c" - "cpp" - ]; - }; - }; - }; - }; in { options.lsp = { @@ -70,8 +23,8 @@ in enable = lib.mkEnableOption "inlay hints globally"; }; - servers = mkOption { - type = types.attrsOf serverType; + servers = lib.mkOption { + type = types.attrsOf (types.submodule ./server.nix); description = '' LSP servers to enable and/or configure. diff --git a/modules/lsp/server.nix b/modules/lsp/server.nix new file mode 100644 index 00000000..c551b405 --- /dev/null +++ b/modules/lsp/server.nix @@ -0,0 +1,50 @@ +{ lib, ... }: +let + inherit (lib) types; +in +{ + options = { + enable = lib.mkEnableOption "the language server"; + + activate = lib.mkOption { + type = types.bool; + description = '' + Whether to call `vim.lsp.enable()` for this server. + ''; + default = true; + example = false; + }; + + package = lib.mkOption { + type = with types; nullOr package; + default = null; + description = '' + Package to use for this language server. + + Alternatively, the language server should be available on your `$PATH`. + ''; + }; + + config = lib.mkOption { + type = with types; attrsOf anything; + description = '' + Configurations for each language server. + ''; + default = { }; + example = { + cmd = [ + "clangd" + "--background-index" + ]; + root_markers = [ + "compile_commands.json" + "compile_flags.txt" + ]; + filetypes = [ + "c" + "cpp" + ]; + }; + }; + }; +}