Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to not always auto format by default #164

Closed
ppcano opened this issue Nov 26, 2018 · 3 comments
Closed

How to not always auto format by default #164

ppcano opened this issue Nov 26, 2018 · 3 comments

Comments

@ppcano
Copy link

ppcano commented Nov 26, 2018

Thanks for this plugin, it works great. I have a question or feature request:

I installed the plugin, and it autoformats all the different JS projects I am working on, but this is not always my desired behavior, I often create PRs on other projects which don't expect its code to be "prettified" but those become also autoformatted by default.

let g:prettier#autoformat = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx Prettier

I don't know which is the best workaround or feature request. May it be better if the plugin only format projects with a .prettierrc configuration file?

@mitermayer
Copy link
Member

Hi @ppcano

The reason for the auto-format be enabled by default is due to this line on your .vimrc

let g:prettier#autoformat = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx Prettier

If you would like to not have autoformat enabled you should remove this autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx Prettier as that is saying to vim that whenever you intend to save a file it should format it before you do so

@mitermayer
Copy link
Member

The let g:prettier#autoformat = 0 flag is used to control vim-prettier bespoke behaviour of autoformatting files that have the pragma @format on top of it.

@mitermayer
Copy link
Member

Closing this issue, please feel free to reopen this in case the above is not working for you and I will happily try to assist you in finding some solutions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants