It may be a bug
vimrc
let g:prettier#config#print_width = 80
" number of spaces per indentation level
" let g:prettier#config#tab_width = 2
let g:prettier#config#tab_width = 4
" use tabs over spaces
let g:prettier#config#use_tabs = 'false'
" print semicolons
"let g:prettier#config#semi = 'false'
let g:prettier#config#semi = 'true'
" single quotes over double quotes
let g:prettier#config#single_quote = 'true'
" none|es5|all
let g:prettier#config#trailing_comma = 'none'
I think the prettier ignoring my configuration about single_quote. Because it turns all quotes to double quotes. I had also tried other configuration, like tab_width. Not work too.
PrettierVersion: 0.2.7
PrettierCliVersion: 1.13.7
PrettierCliPath: prettier
And this work in previous versions until I update vim-prettier today.
Hi @dedoyle,
Do you mind providing the output of :PrettierCliPath ?
Also does your project have some prettier configuration overwrites being written somewhere ? (.prettierrc, prettier.config.json, package.json, etc..)
The above behaviour would happen if somewhere above the ancestry of directories of where you are editing your file may have a prettier config overwrite
I'm experiencing the same issue. No settings are working and I have no .prettierrc, prettier.config.json or such present either that could interfere.
PrettierCliVersion: 1.13.7
PrettierVersion: 0.2.7
PrettierCliPath: /home/drager/my-project/node_modules/.bin/prettier
@mitermayer I don't have any configuration for prettier except the configuration in vimrc. I use Gvim in win7. And the output of :PrettierCliPath is just prettier. Nothing else.
Gvim: 8.0 (Features included +python, +lua, +perl)
I will look into this tonight and post findings in here and if able to reproduce will fix this issue and create a release
I tested this by editing a file foo.js that has simple content
function a() {
return 2;
}
with a .prettierrc file in the same directory with contents:
{
"tabWidth": 8
}
tested with both :Prettier and :PrettierAsync and got the outpout:
function a() {
return 2;
}
Will investigate a bit more tomorrow to see if it has been any change on the API for forcing single quotes from the cli
I had an error where I had to set the parser explicity to 'babylon' on .prettierrc and also if requirePragma is true then the pragma now has to be
/**
* @format
*/
This seems to no longer work
//@format
I hope my findings help, I ended up disabling the pragma requirement to avoid changing all my pragmas to the new format, but I would like to find a way to make it work (was the old style a vim-prettier feature?)
I will resume working on vim-prettier in 2 weeks, been very busy at work at this stage as I am about to go on paternity leave in the next 2 weeks, I really appreciate you raising this issue
I ran into this on a project with a .editorconfig file. It wasn't actually setting anything that conflicted with my default vim-prettier settings (ie, let g:prettier#config#single_quote = 'true'), but when prettier sees the file, it ignores all of the settings passed on the cli.
I was able to get the behavior I expected by setting:
let g:prettier#config#config_precedence = 'file-override'
This uses my vim-prettier settings as a default, but allows .editorconfig, .prettierrc, etc. to override them. I'm not sure if this is a bug, a questionable default setting, a documentation issue, or something I missed in the documentation.
Anyway, thanks for creating/maintaining vim-prettier!
I got inspired from mvgrimes. So I delete .editorconfig file and the prettier configuration in vimrc work now.
let g:prettier#config#config_precedence = 'file-override'
works for me
Most helpful comment
I ran into this on a project with a
.editorconfigfile. It wasn't actually setting anything that conflicted with my default vim-prettier settings (ie,let g:prettier#config#single_quote = 'true'), but when prettier sees the file, it ignores all of the settings passed on the cli.I was able to get the behavior I expected by setting:
This uses my vim-prettier settings as a default, but allows
.editorconfig,.prettierrc, etc. to override them. I'm not sure if this is a bug, a questionable default setting, a documentation issue, or something I missed in the documentation.Anyway, thanks for creating/maintaining vim-prettier!