How can you set a keymap to execute lua code? #1599
-
I'm currently in the process of porting my Astronvim config to nixvim (I'm still not sure if I can carry through with it). Since astronvim has a lot of custom lua code for simple actions, like closing a buffer, I created a custom But when I config the following in the keymaps = [
{
key = "<leader>c";
action = "require('myutils.buffer').close()";
options.desc = "Close buffer";
}
] Then, neovim doesn't actually call the lua function. The resulting mapping in the {
["action"] = "require('myutils.buffer').close()",
["key"] = "<leader>c",
["options"] = { ["desc"] = "Close buffer" },
}, I'm new to nix and nixvim (therefore the learning project) and the documentation didn't help me too much here, unfortunately. :( Since this is some basic stuff, I'd have liked to define these mappings not where I define the utils plugin. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Use nixvim's "raw type": ```nix
action.__raw = "require('myutils.buffer').close"; Or action.__raw = "function() require('myutils.buffer').close() end"; You can use |
Beta Was this translation helpful? Give feedback.
Use nixvim's "raw type":
Or
You can use
helpers.mkRaw
too (which does the same as above)