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,10 +1,18 @@
{
pkgs,
config,
pkgs,
lib,
...
}: let
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString getExe;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.lists) isList;
inherit (lib.strings) optionalString;
inherit (lib.types) either listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryBefore;
cfg = config.vim.languages.lua;
in {
@ -12,14 +20,15 @@ in {
enable = mkEnableOption "Lua language support";
treesitter = {
enable = mkEnableOption "Lua Treesitter support" // {default = config.vim.languages.enableTreesitter;};
package = nvim.types.mkGrammarOption pkgs "lua";
package = mkGrammarOption pkgs "lua";
};
lsp = {
enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.languages.enableLSP;};
package = mkOption {
description = "LuaLS package, or the command to run as a list of strings";
type = with types; either package (listOf str);
type = either package (listOf str);
default = pkgs.lua-language-server;
};
@ -43,7 +52,7 @@ in {
${optionalString cfg.lsp.neodev.enable "before_init = require('neodev.lsp').before_init;"}
cmd = ${
if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${getExe cfg.lsp.package}"}''
};
}
@ -52,7 +61,7 @@ in {
(mkIf cfg.lsp.neodev.enable {
vim.startPlugins = ["neodev-nvim"];
vim.luaConfigRC.neodev = nvim.dag.entryBefore ["lua-lsp"] ''
vim.luaConfigRC.neodev = entryBefore ["lua-lsp"] ''
require("neodev").setup({})
'';
})