From cd92dcf9869d409e5e1cca9ec4ba7fb31226249c Mon Sep 17 00:00:00 2001 From: Pei Yang Ching Date: Tue, 25 Jun 2024 17:10:43 +0200 Subject: [PATCH 01/33] flake: add lz.n plugin --- flake.lock | 17 +++++++++++++++++ flake.nix | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/flake.lock b/flake.lock index de29be3..3fdd96d 100644 --- a/flake.lock +++ b/flake.lock @@ -843,6 +843,22 @@ "type": "github" } }, + "plugin-lz-n": { + "flake": false, + "locked": { + "lastModified": 1719248596, + "narHash": "sha256-GBDmumQ0XYxawPdUncI6fW413MMSjGl6TwCQTexUpnE=", + "owner": "nvim-neorocks", + "repo": "lz.n", + "rev": "24f9fe1024c936d9fa6a5607b73a4ae1958c9d77", + "type": "github" + }, + "original": { + "owner": "nvim-neorocks", + "repo": "lz.n", + "type": "github" + } + }, "plugin-mind-nvim": { "flake": false, "locked": { @@ -1856,6 +1872,7 @@ "plugin-lspkind": "plugin-lspkind", "plugin-lspsaga": "plugin-lspsaga", "plugin-lualine": "plugin-lualine", + "plugin-lz-n": "plugin-lz-n", "plugin-mind-nvim": "plugin-mind-nvim", "plugin-minimap-vim": "plugin-minimap-vim", "plugin-modes-nvim": "plugin-modes-nvim", diff --git a/flake.nix b/flake.nix index 0290638..bb9ad0c 100644 --- a/flake.nix +++ b/flake.nix @@ -102,6 +102,12 @@ }; ## Plugins + # Lazy loading + plugin-lz-n = { + url = "github:nvim-neorocks/lz.n"; + flake = false; + }; + # LSP plugins plugin-nvim-lspconfig = { url = "github:neovim/nvim-lspconfig"; From 9d4b95b7403edf44d66f3b20222b22523c72755a Mon Sep 17 00:00:00 2001 From: Pei Yang Ching Date: Tue, 25 Jun 2024 17:16:49 +0200 Subject: [PATCH 02/33] add lazy module skeleton --- modules/modules.nix | 1 + modules/wrapper/lazy/config.nix | 14 ++++++++++++++ modules/wrapper/lazy/default.nix | 6 ++++++ modules/wrapper/lazy/lazy.nix | 15 +++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 modules/wrapper/lazy/config.nix create mode 100644 modules/wrapper/lazy/default.nix create mode 100644 modules/wrapper/lazy/lazy.nix diff --git a/modules/modules.nix b/modules/modules.nix index a00cea6..a995754 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -50,6 +50,7 @@ wrapper = map (p: ./wrapper + "/${p}") [ "build" "rc" + "lazy" "warnings" ]; diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix new file mode 100644 index 0000000..53df6ae --- /dev/null +++ b/modules/wrapper/lazy/config.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: let + inherit (lib.modules) mkIf; + cfg = config.vim.lazy; +in { + config.vim = mkIf cfg.enable { + startPlugins = ["lz-n"]; + + # optPlugins = + }; +} diff --git a/modules/wrapper/lazy/default.nix b/modules/wrapper/lazy/default.nix new file mode 100644 index 0000000..fa40127 --- /dev/null +++ b/modules/wrapper/lazy/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./lazy.nix + ./config.nix + ]; +} diff --git a/modules/wrapper/lazy/lazy.nix b/modules/wrapper/lazy/lazy.nix new file mode 100644 index 0000000..0b11ab1 --- /dev/null +++ b/modules/wrapper/lazy/lazy.nix @@ -0,0 +1,15 @@ +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) enum; +in { + options.vim.lazy = { + enable = mkEnableOption "plugin lazy-loading" // {default = true;}; + loader = mkOption { + description = "Lazy loader to use"; + type = enum ["lz.n"]; + default = "lz.n"; + }; + + # plugins = mkOption {}; + }; +} From 49cb74afe5101be253e518ecd8718139fa485931 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching Date: Tue, 25 Jun 2024 17:47:33 +0200 Subject: [PATCH 03/33] lib: add basic lz.n plugin spec type --- lib/types/plugins.nix | 81 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 8 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index c0e89d6..b590ed5 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -6,8 +6,7 @@ inherit (lib.options) mkOption; inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair; inherit (lib.strings) hasPrefix removePrefix; - inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr; - + inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr oneOf; # Get the names of all flake inputs that start with the given prefix. fromInputs = { inputs, @@ -51,8 +50,79 @@ }; }; }; + + luaInline = lib.mkOptionType { + name = "luaInline"; + check = x: lib.nvim.lua.isLuaInline x; + }; + + lznPluginType = submodule { + options = { + ## Should probably infer from the actual plugin somehow + ## In general this is the name passed to packadd, so the dir name of the plugin + # name = mkOption { + # type= str; + # } + + package = pluginType; + + before = mkOption { + type = nullOr luaInline; + description = "Code to run before plugin is loaded"; + default = null; + }; + + after = mkOption { + type = nullOr luaInline; + description = "Code to run after plugin is loaded"; + default = null; + }; + + event = mkOption { + description = "Lazy-load on event"; + default = "null"; + type = let + event = submodule { + options = { + event = mkOption { + type = nullOr (either str (listOf str)); + description = "Exact event name"; + example = "BufEnter"; + }; + pattern = mkOption { + type = nullOr (either str (listOf str)); + description = "Event pattern"; + example = "BufEnter *.lua"; + }; + }; + }; + in + oneOf [str (listOf str) event]; + }; + + cmd = mkOption { + description = "Lazy-load on command"; + default = null; + type = nullOr (either str (listOf str)); + }; + + ft = mkOption { + description = "Lazy-load on filetype"; + default = null; + type = nullOr (either str (listOf str)); + }; + + keys = mkOption { + description = "Lazy-load on key mapping"; + default = null; + type = nullOr (either str (listOf str)); # TODO: support lz.n.KeysSpec + }; + + # TODO: enabled, beforeAll, colorscheme, priority, load + }; + }; in { - inherit extraPluginType fromInputs pluginType; + inherit extraPluginType fromInputs pluginType luaInline lznPluginType; pluginsOpt = { description, @@ -64,11 +134,6 @@ in { type = pluginsType; }; - luaInline = lib.mkOptionType { - name = "luaInline"; - check = x: lib.nvim.lua.isLuaInline x; - }; - /* opts is a attrset of options, example: ``` From 5f5dd220807be07a1124c821d56a9064e6c38085 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 00:28:10 +0200 Subject: [PATCH 04/33] lz.n: add basic lazy.plugins option --- modules/wrapper/lazy/lazy.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/wrapper/lazy/lazy.nix b/modules/wrapper/lazy/lazy.nix index 0b11ab1..90ae055 100644 --- a/modules/wrapper/lazy/lazy.nix +++ b/modules/wrapper/lazy/lazy.nix @@ -1,6 +1,7 @@ {lib, ...}: let inherit (lib.options) mkOption mkEnableOption; inherit (lib.types) enum; + inherit (lib.nvim.types) lznPluginTableType; in { options.vim.lazy = { enable = mkEnableOption "plugin lazy-loading" // {default = true;}; @@ -10,6 +11,19 @@ in { default = "lz.n"; }; - # plugins = mkOption {}; + plugins = mkOption { + default = {}; + type = lznPluginTableType; + description = "list of plugins to lazy load"; + example = '' + { + toggleterm-nvim = { + package = "toggleterm-nvim"; + after = "require('toggleterm').setup{}"; + cmd = ["ToggleTerm"]; + }; + } + ''; + }; }; } From d1495cd13dfc3e9f472fa3335958c86bd98fda8c Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 00:28:18 +0200 Subject: [PATCH 05/33] lz.n: load lz.n --- modules/wrapper/lazy/config.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 53df6ae..a2bd73a 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -3,12 +3,26 @@ config, ... }: let + inherit (builtins) toJSON; inherit (lib.modules) mkIf; + inherit (lib.attrsets) mapAttrsToList; + inherit (lib.generators) mkLuaInline; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.lazy; + + toLznSpec = name: plugin: + (removeAttrs plugin ["package"]) + // {__HACK = mkLuaInline "nil, [1] = ${toJSON name}";}; + lznSpecs = mapAttrsToList toLznSpec cfg.plugins; in { config.vim = mkIf cfg.enable { startPlugins = ["lz-n"]; - # optPlugins = + optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; + + luaConfigRC.lzn-load = entryAnywhere '' + require('lz.n').load(${toLuaObject lznSpecs}) + ''; }; } From 201b2969a13cb3d48ddd434278e656ea294bedc1 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 00:52:42 +0200 Subject: [PATCH 06/33] lib: export lznPluginType --- lib/types/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types/default.nix b/lib/types/default.nix index 928bbae..98c64cc 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -9,7 +9,7 @@ typesCustom = import ./custom.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType lznPluginType; inherit (typesLanguage) diagnostics mkGrammarOption; inherit (typesCustom) anythingConcatLists char; } From 315c93b5c517f4a24887b592058afb7664703e62 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 01:40:11 +0200 Subject: [PATCH 07/33] lib: add lznPluginTableType --- lib/types/default.nix | 2 +- lib/types/plugins.nix | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/types/default.nix b/lib/types/default.nix index 98c64cc..170667d 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -9,7 +9,7 @@ typesCustom = import ./custom.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType lznPluginType; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType lznPluginType lznPluginTableType; inherit (typesLanguage) diagnostics mkGrammarOption; inherit (typesCustom) anythingConcatLists char; } diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index b590ed5..fd8e8bb 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -56,6 +56,7 @@ check = x: lib.nvim.lua.isLuaInline x; }; + lznPluginTableType = attrsOf lznPluginType; lznPluginType = submodule { options = { ## Should probably infer from the actual plugin somehow @@ -64,7 +65,9 @@ # type= str; # } - package = pluginType; + package = mkOption { + type = pluginType; + }; before = mkOption { type = nullOr luaInline; @@ -80,7 +83,7 @@ event = mkOption { description = "Lazy-load on event"; - default = "null"; + default = null; type = let event = submodule { options = { @@ -97,7 +100,7 @@ }; }; in - oneOf [str (listOf str) event]; + nullOr (oneOf [str (listOf str) event]); }; cmd = mkOption { @@ -122,7 +125,7 @@ }; }; in { - inherit extraPluginType fromInputs pluginType luaInline lznPluginType; + inherit extraPluginType fromInputs pluginType luaInline lznPluginType lznPluginTableType; pluginsOpt = { description, From d39f03f4db4d94b62882d1c137fb3bc0b770f780 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 01:40:26 +0200 Subject: [PATCH 08/33] flake: update lz.n --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 3fdd96d..a83c266 100644 --- a/flake.lock +++ b/flake.lock @@ -846,11 +846,11 @@ "plugin-lz-n": { "flake": false, "locked": { - "lastModified": 1719248596, - "narHash": "sha256-GBDmumQ0XYxawPdUncI6fW413MMSjGl6TwCQTexUpnE=", + "lastModified": 1719989949, + "narHash": "sha256-oHwmlLgdJJDz5+gs1KLAa2MHQAadM/JYmHGfep9yl28=", "owner": "nvim-neorocks", "repo": "lz.n", - "rev": "24f9fe1024c936d9fa6a5607b73a4ae1958c9d77", + "rev": "4c790ba2c3789f580aa019712bbe3112f85e73a0", "type": "github" }, "original": { From 618ade49c1a5e815be54342fee66c8b21886a396 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:39:53 +0200 Subject: [PATCH 09/33] wrap lazy init code in function --- modules/wrapper/lazy/lazy.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/wrapper/lazy/lazy.nix b/modules/wrapper/lazy/lazy.nix index 90ae055..151c087 100644 --- a/modules/wrapper/lazy/lazy.nix +++ b/modules/wrapper/lazy/lazy.nix @@ -19,7 +19,7 @@ in { { toggleterm-nvim = { package = "toggleterm-nvim"; - after = "require('toggleterm').setup{}"; + after = lib.generators.mkLuaInline "function() require('toggleterm').setup{} end"; cmd = ["ToggleTerm"]; }; } From 00193e902e3044fad688b453515b25e509fb5839 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:00:41 +0200 Subject: [PATCH 10/33] switch to other hacky array-table syntax --- modules/wrapper/lazy/config.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index a2bd73a..749a320 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -3,18 +3,16 @@ config, ... }: let - inherit (builtins) toJSON; inherit (lib.modules) mkIf; inherit (lib.attrsets) mapAttrsToList; - inherit (lib.generators) mkLuaInline; inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.lazy; - toLznSpec = name: plugin: + toLuaLznSpec = name: plugin: (removeAttrs plugin ["package"]) - // {__HACK = mkLuaInline "nil, [1] = ${toJSON name}";}; - lznSpecs = mapAttrsToList toLznSpec cfg.plugins; + // {"@1" = name;}; + lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; in { config.vim = mkIf cfg.enable { startPlugins = ["lz-n"]; From b3e54e5be4de238a03b6bb0b464baa10f4926702 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:36:49 +0200 Subject: [PATCH 11/33] fix: broken optPlugins --- modules/default.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index 227cf20..5130965 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -88,10 +88,7 @@ inputs: { # built (or "normalized") plugins that are modified builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; - builtOptPlugins = map (package: { - plugin = package; - optional = true; - }) (buildConfigPlugins vimOptions.optPlugins); + builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins); # additional Lua and Python3 packages, mapped to their respective functions # to conform to the format makeNeovimConfig expects. end user should From 89b80ac8fb6300bf6a6eef41a59db38b064c5b78 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:52:47 +0200 Subject: [PATCH 12/33] lazy: add setupOpts support --- lib/types/plugins.nix | 17 +++++++++++++++++ modules/wrapper/lazy/config.nix | 20 +++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index fd8e8bb..ca5c614 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -65,10 +65,27 @@ # type= str; # } + # Non-lz.n options + package = mkOption { type = pluginType; + description = "Plugin package"; }; + setupModule = mkOption { + type = nullOr str; + description = "Lua module to run setup function on."; + default = null; + }; + + setupOpts = mkOption { + type = submodule {freeformType = attrsOf anything;}; + description = "Options to pass to the setup function"; + default = {}; + }; + + # lz.n options + before = mkOption { type = nullOr luaInline; description = "Code to run before plugin is loaded"; diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 749a320..5e25939 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -3,15 +3,29 @@ config, ... }: let + inherit (builtins) toJSON; inherit (lib.modules) mkIf; inherit (lib.attrsets) mapAttrsToList; + inherit (lib.generators) mkLuaInline; + inherit (lib.strings) optionalString; inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.lazy; - toLuaLznSpec = name: plugin: - (removeAttrs plugin ["package"]) - // {"@1" = name;}; + toLuaLznSpec = name: spec: + (removeAttrs spec ["package" "setupModule" "setupOpts"]) + // { + "@1" = name; + after = mkLuaInline '' + function() + ${ + optionalString (spec.setupModule != null) + "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})" + } + ${optionalString (spec.after != null) spec.after} + end + ''; + }; lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; in { config.vim = mkIf cfg.enable { From 8369ca560238204afbd7282874098390f56dec08 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:23:53 +0200 Subject: [PATCH 13/33] nvim-tree: use lazy --- modules/plugins/filetree/nvimtree/config.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index b97b1e4..f1e75b5 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -16,8 +16,6 @@ inherit (self.options.vim.filetree.nvimTree) mappings; in { config = mkIf cfg.enable { - vim.startPlugins = ["nvim-tree-lua"]; - vim.maps.normal = mkMerge [ (mkBinding cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) (mkBinding cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) @@ -29,6 +27,17 @@ in { "t" = "+NvimTree"; }; + vim.lazy = { + plugins = { + nvim-tree-lua = { + package = "nvim-tree-lua"; + setupModule = "nvim-tree"; + inherit (cfg) setupOpts; + cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"]; + }; + }; + }; + vim.pluginRC.nvimtreelua = entryAnywhere '' ${ optionalString cfg.setupOpts.disable_netrw '' @@ -38,8 +47,6 @@ in { '' } - require'nvim-tree'.setup(${toLuaObject cfg.setupOpts}) - ${ optionalString cfg.openOnSetup '' -- autostart behaviour From 593435318d784f2800d5f278a7cfbd6bb27ecfdb Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Thu, 1 Aug 2024 22:33:51 +0200 Subject: [PATCH 14/33] lib: add lz.n KeySpec --- lib/types/plugins.nix | 62 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index ca5c614..7e65abc 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -6,7 +6,7 @@ inherit (lib.options) mkOption; inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair; inherit (lib.strings) hasPrefix removePrefix; - inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr oneOf; + inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr oneOf bool; # Get the names of all flake inputs that start with the given prefix. fromInputs = { inputs, @@ -56,6 +56,64 @@ check = x: lib.nvim.lua.isLuaInline x; }; + lznKeysSpec = submodule { + apply = x: + x + // { + "@1" = x.lhs; + "@2" = x.rhs; + }; + + options = { + desc = mkOption { + description = "Description of the key map"; + type = nullOr str; + default = null; + }; + + noremap = mkOption { + description = "TBD"; + type = bool; + default = false; + }; + + expr = mkOption { + description = "TBD"; + type = bool; + default = false; + }; + + nowait = mkOption { + description = "TBD"; + type = bool; + default = false; + }; + + ft = mkOption { + description = "TBD"; + type = nullOr (listOf str); + default = null; + }; + + lhs = mkOption { + type = str; + description = "Key to bind to"; + }; + + rhs = mkOption { + type = nullOr str; + default = null; + description = "Action to trigger"; + }; + + mode = mkOption { + description = "Modes to bind in"; + type = listOf str; + default = ["n"]; + }; + }; + }; + lznPluginTableType = attrsOf lznPluginType; lznPluginType = submodule { options = { @@ -135,7 +193,7 @@ keys = mkOption { description = "Lazy-load on key mapping"; default = null; - type = nullOr (either str (listOf str)); # TODO: support lz.n.KeysSpec + type = nullOr (oneOf [str (listOf str) lznKeysSpec]); # TODO: support lz.n.KeysSpec }; # TODO: enabled, beforeAll, colorscheme, priority, load From a4ad8654a6f6bb8703285f24ef88f45022c93b81 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:10:20 +0200 Subject: [PATCH 15/33] lib: fix lz.n map type --- lib/types/plugins.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 7e65abc..c993f1d 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -109,7 +109,7 @@ mode = mkOption { description = "Modes to bind in"; type = listOf str; - default = ["n"]; + default = ["n" "x" "s" "o"]; }; }; }; @@ -193,7 +193,7 @@ keys = mkOption { description = "Lazy-load on key mapping"; default = null; - type = nullOr (oneOf [str (listOf str) lznKeysSpec]); # TODO: support lz.n.KeysSpec + type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]); # TODO: support lz.n.KeysSpec }; # TODO: enabled, beforeAll, colorscheme, priority, load From 4efc5d89d0038ca4268ac9bcb6fcfdc6524afd3b Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 14:45:29 +0200 Subject: [PATCH 16/33] remove unused --- lib/types/plugins.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index c993f1d..7fa7448 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -57,13 +57,6 @@ }; lznKeysSpec = submodule { - apply = x: - x - // { - "@1" = x.lhs; - "@2" = x.rhs; - }; - options = { desc = mkOption { description = "Description of the key map"; From 085d5d304a9b9cd3500e7d9d574d66ebca1d605a Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 14:45:48 +0200 Subject: [PATCH 17/33] lz.n: process key maps --- modules/wrapper/lazy/config.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 5e25939..645dfb9 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -12,8 +12,23 @@ inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.lazy; + toLuzLznKeySpec = { + desc, + noremap, + expr, + nowait, + ft, + lhs, + rhs, + mode, + }: { + "@1" = lhs; + "@2" = rhs; + inherit desc noremap expr nowait ft mode; + }; + toLuaLznSpec = name: spec: - (removeAttrs spec ["package" "setupModule" "setupOpts"]) + (removeAttrs spec ["package" "setupModule" "setupOpts" "keys"]) // { "@1" = name; after = mkLuaInline '' @@ -25,6 +40,7 @@ ${optionalString (spec.after != null) spec.after} end ''; + keys = map toLuzLznKeySpec spec.keys; }; lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; in { From 4d519811798df731ead46a1acb06b3dc9320c026 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 16:38:42 +0200 Subject: [PATCH 18/33] lib: add lznKeySpec example --- lib/types/plugins.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 7fa7448..f328aae 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -186,7 +186,12 @@ keys = mkOption { description = "Lazy-load on key mapping"; default = null; - type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]); # TODO: support lz.n.KeysSpec + type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]); + example = '' + keys = [ + {lhs = "s"; rhs = ":NvimTreeToggle"; desc = "Toggle NvimTree"} + ] + ''; }; # TODO: enabled, beforeAll, colorscheme, priority, load From c6071b7da46f2b208f3e4cc0889d21f89230160f Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 18:01:34 +0200 Subject: [PATCH 19/33] lz.n: missing type check --- modules/wrapper/lazy/config.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 645dfb9..5ce308b 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -3,7 +3,7 @@ config, ... }: let - inherit (builtins) toJSON; + inherit (builtins) toJSON typeOf head length; inherit (lib.modules) mkIf; inherit (lib.attrsets) mapAttrsToList; inherit (lib.generators) mkLuaInline; @@ -40,7 +40,10 @@ ${optionalString (spec.after != null) spec.after} end ''; - keys = map toLuzLznKeySpec spec.keys; + keys = + if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set" + then map toLuzLznKeySpec spec.keys + else spec.keys; }; lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; in { From b437242689a98c3a1aeaa8c10a6befcda7940c20 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 18:05:33 +0200 Subject: [PATCH 20/33] lib: change lz.n spec "inlineLua" types to str --- lib/types/plugins.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index f328aae..84bf78a 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -138,14 +138,14 @@ # lz.n options before = mkOption { - type = nullOr luaInline; - description = "Code to run before plugin is loaded"; + type = nullOr str; + description = "Lua code to run before plugin is loaded. This will be wrapped in a function."; default = null; }; after = mkOption { - type = nullOr luaInline; - description = "Code to run after plugin is loaded"; + type = nullOr str; + description = "Lua code to run after plugin is loaded. This will be wrapped in a function."; default = null; }; From 42c60df933da985bada8e5177ce307069ad6a139 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 18:41:41 +0200 Subject: [PATCH 21/33] lib: add mkLznBinding --- lib/binds.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/binds.nix b/lib/binds.nix index 8c9e9a6..ae16d73 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -67,6 +67,10 @@ mkLuaBinding binding.value action binding.description; pushDownDefault = attr: mapAttrs (_: mkDefault) attr; + + mkLznBinding = mode: lhs: rhs: desc: { + inherit mode lhs rhs desc; + }; }; in binds From 664d7154b404a515394724df57f1bef2d2ab728b Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 14:46:05 +0200 Subject: [PATCH 22/33] nvim-tree: move to lz.n keymaps --- modules/plugins/filetree/nvimtree/config.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index f1e75b5..9e9d4e3 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -4,11 +4,11 @@ pkgs, ... }: let + inherit (builtins) filter; inherit (lib.strings) optionalString; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.binds) mkBinding; + inherit (lib.modules) mkIf; + inherit (lib.nvim.binds) mkLznBinding; inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.filetree.nvimTree; @@ -16,13 +16,6 @@ inherit (self.options.vim.filetree.nvimTree) mappings; in { config = mkIf cfg.enable { - vim.maps.normal = mkMerge [ - (mkBinding cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) - (mkBinding cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) - (mkBinding cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) - (mkBinding cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) - ]; - vim.binds.whichKey.register = pushDownDefault { "t" = "+NvimTree"; }; @@ -34,6 +27,13 @@ in { setupModule = "nvim-tree"; inherit (cfg) setupOpts; cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"]; + + keys = filter ({lhs, ...}: lhs != null) [ + (mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) + (mkLznBinding ["n"] cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) + (mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) + (mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) + ]; }; }; }; From f43d3835f111e41d619cb2d744a39895e8d94a6b Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 16:59:41 +0200 Subject: [PATCH 23/33] nvim-tree: load nvim-tree if openOnSetup --- modules/plugins/filetree/nvimtree/config.nix | 1 + modules/wrapper/lazy/config.nix | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index 9e9d4e3..47a85d6 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -49,6 +49,7 @@ in { ${ optionalString cfg.openOnSetup '' + require('lz.n').trigger_load("nvim-tree-lua") -- autostart behaviour -- Open on startup has been deprecated -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 5ce308b..b1afb5b 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -9,7 +9,7 @@ inherit (lib.generators) mkLuaInline; inherit (lib.strings) optionalString; inherit (lib.nvim.lua) toLuaObject; - inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.dag) entryBefore; cfg = config.vim.lazy; toLuzLznKeySpec = { @@ -52,7 +52,7 @@ in { optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; - luaConfigRC.lzn-load = entryAnywhere '' + luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] '' require('lz.n').load(${toLuaObject lznSpecs}) ''; }; From fc58c85524ce15a7ff0478354cb5d3fd95cf8b7c Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 19:18:25 +0200 Subject: [PATCH 24/33] lib: add mkLznBinding --- lib/binds.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/binds.nix b/lib/binds.nix index ae16d73..61fec95 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -71,6 +71,24 @@ mkLznBinding = mode: lhs: rhs: desc: { inherit mode lhs rhs desc; }; + + # Usage: + # + # ``` + # vim.lazy.plugins = { + # telescope = { + # # ... + # keys = builtins.filter ({lhs, ...}: lhs != null) [ + # mkSetLznBinding mapping ":Telescope" + # ]; + # } + # } + # ``` + mkSetLznBinding = binding: action: { + lhs = binding.value; + rhs = action; + desc = binding.description; + }; }; in binds From e086dc02fe72b708ec2d24689bbd30baa8b18566 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 19:46:52 +0200 Subject: [PATCH 25/33] lz.n: wrap lua code in function --- modules/wrapper/lazy/config.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index b1afb5b..38be892 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -31,6 +31,15 @@ (removeAttrs spec ["package" "setupModule" "setupOpts" "keys"]) // { "@1" = name; + before = + if spec.before != null + then + mkLuaInline '' + function() + ${spec.before} + end + '' + else null; after = mkLuaInline '' function() ${ From c7df5c97f3a1f6f4032e49a2829482f2d562e3b5 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 19:48:13 +0200 Subject: [PATCH 26/33] lz.n: generate less code --- modules/wrapper/lazy/config.nix | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 38be892..b3fdb7d 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -40,15 +40,21 @@ end '' else null; - after = mkLuaInline '' - function() - ${ - optionalString (spec.setupModule != null) - "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})" - } - ${optionalString (spec.after != null) spec.after} - end - ''; + + after = + if spec.setupModule == null && spec.after == null + then null + else + mkLuaInline '' + function() + ${ + optionalString (spec.setupModule != null) + "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})" + } + ${optionalString (spec.after != null) spec.after} + end + ''; + keys = if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set" then map toLuzLznKeySpec spec.keys From 8dd9aa0cb5d90bdbbaa91b8eca6069e575242934 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:21:32 +0200 Subject: [PATCH 27/33] flake: add plugin lzn-auto-require --- flake.lock | 17 +++++++++++++++++ flake.nix | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/flake.lock b/flake.lock index a83c266..2818da5 100644 --- a/flake.lock +++ b/flake.lock @@ -859,6 +859,22 @@ "type": "github" } }, + "plugin-lzn-auto-require": { + "flake": false, + "locked": { + "lastModified": 1722716302, + "narHash": "sha256-YehBjQ4m3i0yEnts7HhWW78N6g40hblfcl94d7l9aN4=", + "owner": "horriblename", + "repo": "lzn-auto-require", + "rev": "57567c9db26a3b5b143ae91f35143c34706e8881", + "type": "github" + }, + "original": { + "owner": "horriblename", + "repo": "lzn-auto-require", + "type": "github" + } + }, "plugin-mind-nvim": { "flake": false, "locked": { @@ -1873,6 +1889,7 @@ "plugin-lspsaga": "plugin-lspsaga", "plugin-lualine": "plugin-lualine", "plugin-lz-n": "plugin-lz-n", + "plugin-lzn-auto-require": "plugin-lzn-auto-require", "plugin-mind-nvim": "plugin-mind-nvim", "plugin-minimap-vim": "plugin-minimap-vim", "plugin-modes-nvim": "plugin-modes-nvim", diff --git a/flake.nix b/flake.nix index bb9ad0c..c383e73 100644 --- a/flake.nix +++ b/flake.nix @@ -108,6 +108,11 @@ flake = false; }; + plugin-lzn-auto-require = { + url = "github:horriblename/lzn-auto-require"; + flake = false; + }; + # LSP plugins plugin-nvim-lspconfig = { url = "github:neovim/nvim-lspconfig"; From 102b908deb1f0c4f37b473b14d4e80ab4c99dbbf Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:28:51 +0200 Subject: [PATCH 28/33] wrapper: use lzn-auto-require loader --- modules/wrapper/rc/config.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index be299f3..22bc4b5 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -6,7 +6,7 @@ inherit (builtins) map mapAttrs filter; inherit (lib.options) mkOption; inherit (lib.attrsets) filterAttrs getAttrs attrValues attrNames; - inherit (lib.strings) concatLines concatMapStringsSep; + inherit (lib.strings) concatLines concatMapStringsSep optionalString; inherit (lib.misc) mapAttrsFlatten; inherit (lib.trivial) showWarnings; inherit (lib.types) str nullOr; @@ -138,6 +138,8 @@ in { pluginConfigs = entryAfter ["theme"] pluginConfigs; extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs; mappings = entryAfter ["extraPluginConfigs"] mappings; + # FIXME: put this somewhere less stupid + footer = entryAfter ["mappings"] (optionalString config.vim.lazy.enable "require('lzn-auto-require.loader').register_loader()"); }; builtLuaConfigRC = let From 8bddf37b43937ca17d8ac27e3e1d0ebf97529a92 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:33:09 +0200 Subject: [PATCH 29/33] lib: add mkSetLuaBinding --- lib/binds.nix | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/binds.nix b/lib/binds.nix index 61fec95..f8f915e 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -3,6 +3,7 @@ inherit (lib.modules) mkIf mkDefault; inherit (lib.types) nullOr str; inherit (lib.attrsets) isAttrs mapAttrs; + inherit (lib.generators) mkLuaInline; binds = rec { mkLuaBinding = key: action: desc: @@ -72,23 +73,17 @@ inherit mode lhs rhs desc; }; - # Usage: - # - # ``` - # vim.lazy.plugins = { - # telescope = { - # # ... - # keys = builtins.filter ({lhs, ...}: lhs != null) [ - # mkSetLznBinding mapping ":Telescope" - # ]; - # } - # } - # ``` mkSetLznBinding = binding: action: { lhs = binding.value; rhs = action; desc = binding.description; }; + + mkSetLuaLznBinding = binding: action: { + lhs = binding.value; + rhs = mkLuaInline "function() ${action} end"; + desc = binding.description; + }; }; in binds From 682779b0f3f8acbf18bbb767792cc02334ef439e Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:46:06 +0200 Subject: [PATCH 30/33] fixup! wrapper: use lzn-auto-require loader --- modules/wrapper/lazy/config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index b3fdb7d..7baefa4 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -63,7 +63,7 @@ lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; in { config.vim = mkIf cfg.enable { - startPlugins = ["lz-n"]; + startPlugins = ["lz-n" "lzn-auto-require"]; optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; From 9faddddf8498dc263eb841e500a7e69fd9b00502 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 4 Aug 2024 02:23:30 +0200 Subject: [PATCH 31/33] flake: update lzn-auto-require --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 2818da5..cec7eba 100644 --- a/flake.lock +++ b/flake.lock @@ -862,11 +862,11 @@ "plugin-lzn-auto-require": { "flake": false, "locked": { - "lastModified": 1722716302, - "narHash": "sha256-YehBjQ4m3i0yEnts7HhWW78N6g40hblfcl94d7l9aN4=", + "lastModified": 1722727896, + "narHash": "sha256-h7Dx3zBkUYamQY6lcuQrwAMgBpPqskLnA6WsbefHzMU=", "owner": "horriblename", "repo": "lzn-auto-require", - "rev": "57567c9db26a3b5b143ae91f35143c34706e8881", + "rev": "c6b47e148a1ff9709e802f68c2c8b558a9a8de9b", "type": "github" }, "original": { From 432cb9c87bc947cd37c6e4bc963feac709288de3 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 4 Aug 2024 02:24:10 +0200 Subject: [PATCH 32/33] lib: allow luaInline in lz.n map action --- lib/types/plugins.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 84bf78a..d6dc79a 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -94,9 +94,9 @@ }; rhs = mkOption { - type = nullOr str; + type = nullOr (either str luaInline); default = null; - description = "Action to trigger"; + description = "Action to trigger. luaInline code will be wrapped in a function."; }; mode = mkOption { From f6500bbd0583ba221fba2e8c57a625414906fbe8 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 4 Aug 2024 02:27:59 +0200 Subject: [PATCH 33/33] add TODO --- lib/types/plugins.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index d6dc79a..86f6101 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -96,6 +96,7 @@ rhs = mkOption { type = nullOr (either str luaInline); default = null; + # FIXME: use a separate flag to indicate lua instead of luaInline description = "Action to trigger. luaInline code will be wrapped in a function."; };