-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: provide a stable callback-based lua API #245
Comments
Hey @Civitasv I was wondering if you would accept a PR with such changes (make all callbacks adhere to the same format, make sure they are always called even in case of command failure)? |
We actually have some getters in cmake-tools.nvim/lua/cmake-tools/init.lua Lines 1020 to 1108 in 5893fef
I think this indeed is helpful. And I'm happy to accept this. Edit: These are all getters: https://github.com/Civitasv/cmake-tools.nvim/blob/master/docs/howto.md#mimic-ui-of-cmake-tools-toolbar-in-visual-studio-code |
Hey, thank you for all the work on this plugin. It really makes interacting with CMake much easier and I use it a lot :)
That said, I think the plugin can be improved by providing a stable API.
Describe the problem or limitation you are having
The plugin's API is difficult to use by another plugin.
Describe the solution you'd like
fn(is_ok, result_or_error)
callback signature in all lua APIDescribe alternatives you've considered
Working with the API as-is. It's quite difficult, and here's an example:
I'm working on this plugin, and as part of it I need to list all executables in the CMake project.
To do that, I need to generate the CMake files first. Thus, I would have to call
cmake.generate()
, and thencmake.get_targets
. However, there are 2 problems:cmake.generate
only calls the callback if the call is successful. This means that I cannot schedule another operation after it: once I docmake.generate()
, I have no way of knowing when it is done. I can pass the callback, but if the call fails, I'll never know. One option is to do timeouts, but then if CMake fails quickly (say, due to invalidCMakeLists
file), the user would have to wait until the timeout (which can be very long for complexCMakeLists
) before the interface would react.Additional context
If the proposed changes make sense to you (change callback signature, ensure callback is always called), I can take a crack at it in a PR.
The text was updated successfully, but these errors were encountered: