Compare commits

...

3 Commits

Author SHA1 Message Date
Ching Pei Yang 8bddf37b43 lib: add mkSetLuaBinding 2024-08-03 22:33:23 +02:00
Ching Pei Yang 102b908deb wrapper: use lzn-auto-require loader 2024-08-03 22:28:51 +02:00
Ching Pei Yang 8dd9aa0cb5 flake: add plugin lzn-auto-require 2024-08-03 22:21:32 +02:00
4 changed files with 32 additions and 13 deletions

View File

@ -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",

View File

@ -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";

View File

@ -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<CR>"
# ];
# }
# }
# ```
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

View File

@ -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