plugins: switch to mkLuaInline

This commit is contained in:
Ching Pei Yang 2024-03-16 09:29:32 +00:00
commit 5d8eb192d7
8 changed files with 80 additions and 79 deletions

View file

@ -9,8 +9,7 @@
inherit (lib.strings) toUpper;
inherit (lib.types) int float bool str enum listOf attrsOf;
inherit (lib.nvim.types) mkPluginSetupOption;
rawLua = lua: {__raw = lua;};
inherit (lib.generators) mkLuaInline;
in {
imports = [
(mkRenamedOptionModule ["vim" "visuals" "fidget-nvim" "align" "bottom"] ["vim" "visuals" "fidget-nvim" "setupOpts" "notification" "window" "align"])
@ -50,7 +49,7 @@ in {
apply = clear:
if clear
then
rawLua ''
mkLuaInline ''
function(client_id)
local client = vim.lsp.get_client_by_id(client_id)
return client and client.name or nil
@ -66,7 +65,7 @@ in {
return msg.lsp_client.name
end
'';
apply = rawLua;
apply = mkLuaInline;
};
ignore = mkOption {
description = "Ignore LSP servers by name";
@ -177,7 +176,7 @@ in {
default = ''
require("fidget.progress.display").default_format_message
'';
apply = rawLua;
apply = mkLuaInline;
};
format_annote = mkOption {
description = "How to format a progress annotation";
@ -185,7 +184,7 @@ in {
default = ''
function(msg) return msg.title end
'';
apply = rawLua;
apply = mkLuaInline;
};
format_group_name = mkOption {
description = "How to format a progress notification group's name";
@ -193,13 +192,13 @@ in {
default = ''
function(group) return tostring(group) end
'';
apply = rawLua;
apply = mkLuaInline;
};
overrides = mkOption {
description = "Override options from the default notification config";
type = attrsOf str;
default = {rust_analyzer = "{ name = 'rust-analyzer' }";};
apply = mapAttrs (key: lua: rawLua lua);
apply = mapAttrs (key: lua: mkLuaInline lua);
};
};
@ -227,7 +226,7 @@ in {
description = "Minimum notifications level";
type = enum ["debug" "info" "warn" "error"];
default = "info";
apply = filter: rawLua "vim.log.levels.${toUpper filter}";
apply = filter: mkLuaInline "vim.log.levels.${toUpper filter}";
};
history_size = mkOption {
description = "Number of removed messages to retain in history";
@ -243,7 +242,7 @@ in {
description = "How to configure notification groups when instantiated";
type = attrsOf str;
default = {default = "require('fidget.notification').default_config";};
apply = mapAttrs (key: lua: rawLua lua);
apply = mapAttrs (key: lua: mkLuaInline lua);
};
redirect = mkOption {
description = "Conditionally redirect notifications to another backend";
@ -255,7 +254,7 @@ in {
end
end
'';
apply = rawLua;
apply = mkLuaInline;
};
view = {
@ -287,7 +286,7 @@ in {
return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg)
end
'';
apply = rawLua;
apply = mkLuaInline;
};
};
@ -373,7 +372,7 @@ in {
description = "Minimum logging level";
type = enum ["debug" "error" "info" "trace" "warn" "off"];
default = "warn";
apply = logLevel: rawLua "vim.log.levels.${toUpper logLevel}";
apply = logLevel: mkLuaInline "vim.log.levels.${toUpper logLevel}";
};
max_size = mkOption {
description = "Maximum log file size, in KB";
@ -391,7 +390,7 @@ in {
default = ''
string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache"))
'';
apply = rawLua;
apply = mkLuaInline;
};
};
};