Vim-prettier: Autoformat not working on save

Created on 21 Jun 2019  路  5Comments  路  Source: prettier/vim-prettier

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

What is the current/expected behavior?
Just installed the plugin and when I save the file, nothing changes. If I do :Prettier it then formats my document. I ran echo g:prettier#autoformat and it returns a 1

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

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

What is your prettier executable path - (output of :PrettierCliPath) ?
/Users/jcostanzo/.dotfiles/config/nvim/plugged/vim-prettier/node_modules/.bin/prettier

Did this work in previous versions of vim-prettier and/or prettier ?
This is my first time using this so its unknown

Most helpful comment

The docs are not clear for me. It took 15 mins to make it works on autosave. It's not easy to understand, that options below must be used together for execute prettier on autosave without "@format" or "@prettier" tags.

let g:prettier#autoformat = 1
let g:prettier#autoformat_require_pragma = 0

Or for autoformating only when you have config file in directory or parent.

let g:prettier#autoformat_config_present = 1
let g:prettier#autoformat_require_pragma = 0

All 5 comments

look for the following text in the README:

To enable vim-prettier to run in files without requiring the "@format" doc tag..

In that section there are some options to enable autosaving (the code snippets should be added to the ~/.vimrc file)

Please follow the README instructions as mentioned by @lfarroco

If you still got issues feel free to re-open this

The docs are not clear for me. It took 15 mins to make it works on autosave. It's not easy to understand, that options below must be used together for execute prettier on autosave without "@format" or "@prettier" tags.

let g:prettier#autoformat = 1
let g:prettier#autoformat_require_pragma = 0

Or for autoformating only when you have config file in directory or parent.

let g:prettier#autoformat_config_present = 1
let g:prettier#autoformat_require_pragma = 0

I agree with @vadimshvetsov . This should be more clear on the readme

@drjosephliu Please feel free to submit a PR for it we would love contributions!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

n-xlkt picture n-xlkt  路  5Comments

alex-shamshurin picture alex-shamshurin  路  10Comments

Luobata picture Luobata  路  7Comments

cdimitroulas picture cdimitroulas  路  5Comments

andreiglingeanu picture andreiglingeanu  路  12Comments