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

Explain how to disable vim-prettier default settings in readme #343

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ejoubaud
Copy link

@ejoubaud ejoubaud commented Apr 20, 2023

I spent a while figuring out why vim-prettier was adding some default CLI options like --tab-width=4 to the prettier command it was running, which was causing changes that would break my CI build when it would check the codebase against a .prettierrc that (obviously) didn't include vim-prettier's default settings.

In case anyone encounters a similar issue, here's what I found out:

  1. vim-prettier always adds a bunch of CLI flags with its own default settings to the prettier command it runs. See https://github.com/prettier/vim-prettier/blob/e122231/autoload/prettier/resolver/config.vim#L8
  2. it even overrides some of its own default settings, like if g:prettier#config#tab_width is set to auto (the default), it will set it to the value of the shiftwidth vim setting (see https://github.com/prettier/vim-prettier/blob/e122231/autoload/prettier/resolver/config.vim#L56). In my case it would set it to 4 on markdown files

There doesn't seem to be any option to prevent vim-prettier from adding all those CLI flags, but thankfully we can ask prettier to ignore them whenever a config file is passed with the --config-precedence prefer-file option.

I thought this deserved a clearer mention in the section of the README that mentions the vim-prettier default config. WDYT?

(Thanks to @twm who put me on the right track in this issue comment: #266 (comment))

I spent a while figuring out why vim-prettier was adding some default CLI options like `--tab-width=4`, which was breaking my CI build checking the codebase against a .prettierrc that (obviously) didn't include vim-prettier's default settings.

In case anyone encounters a similar issue, here's what I found out:

1. vim-prettier always adds a bunch of CLI flags with its own default settings to the prettier command it runs. See https://github.com/prettier/vim-prettier/blob/e122231/autoload/prettier/resolver/config.vim#L8
2. it even overrides some of its own default settings, like if `g:prettier#config#tab_width` is set to `auto` (the default), it will set it to the value of the `shiftwidth` vim setting (see https://github.com/prettier/vim-prettier/blob/e122231/autoload/prettier/resolver/config.vim#L56). In my case it would set it to 4 on markdown files

There's no option to prevent vim-prettier from adding all those CLI flags, but mercifully we can ask prettier to ignore them whenever a config file is passed with the `--config-precedence prefer-file` option.
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

Successfully merging this pull request may close these issues.

None yet

1 participant