Skip to content
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

Terminal mode: When checking if there is a process attached to terminal, it should not block neovim instance #60

Closed
Civitasv opened this issue Jun 6, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@Civitasv
Copy link
Owner

Civitasv commented Jun 6, 2023

Currently, I use these codes to check if there is a process is finished, which is need to chain callback.

https://github.com/Civitasv/cmake-tools.nvim/blob/3e5f768977a7825e70335feff2cfac56e54ac33b/lua/cmake-tools/terminal.lua#LL542C1-L560C6

But this will block neovim instance, we should find a non-blocking or async way to check this.

@Civitasv Civitasv added the bug Something isn't working label Jun 6, 2023
@Civitasv Civitasv pinned this issue Jun 6, 2023
@rohit-kumar-j
Copy link
Contributor

rohit-kumar-j commented Jun 6, 2023

Note to people using cmake_always_use_terminal=true

If you do not chaining of commands and vim.wait() to block your neovim instance, you can hit the CTRL C once or twice after launching the terminals.
This will lose the chained commands, but you can access neovim while the CMakeTask is running.


The reason we added this option is because:

  1. We want to keep the build output from all the commands, along with the commands persistent.
  2. And to view the exact commands that are being sent to the terminal on each run.
  3. We want to give full access to the user (users who donot use CMake Presets) to set/modify specific cmake flags to the terminal directly in the command line for quick experimentation.

Kindly provide feedback on this feature... 👋

@rohit-kumar-j
Copy link
Contributor

Currently, I use these codes to check if there is a process is finished, which is need to chain callback.

https://github.com/Civitasv/cmake-tools.nvim/blob/3e5f768977a7825e70335feff2cfac56e54ac33b/lua/cmake-tools/terminal.lua#LL542C1-L560C6

But this will block neovim instance, we should find a non-blocking or async way to check this.

(Posible solution?)...

If we do a background non-blocking vim.wait() that looks inside the build directory every n milliseconds until the currently running cmake produces the CMakeCache.txt or something like that which tells the status of the cmake process is completed, once it finds this (effectively a more verbose on_success() condition), maybe even the timestamp of the file... We can then chain the next command with a small delay.

We will need to create new functions for checking status of files like how the codemodel targets are obatined...

Since the solution is cmake specific solution, I think this will be a decent solution without the explicit on_success() callback.

@rohit-kumar-j
Copy link
Contributor

@Civitasv
Copy link
Owner Author

Civitasv commented Jun 7, 2023

Okay, hopefully someone can anwser it. 😄

@rohit-kumar-j
Copy link
Contributor

Seems like this can be accomplished by writing a dummy query into a file.

@Civitasv, do you have any idea how we may do this?

@Civitasv
Copy link
Owner Author

I've researched some plugins about terminal, cannot find a suitable solution to get notified when terminal executes commands successfully. But I find another way, See it at #63.

@rohit-kumar-j
Copy link
Contributor

Nice! That is a simple and effective solution :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants