habamax / vim-shout

Run and Capture Shell Command Output in Vim
19 stars 3 forks source link

Async buffer writing commands #3

Open Konfekt opened 6 months ago

Konfekt commented 6 months ago

While there are some plug-ins (such as https://github.com/mg979/tasks.vim/ or https://github.com/tpope/vim-dispatch) that replace :make by an async command, few that do these for the commands that write to a buffer such as :<range>!command or :read! command (which is more intricate regarding possible user interaction that should go elsewhere). Does this plug-in fill the gap?

habamax commented 6 months ago

Does this plug-in fill the gap?

I don't know to be honest. The idea is to run shell command, have the output in a dedicated buffer, be able to navigate results if possible.

Konfekt commented 6 months ago

Thank you, this sounds great. Since it runs in the background and outputs into a buffer, this is already more convenient than having to wait for the output:

:Sh {command}

    Start {command} in background, open existing [shout] buffer or create a new one and print output of stdout and stderr there. Put cursor to the end of buffer.

Would you consider writing to the same (or indicated) buffer to a given range (like :<range> command) or a line (like :<count>read! command) ? Of course, this buffer better be left for the time being to avoid having to handle user input sensibly.

habamax commented 6 months ago

Of course, this buffer better be left for the time being to avoid having to handle user input sensibly.

While I can see this is possible to do, I don't want to do it in this plugin. At least now :)

Konfekt commented 6 months ago

I can hardly see how smooth user interaction is possible (as it could jump forth and back with the income of stdout data). But as long as its output goes to a buffer without user interaction (in a different window or tab), then it works as at the moment, with the sole difference of specifying the output buffer and range instead of using the dedicated buffer (and output range starting at the first line!?)

habamax commented 6 months ago

can hardly see how smooth user interaction is possible

I wouldn't call it smooth, indeed. I can see 2 possibiliteis:

  1. capturing current range and replace it at once when shell command is finished
  2. delete the range and feed line by line output of shell command starting from range line start <- I don't like this as it would be unpredictable in a general case.
Konfekt commented 6 months ago

Yes, we can go with 1 which has many advantages from the developer's side and is already a lot better than being stuck in the buffer without being able to interact.

Note that :<range>command not only replaces the range, but also reads it.

Konfekt commented 6 months ago

It seems that this is the first plug-in to send output to an editable buffer. I am a bit overwhelmed by the variety of REPL plug-ins, such as https://github.com/rhysd/reply.vim, https://github.com/metakirby5/codi.vim and https://github.com/jpalardy/vim-slime, but they all send to an unmodifiable vim terminal buffer, which seems to be the same as :FloatermSend.

habamax commented 6 months ago

I just wanted something like :new | !r command but with "stable" scratch like buffer behind it.