overseer.nvim icon indicating copy to clipboard operation
overseer.nvim copied to clipboard

Suggestion: let strategies override default actions

Open pianocomposer321 opened this issue 2 years ago • 3 comments

For example, the "open" action and all it's relatives just open a new window and load the buffer for that task. With the toggleterm strategy, this causes some issues because the terminal is opened bypassing toggleterm, so window options like adding shading and disabling line numbers don't take effect.

So my suggestion is to allow strategies to provide handlers for actions. So the open actions for tasks with the toggleterm strategy could call term:open(), etc. If a strategy does not provide a handler for a particular action, it could fall back to the defaults.

This isn't necessarily a must, but I think it would be useful. If you think it's a good idea, lmk some idea of what you think it should look like and I can probably make a PR to add it.

What do you think about this idea?

pianocomposer321 avatar Jun 17 '23 22:06 pianocomposer321

I see the need for it, since toggleterm has its own UI hooks. I don't like the idea of having strategies override actions, because it makes actions a lot more difficult to understand. Right now it's a pure function that runs on the task. If that code can get run or not depending on the strategy, then it becomes more difficult to understand and debug.

Right now the strategy handles the running of the process, and a little bit of how it's displayed (at least, it controls the buffer that gets shown). I wonder if it would make sense to create some sort of "display" abstraction? Maybe this could be its own thing, or maybe it would be rolled into the strategy.

I've been thinking a bit about implementing the output behavior from VS Code (#142), so likely these two ideas would go together.

stevearc avatar Jun 18 '23 00:06 stevearc

Hey, so I was able to achieve basically what I wanted on my own. I just switched back to the default "terminal" strategy and made my own custom component to handle the ui stuff.

This, or something like it, could still probably be useful for someone else. Feel free to close this or keep it open for tracking, whichever you think is best :slightly_smiling_face:.

For those interested, the component and stuff is on my dotfiles repo

pianocomposer321 avatar Jun 19 '23 19:06 pianocomposer321

Glad you were able to work around it! I think it still makes sense to try to add some form of abstraction to make the default actions (and other operations) play nicer with toggleterm. I'll leave this issue open to track that

stevearc avatar Jun 21 '23 16:06 stevearc

I ended up doing this in a quicker, hackier way than I initially wanted. Would still like to come up with a proper fix, but any fix is better than none.

stevearc avatar Jun 04 '24 16:06 stevearc