neoformat icon indicating copy to clipboard operation
neoformat copied to clipboard

Run formatters asynchronously

Open uri opened this issue 6 years ago • 15 comments

It would be nice if the formatter could run asynchronously. I often save a file and want to navigate elsewhere but the editor is locked on until the formatter finishes. Would be be possible to run the formatter asynchronously? I believe the file would have to be changed to read-only mode between saving and the formatter completing, not sure if this is possible however.

uri avatar Aug 10 '17 13:08 uri

Neoformat used to work async, but due to limitations with vim's api, specifically the lack of setbufline(), users couldn't change the buffer.

sbdchd avatar Aug 10 '17 23:08 sbdchd

Does it work asynchronously in neovim ?

alem0lars-yr avatar Sep 06 '17 09:09 alem0lars-yr

I think neovim has it, and it could be added just for it. This plugin was originally for neovim after all. I'd also like this feature back in.

alok avatar Sep 20 '17 14:09 alok

@sbdchd if you wanted Neoformat to run async and setbufline was the stumbling block, Vim, as of 8.0.1039 has setbufline https://github.com/vim/vim/commit/b31cf2bb0be95d106bd8eef93cc07550591c1d0d

gryftir avatar Nov 17 '17 01:11 gryftir

Seems like neovim has nvim_buf_set_lines()

sbdchd avatar Nov 17 '17 02:11 sbdchd

Any thoughts on going forward with this?

alok avatar Mar 15 '18 07:03 alok

All that needs to happen is https://github.com/sbdchd/neoformat/commit/34d049fd82d86206ef0c153f886c9f5dc84f5494 gets patched onto master, and the job dict gets the current buffer number added so buf_set_lines can be used instead of setline.

Also, killing the job process is no longer needed on buffer switch, since neoformat will keep track of the job's relevant buffer.

sbdchd avatar Mar 15 '18 16:03 sbdchd

Is there a way to restore the async functionality for neovim users in the meantime?

shinzui avatar Jul 25 '18 14:07 shinzui

@sbdchd I am happy to do the work you mentioned here: https://github.com/sbdchd/neoformat/issues/106#issuecomment-373434576 to make this async again, but I might need a little more guidance. Do you have time to talk it through a bit more?

thedelchop avatar Aug 15 '18 18:08 thedelchop

To add on to what mentioned earlier, we also need to have an ability to switch between the sync and async functionality with variable, e.g., g:neoformat_async = 1 https://github.com/sbdchd/neoformat/issues/106#issuecomment-373434576

This should allow some siloing between the two runner setups and might actually make it easier to add the job_control back.

Patching that previous diff will have to be mostly manual since I am guessing master has changed significantly since then.

sbdchd avatar Aug 15 '18 23:08 sbdchd

Hi, is there any progress on this? thank you!

quantum-booty avatar Sep 15 '21 06:09 quantum-booty

Any updates or plans?

dlvhdr avatar Dec 19 '21 18:12 dlvhdr

🙏

jesseleite avatar Jan 26 '22 17:01 jesseleite