Open ModProg opened 2 years ago
I'm not sure this should be made async even if it was currently possible.
I don't need to have them be async, async would just make them easier to use to avoid ending up in callback hell, e.g. if you want to call a bunch of them in sequence. Maybe there could be a general way to await the callback functions in the neovim api.
Right, but not all callbacks serve the same purpose.
Some are used to save a function to be executed later in response to an event or a command (like those bound to keymaps or autocommands), some are just a way to fake async to avoid blocking the thread, usually used when dealing with IO (like those in :h lsp-handler
).
vim.ui.*
fall into this category, hence why I'd leave them as callbacks.Makes sense, I think there are both use cases for the ui callbacks.
I think there are two use cases:
npm init
where you are asked multiple times for input)My use case is the latter, I load config files and if they change, I query the user if they want to approve the changes, afterwards I'll continue loading, merging all the configurations that were approved and applying them, so I need to wait for the user to respond for each changed file before I continue executing the function.
Hence, why I wanted these as async.
Obviously these can also be used for a different use case, where you e.g. list a bunch of commands and the user selects one which is then executed.
I think I could use both, and shouldn't be too bad doing it with callbacks.
One great thing to have would be https://neovim.io/doc/user/lua.html#lua-ui Sadly they are only usable with callbacks, but with #38 this could maybe be made to be async instead.
Especially because they can be overridden using plugins like telescope.