cmake-tools.nvim
cmake-tools.nvim copied to clipboard
Integrate Toggleterm as terminal and executor
Toggleterm is a simple wrapper around native terminals. It extends native terminals and allows to execute processes on individual terminals and much more. It doesn't integrate nicely with cmake-tools however, where currently cmake-tools will use the native backend ignoring the toggleterm ones. It would be nice if there would be an additional Toggleterm backend.
Toggleterm provides access for custom terminals / customization with e.g. Terminal:new. It shouldn't be too complicated. Let's see if I find the time in the next days to implement this. Opinions welcome!
Now, toggleterm is supported using the overseer
, have you tried it?
Edit: add configuration
cmake_executor = { -- executor to use
name = "overseer", -- name of the executor
...
default_opts = { -- a list of default and possible values for executors
...
overseer = {
new_task_opts = {
strategy = {
"toggleterm",
direction = "horizontal",
autos_croll = true,
quit_on_exit = "success"
}
}, -- options to pass into the `overseer.new_task` command
...
},
...
},
Yes, i've tried it but I don't need another plugin (which I won't use) just for getting the output there. I would prefer a direct integration :)
I understand. You can define a new executor/runner in the plugin. See the source code of overseer, quickfix and terminal to get some idea. It should not be that hard.
Someday I may expose the definition of executor/runner as API so users can define their owns.
I understand. You can define a new executor/runner in the plugin. See the source code of overseer, quickfix and terminal to get some idea. It should not be that hard.
I'll try something out in the following days, thanks.
Someday I may expose the definition of executor/runner as API so users can define their owns.
Yeah, that would be cool :)
I've supported toggleterm
as an executor or runner, just set executor or runner to toggleterm
should be fine.
Oh damn :D I was just about to push my version. Good job and thanks! I'm currently on it to improve it just a little bit and add some more features :)
Okay, feel free to improve it 😄
Okay, I've been improving it quite a bit. As e.g. running separate or unified terminals and also tracking the cmd finish accurately. I was a bit surprised about the chan_id
property you've set and how you tracked the end of the cmd in general as on_exit
will get invoked only if you start the terminal with the cmd and otherwise on shell exit. Anyway have a WIP patch here. Still need to fix some edgecases and create a PR then :)
@Civitasv works great for me except that the command passed to toggleterm seems to contain unwanted parts:
/home/code/test/build/clang-17_mold/Debug/bin/test
exit $?
When the command finishes, exit$?
is then executed by my shell.
Running separate or unified terminals would be really helpful @deeedob
Yes, the ‘exit $?’ is used to stop the shell process. For reference, I kinda copied them from overseer.nvim.
Okay, I've been improving it quite a bit. As e.g. running separate or unified terminals and also tracking the cmd finish accurately. I was a bit surprised about the
chan_id
property you've set and how you tracked the end of the cmd in general ason_exit
will get invoked only if you start the terminal with the cmd and otherwise on shell exit. Anyway have a WIP patch here. Still need to fix some edgecases and create a PR then :)
Great to hear! And currently each cmd is executed using a separate shell process. After the command finish, we use exit $? to stop the shell process, then, the on_exit function will be executed.
Ahh yeah, I see. I wanted to go with a different approach since I (personally) like it more if the shell stays 'active' e.g. just sending the cmd and then tracking the execution of it.
I understand, actually our plugin’s terminal implementation(though kinda buggy) follows this idea, it is unified.