goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.78k stars 104 forks source link

feat: allow to use function as rhs for button keymap #207

Closed jedrzejboczar closed 6 months ago

jedrzejboczar commented 1 year ago

This is useful when generating some button actions programmatically to avoid defining new globally accesible functions.

goolord commented 1 year ago

why not just set opts.callback = rhs? i'm kinda wary about overloading neovim api

goolord commented 1 year ago

i would have used vim.keymap but it wasn't available when I wrote the plugin, and just using opts.callback honestly doesn't feel that dirty to me

jedrzejboczar commented 1 year ago

Ah, ok, my button() wrapper code is pretty complicated so when searching why functions do not work I didn't initially find a way to support function rhs there, so I did this change to alpha. I now changed my code to conditionally use opts.callback so this PR is not needed. It might be useful as a convenience for users (as probably most are now used to vim.keymap.set) but if you don't want to complicate the code then feel free to close this PR.

goolord commented 6 months ago

https://github.com/goolord/alpha-nvim/commit/7dc1bd80fac6da1b15a952e9b8fe245cbe5c0287