language/toml: refactor lsp usage to use lsp/presets/<name>

This commit is contained in:
Snoweuph 2026-04-11 13:32:40 +02:00
commit eb768eb982
No known key found for this signature in database
GPG key ID: BEFC41DA223CEC55

View file

@ -5,41 +5,17 @@
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib) genAttrs;
inherit (lib.meta) getExe; inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) enum; inherit (lib.types) enum listOf;
inherit (lib.nvim.types) diagnostics mkGrammarOption deprecatedSingleOrListOf; inherit (lib.nvim.types) diagnostics mkGrammarOption deprecatedSingleOrListOf;
inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.attrsets) mapListToAttrs;
cfg = config.vim.languages.toml; cfg = config.vim.languages.toml;
defaultServers = ["taplo"]; defaultServers = ["taplo"];
servers = { servers = ["taplo" "tombi"];
tombi = {
enable = true;
cmd = [
(getExe pkgs.tombi)
"lsp"
];
filetypes = ["toml"];
root_markers = [
"tombi.toml"
".git"
];
};
taplo = {
enable = true;
cmd = [
(getExe pkgs.taplo)
"lsp"
"stdio"
];
filetypes = ["toml"];
root_markers = [
".git"
];
};
};
defaultFormat = ["taplo"]; defaultFormat = ["taplo"];
formats = { formats = {
@ -93,7 +69,7 @@ in {
servers = mkOption { servers = mkOption {
description = "TOML LSP server to use"; description = "TOML LSP server to use";
type = deprecatedSingleOrListOf "vim.language.toml.lsp.servers" (enum (attrNames servers)); type = listOf (enum servers);
default = defaultServers; default = defaultServers;
}; };
}; };
@ -137,12 +113,12 @@ in {
}) })
(mkIf cfg.lsp.enable { (mkIf cfg.lsp.enable {
vim.lsp.servers = vim.lsp = {
mapListToAttrs (n: { presets = genAttrs cfg.lsp.servers (_: {enable = true;});
name = n; servers = genAttrs cfg.lsp.servers (_: {
value = servers.${n}; filetypes = ["toml"];
}) });
cfg.lsp.servers; };
}) })
(mkIf cfg.format.enable { (mkIf cfg.format.enable {