Vim-prettier: prettier config default values

Created on 7 Oct 2020  路  5Comments  路  Source: prettier/vim-prettier

Hello,

Thank you very much for plugin. I use it every day and love it! 鉂わ笍

I wanted to ask whether it's really necessary to set the default values for prettier within the plugin:
https://github.com/prettier/vim-prettier/blob/7a6fddd0eb41f498ddc24aa6e34063dee7f04c2e/plugin/prettier.vim#L63-L136

The defaults that are present in the plugin are for prettier 2.x, so if you happen to work on a project with prettier 1.9 and forget to set arrow-parens to avoid in your config it will become always and then you will have conflicts with eslint.

Do you think that we probably should not pass the option at all if its value is not specified in prettier config and user .vimrc?

Most helpful comment

The Readme states:

Note: vim-prettier default settings differ from prettier intentionally.

It would be good to know why this is the case. I found this behaviour surprising.

All 5 comments

I would also love it if this plugin didn't force a set of options and just let prettier do its own thing. In the mean time, I drafted this workaround:

if prettier#PrettierCli('--version') < '2.0'
  let g:prettier#config#arrow_parens = 'avoid'
end

The Readme states:

Note: vim-prettier default settings differ from prettier intentionally.

It would be good to know why this is the case. I found this behaviour surprising.

I have been caught out today but vim-prettier using my shiftwidth instead of using the prettier default for tabWidth. I'd be grateful if there was an option to use default as a config value that basically means "don't set it and leave it to whatever prettier wants to do". Perhaps with time I'll adjust my vim to fall inline with the prettier settings but it as been confusing though I can see it is clearly documented.

This is mostly happening because my new team seems to be relying on prettier defaults for a lot so there is no config but my vim setup is old and crufty and so has some file type plugin settings lurking around which don't match prettier and I'd rather the prettier output matched my team and then I could bring my editor inline when I wanted but save in the knowledge that my code fits the team, rather than have the prettier output match my editor and have to bring my editor inline with the team straight away.

Though typing this out, it all sounds a bit subjective. I was just caught out and had to start printing out the command that vim-prettier was running to understand it all.

Thanks for the project though :)

Yeah, a little confused myself as to why there are defaults.

Had to add:-

let g:prettier#config#tab_width = '2'
let g:prettier#config#print_width = '80'

To get it to play nice with eslint at this end. Prettier 2.2.1.

The fact that the saved files are not guaranteed to pass prettier --check is a deal-breaking bug for me, unfortunately. Which is a shame, because the plugin works great otherwise!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ajcrites picture ajcrites  路  8Comments

tugorez picture tugorez  路  7Comments

mitermayer picture mitermayer  路  8Comments

mitermayer picture mitermayer  路  5Comments

rkulla picture rkulla  路  3Comments