which-key.nvim icon indicating copy to clipboard operation
which-key.nvim copied to clipboard

feat: Allow mapped lua functions to have arguments

Open ben-hansske opened this issue 4 years ago • 0 comments

With a lot of lua plugins it is quite common to have bindings that call a lua function which can take some additional options. It would be nice if these arguments could be stored together with the function. Then upon invoking the mapping, the arguments could be unpacked and forwarded to the function. I think having an option called args that holds the arguments as an array would be a nice improvement.

One could then do

["<Leader>ff"] = { require"telescope.builtin".find_files, args = { require"telescope.themes".get_ivy() }, "Find files, but with ivy-theme" }

instead of

["<Leader>ff"] = { function() require"telescope.builtin".find_files(require"telescope.themes".get_ivy()) end, "Find files, but with ivy-theme" }

ben-hansske avatar Nov 29 '21 23:11 ben-hansske

Sorry, I'm not a fan of this. I'd rather keep it simple and similar to the vim.keymap api.

Thank you for the suggestion though!

folke avatar Sep 06 '22 18:09 folke