neoformat
neoformat copied to clipboard
Run formatters asynchronously
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.
Neoformat used to work async, but due to limitations with vim's api, specifically the lack of setbufline()
, users couldn't change the buffer.
Does it work asynchronously in neovim ?
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.
@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
Seems like neovim has nvim_buf_set_lines()
Any thoughts on going forward with this?
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.
Is there a way to restore the async functionality for neovim users in the meantime?
@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?
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.
Hi, is there any progress on this? thank you!
Any updates or plans?
🙏