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

my config single_quote is ignored #146

Closed
dedoyle opened this issue Jul 17, 2018 · 11 comments
Closed

my config single_quote is ignored #146

dedoyle opened this issue Jul 17, 2018 · 11 comments
Labels

Comments

@dedoyle
Copy link

dedoyle commented Jul 17, 2018

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.

@mitermayer
Copy link
Member

mitermayer commented Jul 17, 2018

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

@drager
Copy link

drager commented Jul 17, 2018

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

@dedoyle
Copy link
Author

dedoyle commented Jul 18, 2018

@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)

@mitermayer
Copy link
Member

I will look into this tonight and post findings in here and if able to reproduce will fix this issue and create a release

@mitermayer
Copy link
Member

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;
}

@mitermayer
Copy link
Member

Will investigate a bit more tomorrow to see if it has been any change on the API for forcing single quotes from the cli

@marianoguerra
Copy link

marianoguerra commented Aug 14, 2018

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?)

@mitermayer
Copy link
Member

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

@mvgrimes
Copy link

mvgrimes commented Oct 4, 2018

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!

@dedoyle
Copy link
Author

dedoyle commented Oct 8, 2018

I got inspired from mvgrimes. So I delete .editorconfig file and the prettier configuration in vimrc work now.

@jrledezma
Copy link

let g:prettier#config#config_precedence = 'file-override'
works for me

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

No branches or pull requests

6 participants