modules/languages: switch to explicit lib calls

This commit is contained in:
raf 2024-03-08 20:34:19 +03:00
commit 6d3f28283f
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
3 changed files with 34 additions and 24 deletions

View file

@ -1,19 +1,25 @@
{
pkgs,
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib) isList nvim optionalString mkEnableOption mkOption types mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib) nvim;
inherit (lib.strings) optionalString;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool enum package either listOf str nullOr;
inherit (lib.modules) mkIf mkMerge;
cfg = config.vim.languages.clang;
defaultServer = "ccls";
packageToCmd = package: defaultCmd:
if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package
else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }'';
cfg = config.vim.languages.clang;
defaultServer = "ccls";
servers = {
ccls = {
package = pkgs.ccls;
@ -79,7 +85,7 @@ in {
C syntax for headers. Can fix treesitter errors, see:
https://www.reddit.com/r/neovim/comments/orfpcd/question_does_the_c_parser_from_nvimtreesitter/
'';
type = types.bool;
type = bool;
default = false;
};
@ -94,20 +100,20 @@ in {
server = mkOption {
description = "The clang LSP server to use";
type = with types; enum (attrNames servers);
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "clang 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;
};
opts = mkOption {
description = "Options to pass to clang LSP server";
type = with types; nullOr str;
type = nullOr str;
default = null;
};
};
@ -115,17 +121,17 @@ in {
dap = {
enable = mkOption {
description = "Enable clang Debug Adapter";
type = types.bool;
type = bool;
default = config.vim.languages.enableDAP;
};
debugger = mkOption {
description = "clang debugger to use";
type = with types; enum (attrNames debuggers);
type = enum (attrNames debuggers);
default = defaultDebugger;
};
package = mkOption {
description = "clang debugger package.";
type = types.package;
type = package;
default = debuggers.${cfg.dap.debugger}.package;
};
};