There are a couple of Vim plugins for prettier that seem to work well. However, I like to keep Vim as light/fast as possible, so I chose prettier-eslint-cli which doesn't require to install a plugin, but add a couple of lines to your Vim's config file (it also combines with eslint rules).
So, I added the following two lines to my
.vimrc after installing prettier-eslint-cli via yarn, and... it didn't work (because computers...).
The first line sets
formatprg (format program) to
formatprg docs (
If the 'formatexpr' option is not empty, it will be used instead. Otherwise, if 'formatprg' option is an empty string, the internal format function will be used |C-indenting|.
formatexpr wasn't empty because I had vim-es6 plugin installed (syntax highlighting for ES6+). This plugin set's
formatexpr for indentation; I removed vim-es6 and prettier-eslint-cli started to work correctly.