treewide: Reformat with nixfmt

This commit is contained in:
traxys 2024-05-05 19:39:35 +02:00
parent c6281260dc
commit 62f32bfc71
459 changed files with 28139 additions and 26377 deletions

View file

@ -1,26 +1,30 @@
{pkgs, ...}: {
mkLsp = {
name,
description ? "Enable ${name}.",
serverName ? name,
package ? pkgs.${name},
cmd ? (cfg: null),
settings ? (cfg: cfg),
settingsOptions ? {},
extraConfig ? cfg: {},
...
}:
# returns a module
{
pkgs,
config,
helpers,
lib,
...
}:
with lib; let
{ pkgs, ... }:
{
mkLsp =
{
name,
description ? "Enable ${name}.",
serverName ? name,
package ? pkgs.${name},
cmd ? (cfg: null),
settings ? (cfg: cfg),
settingsOptions ? { },
extraConfig ? cfg: { },
...
}:
# returns a module
{
pkgs,
config,
helpers,
lib,
...
}:
with lib;
let
cfg = config.plugins.lsp.servers.${name};
in {
in
{
options = {
plugins.lsp.servers.${name} = {
enable = mkEnableOption description;
@ -33,10 +37,7 @@
cmd = mkOption {
type = with types; nullOr (listOf str);
default =
if (cfg.package or null) != null
then cmd cfg
else null;
default = if (cfg.package or null) != null then cmd cfg else null;
};
filetypes = helpers.mkNullOrOption (types.listOf types.str) ''
@ -56,75 +57,72 @@
launched server when you open a new buffer matching the filetype of the server.
'';
onAttach =
helpers.mkCompositeOption "Server specific on_attach behavior."
{
override = mkOption {
type = types.bool;
default = false;
description = "Override the global `plugins.lsp.onAttach` function.";
};
function = mkOption {
type = types.lines;
description = ''
Body of the on_attach function.
The argument `client` and `bufnr` is provided.
'';
};
onAttach = helpers.mkCompositeOption "Server specific on_attach behavior." {
override = mkOption {
type = types.bool;
default = false;
description = "Override the global `plugins.lsp.onAttach` function.";
};
function = mkOption {
type = types.lines;
description = ''
Body of the on_attach function.
The argument `client` and `bufnr` is provided.
'';
};
};
settings = helpers.mkSettingsOption {
description = "The settings for this LSP.";
options = settingsOptions;
};
extraOptions = mkOption {
default = {};
default = { };
type = types.attrsOf types.anything;
description = "Extra options for the ${name} language server.";
};
};
};
config =
mkIf cfg.enable
{
extraPackages = [cfg.package];
config = mkIf cfg.enable {
extraPackages = [ cfg.package ];
plugins.lsp.enabledServers = [
{
name = serverName;
extraOptions =
{
inherit (cfg) cmd filetypes autostart;
root_dir = cfg.rootDir;
on_attach =
helpers.ifNonNull' cfg.onAttach
(
helpers.mkRaw ''
function(client, bufnr)
${optionalString (!cfg.onAttach.override) config.plugins.lsp.onAttach}
${cfg.onAttach.function}
end
''
);
settings = settings cfg.settings;
}
// cfg.extraOptions;
}
plugins.lsp.enabledServers = [
{
name = serverName;
extraOptions = {
inherit (cfg) cmd filetypes autostart;
root_dir = cfg.rootDir;
on_attach = helpers.ifNonNull' cfg.onAttach (
helpers.mkRaw ''
function(client, bufnr)
${optionalString (!cfg.onAttach.override) config.plugins.lsp.onAttach}
${cfg.onAttach.function}
end
''
);
settings = settings cfg.settings;
} // cfg.extraOptions;
}
];
};
imports =
let
basePluginPath = [
"plugins"
"lsp"
"servers"
name
];
};
imports = let
basePluginPath = ["plugins" "lsp" "servers" name];
basePluginPathString = concatStringsSep "." basePluginPath;
in [
(
mkRemovedOptionModule
(basePluginPath ++ ["extraSettings"])
"You can use `${basePluginPathString}.extraOptions.settings` instead."
)
(extraConfig cfg)
];
basePluginPathString = concatStringsSep "." basePluginPath;
in
[
(mkRemovedOptionModule (
basePluginPath ++ [ "extraSettings" ]
) "You can use `${basePluginPathString}.extraOptions.settings` instead.")
(extraConfig cfg)
];
};
}