Open diniamo opened 3 months ago
It would be cool if mode
would be a string that allows multiple modes, such as modes = "niv"
for normal
, insert
, visual
. I believe I've used something similar before in nixvim
and the UX is much better than having to inherit functions from lib and use e.g. vim.maps.normal = lib.mkMerge [ (mkBinding ....) ... ];
and then the same for other maps. listOf str
is unnecessarily verbose, because modes can be indicated by a single letter, so we gain nothing by that.
something like this maybe?
vim.maps = {
"<leader>x" = [
{mode = ["n", "v"]; action = ":foo<CR>";}
{mode = "i"; action = "<cmd>bar<cr>";}
];
"<leader>y" = {mode = "c"; action = "...";}
};
["n", "v"]
ah yes, the infamous comma in a Nix list...
something like this maybe?
vim.maps = { "<leader>x" = [ {mode = ["n", "v"]; action = ":foo<CR>";} {mode = "i"; action = "<cmd>bar<cr>";} ]; "<leader>y" = {mode = "c"; action = "...";} };
what am I looking at
@ppenguin I'm pretty sure there is a map mode whose short form is 2 characters, and besides, a list makes more sense, as that's used in the lua api too.
heh I misread
though the current rewrite has the problem of not being able to make different bindings for the same key on different modes (what I suggested)
that aside, string (e.g. "nvc" for normal + visual + command) mode should work with this rewrite
p.s. whoever thought comma-less list is good syntax deserves to stub their toe tonight
Make vim.maps a list then, idk
⚠️ Please verify that this feature request has NOT been suggested before.
🏷️ Feature Type
Other
🔖 Feature description
The current implementation isn't great, because the implementation is messy, and it's not flexible, since the user can't specify modes.
✔️ Solution
My suggestion is very similar to the previous one, except binds are directly in
vim.maps
and there is a new mode attribute in their definition, eg.:(mode is of type
either str (listOf str)
)❓ Alternatives
No response
📝 Additional Context
This would still allow the user to have a very similar structure, eg.: