I followed https://github.com/prettier/vim-prettier instructions and added
// @format
at the top of my .js
files.
I installed prettier with
cd ~/.vim/bundle/
git clone https://github.com/prettier/vim-prettier
but I can't see to get Prettier to work, either on file save or by using :Prettier
at the ex command line. Nothing changes
At the command line, when I run
$ npx prettier-eslint $PWD/'**/*.js'
I get newly formatted output as expected.
package.json
includes
"devDependencies": {
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.6.0",
"jest": "^25.1.0",
"prettier-eslint-cli": "^5.0.0"
IF you are manually installing the prettier plugin then you have missed one step
what you will have to do is
cd ~/.vim/bundle/
git clone https://github.com/prettier/vim-prettier
cd vim-prettier
cd inside prettier root directory and do yarn install
or npm install
the third step is important because you don't have prettier executable globally or in your project installed and I see in your question you have missed that step
And if you don't have prettier in your project ( in which you are running the format command ) or in vim-prettier
directory or globally installed you can specify prettier executable let g:prettier#exec_cmd_path = "~/path/to/cli/prettier"
Also note that i was using branch release/1.x
not the master for stability
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.