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

Configuration file not loading correctly #269

Closed
jsgv opened this issue Nov 14, 2020 · 1 comment
Closed

Configuration file not loading correctly #269

jsgv opened this issue Nov 14, 2020 · 1 comment

Comments

@jsgv
Copy link

jsgv commented Nov 14, 2020

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

What is the current/expected behavior?
Trying to set a default .prettierrc file to be always used

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

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

What is your prettier executable path - (output of :PrettierCliPath) ?
/Users/username/.nvm/versions/node/v14.15.0/bin/prettier

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

Info

I am trying to set a default .prettierrc to be used with vim-prettier
Cli usage by itself can pick up the .prettierrc file located in user path ~

Vim configuration

let g:prettier#autoformat = 1
let g:prettier#exec_cmd_path = "/Users/username/.nvm/versions/node/v14.15.0/bin/prettier"
let g:prettier#autoformat_config_present = 1

.prettierrc

arrowParens: "always"
bracketSpacing: true
jsxBracketSameLine: true
printWidth: 100
singleQuote: false
tabWidth: 4
trailingComma: "all"

Original file (index.ts)

import React from "react";
import ReactDOM from "react-dom";
import {Provider} from "react-redux";

import {Root} from "./Root";
import store from "./store";

ReactDOM.render(
    <Provider store={store}>
        <Root />
    </Provider>,
    document.getElementById("root")
);

Output with Prettier CLI (prettier index.ts)

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';

import { Root } from './Root';
import store from './store';

ReactDOM.render(
    <Provider store={store}>
        <Root />
    </Provider>,
    document.getElementById('root'),
);
  • Saving in Vim does nothing to update the current file.
  • Calling :Prettier command directly also does nothing.
  • But if I open the file with vim flag the file is opened formatted correctly.
    • vim +Prettier index.ts
@jsgv jsgv closed this as completed Nov 15, 2020
@jsgv
Copy link
Author

jsgv commented Nov 15, 2020

It was an error in my configuration.
I did not realize that it required let g:prettier#autoformat_require_pragma = 0 setting.

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

1 participant