vim-prettier icon indicating copy to clipboard operation
vim-prettier copied to clipboard

Autoformat not running when exiting neovim with :wq

Open mikerowehl opened this issue 3 years ago • 0 comments

Do you want to request a feature or report a bug? bug

What is the current/expected behavior? It appears that the async job in neovim isn't always working correctly when running as part of an autocommand. I have vim-prettier setup to autoformat. And generally everything works, if I manually trigger prettier or save the buffer without exiting everything works. But if I exit with :wq the file isn't formatted.

I saw some bugs in older issues related to similar situations, so I dug around a bit. Cranked up debugging in neovim and saw that the prettier#Autoformat function was getting called and it did seem to be starting the executable. Just never updating the file. So I changed the first argument of the prettier#Prettier function to a 0 instead of a 1 within that prettier#Autoformat function and files started saving as expected.

At first I was testing this with a locally compiled neovim (v0.6.0-dev+84-gac5139eae), but I've also tried with the v0.5.0 release from Homebrew and saw the same behavior.

What version of vim-prettier are you using - (output of :PrettierVersion) ? 1.0.0-beta

What version of prettier are you using - (output of :PrettierCliVersion) ? 2.3.2

What is your prettier executable path - (output of :PrettierCliPath) ? prettier

Did this work in previous versions of vim-prettier and/or prettier ? I'm not sure, this is my first setup for both.

mikerowehl avatar Jul 29 '21 04:07 mikerowehl