modules/languages: finish making lib calls explicit

This commit is contained in:
raf 2024-03-09 08:49:22 +03:00
commit dfc7c6737f
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
16 changed files with 301 additions and 217 deletions

View file

@ -1,11 +1,17 @@
{
pkgs,
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib) isList nvim getExe mkEnableOption mkOption types mkMerge mkIf;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.lists) isList;
inherit (lib.types) bool enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
cfg = config.vim.languages.go;
@ -19,13 +25,14 @@
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/gopls", "serve"}''
},
}
'';
};
};
defaultDebugger = "delve";
debuggers = {
delve = {
@ -73,7 +80,7 @@ in {
treesitter = {
enable = mkEnableOption "Go treesitter" // {default = config.vim.languages.enableTreesitter;};
package = nvim.types.mkGrammarOption pkgs "go";
package = mkGrammarOption pkgs "go";
};
lsp = {
@ -81,14 +88,14 @@ in {
server = mkOption {
description = "Go LSP server to use";
type = with types; enum (attrNames servers);
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Go LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
type = with types; either package (listOf str);
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
@ -96,17 +103,17 @@ in {
dap = {
enable = mkOption {
description = "Enable Go Debug Adapter";
type = types.bool;
type = bool;
default = config.vim.languages.enableDAP;
};
debugger = mkOption {
description = "Go debugger to use";
type = with types; enum (attrNames debuggers);
type = enum (attrNames debuggers);
default = defaultDebugger;
};
package = mkOption {
description = "Go debugger package.";
type = types.package;
type = package;
default = debuggers.${cfg.dap.debugger}.package;
};
};