From c220da2af96200dac0cbfe62192ec5f1eabe7e13 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 27 Apr 2024 16:00:54 +0200 Subject: [PATCH 1/3] fidget: remove ineffectful option whether you set clear_on_detach to true or false you still get the default behaviour --- modules/plugins/visuals/fidget/fidget.nix | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/modules/plugins/visuals/fidget/fidget.nix b/modules/plugins/visuals/fidget/fidget.nix index 6897800..3cdcee8 100644 --- a/modules/plugins/visuals/fidget/fidget.nix +++ b/modules/plugins/visuals/fidget/fidget.nix @@ -42,21 +42,6 @@ in { type = bool; default = false; }; - clear_on_detach = mkOption { - description = "Clear notification group when LSP server detaches"; - type = bool; - default = true; - apply = clear: - if clear - then - mkLuaInline '' - function(client_id) - local client = vim.lsp.get_client_by_id(client_id) - return client and client.name or nil - end - '' - else null; - }; notification_group = mkOption { description = "How to get a progress message's notification group key"; type = str; From 0c4f7a544d75125b4f5d9a2d87502ff3626239b5 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 27 Apr 2024 16:01:37 +0200 Subject: [PATCH 2/3] lib: fix crash on non-attrset arg --- lib/lua.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lua.nix b/lib/lua.nix index 0ed2505..9e67b3f 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -58,7 +58,7 @@ in rec { # Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first luaTable = items: ''{${concatStringsSep "," items}}''; - isLuaInline = {_type ? null, ...}: _type == "lua-inline"; + isLuaInline = object: (object._type or null) == "lua-inline"; toLuaObject = args: if isAttrs args From f0631c2d2624c3d4c2f5d8d4e181639fc52c19b3 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 27 Apr 2024 16:06:31 +0200 Subject: [PATCH 3/3] fidget: do not apply mkLuaInline to str opts --- modules/plugins/visuals/fidget/fidget.nix | 49 +++++++++-------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/modules/plugins/visuals/fidget/fidget.nix b/modules/plugins/visuals/fidget/fidget.nix index 3cdcee8..481dfeb 100644 --- a/modules/plugins/visuals/fidget/fidget.nix +++ b/modules/plugins/visuals/fidget/fidget.nix @@ -7,8 +7,8 @@ inherit (lib.options) mkEnableOption mkOption; inherit (lib.attrsets) mapAttrs; inherit (lib.strings) toUpper; - inherit (lib.types) int float bool str enum listOf attrsOf; - inherit (lib.nvim.types) mkPluginSetupOption; + inherit (lib.types) int float bool str enum listOf attrsOf anything; + inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.generators) mkLuaInline; in { imports = [ @@ -44,13 +44,12 @@ in { }; notification_group = mkOption { description = "How to get a progress message's notification group key"; - type = str; - default = '' + type = luaInline; + default = mkLuaInline '' function(msg) return msg.lsp_client.name end ''; - apply = mkLuaInline; }; ignore = mkOption { description = "Ignore LSP servers by name"; @@ -157,33 +156,29 @@ in { }; format_message = mkOption { description = "How to format a progress message"; - type = str; - default = '' + type = luaInline; + default = mkLuaInline '' require("fidget.progress.display").default_format_message ''; - apply = mkLuaInline; }; format_annote = mkOption { description = "How to format a progress annotation"; - type = str; - default = '' + type = luaInline; + default = mkLuaInline '' function(msg) return msg.title end ''; - apply = mkLuaInline; }; format_group_name = mkOption { description = "How to format a progress notification group's name"; - type = str; - default = '' + type = luaInline; + default = mkLuaInline '' function(group) return tostring(group) end ''; - 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: mkLuaInline lua); + type = attrsOf (attrsOf anything); + default = {rust_analyzer = {name = "rust-analyzer";};}; }; }; @@ -225,21 +220,19 @@ in { }; configs = mkOption { description = "How to configure notification groups when instantiated"; - type = attrsOf str; - default = {default = "require('fidget.notification').default_config";}; - apply = mapAttrs (key: lua: mkLuaInline lua); + type = attrsOf luaInline; + default = {default = mkLuaInline "require('fidget.notification').default_config";}; }; redirect = mkOption { description = "Conditionally redirect notifications to another backend"; - type = str; - default = '' + type = luaInline; + default = mkLuaInline '' function(msg, level, opts) if opts and opts.on_open then return require("fidget.integration.nvim-notify").delegate(msg, level, opts) end end ''; - apply = mkLuaInline; }; view = { @@ -265,13 +258,12 @@ in { }; render_message = mkOption { description = "How to render notification messages"; - type = str; - default = '' + type = luaInline; + default = mkLuaInline '' function(msg, cnt) return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg) end ''; - apply = mkLuaInline; }; }; @@ -371,11 +363,10 @@ in { }; path = mkOption { description = "Where Fidget writes its logs to"; - type = str; - default = '' + type = luaInline; + default = mkLuaInline '' string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache")) ''; - apply = mkLuaInline; }; }; };