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

prettier runs with incorrect prettier configuration #352

Closed
akoskm opened this issue Dec 27, 2023 · 2 comments
Closed

prettier runs with incorrect prettier configuration #352

akoskm opened this issue Dec 27, 2023 · 2 comments

Comments

@akoskm
Copy link

akoskm commented Dec 27, 2023

Do you want to request a feature or report a bug?
Bug

What is the current/expected behavior?
When I run prettier with p, it formats the file one way; when I run prettier from VSCode, it formats the file a bit differently.
We have a pre-commit hook in the project, and unfortunately, the formatting applied by Vim is incorrect.

What version of vim-prettier are you using - (output of :PrettierVersion) ?
1.0.0

What version of prettier are you using - (output of :PrettierCliVersion) ?
2.8.8

What is your prettier executable path - (output of :PrettierCliPath) ?
/Users/akoskm/Projects/my-project/node_modules/.bin/prettier

Did this work in previous versions of vim-prettier and/or prettier ?
No information.

Here's my prettierrc.js file:

const originalConfig = require('eslint-config-my-project/.prettierrc');

// ---------------------------------------------------------------------------------------
// NOTE: When we upgrade to prettier 3.x.x we should uncomment the `ignorePath` and remove
// the `.prettierignore` file.
// ---------------------------------------------------------------------------------------
module.exports = {
  ...originalConfig,
  // ignorePath: '.eslintignore',
};

And the contents of ~/.vimrc:

let g:prettier#autoformat = 1
let g:prettier#autoformat_require_pragma = 0
let g:prettier#autoformat_config_present = 1
let g:prettier#exec_cmd_async = 1
@gkoberger
Copy link

gkoberger commented Jan 11, 2024

Hey, I ran into this too. After a lot of debugging, it seems like vim-prettier is overriding prettier defaults with its own.

Here's my issue: #353

Here's where the overriding is happening: https://github.com/prettier/vim-prettier/blob/master/plugin/prettier.vim#L58

I bet you'll find the property you're having is overridden in the prettier.vim file.

A short-term fix is to add your own let g:prettier#config#CONFIG_YOURE_WORRIED_ABOUT in your ~/.vimrc to override their overriding.

@akoskm
Copy link
Author

akoskm commented Jan 11, 2024

I switched to LazyVim, so I can't really reproduce this, but I hope your comment will help those who want to get this working in their custom setup - without LazyVim. Thanks @gkoberger.

@akoskm akoskm closed this as completed Jan 11, 2024
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