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

Code formating for Prettier #681

Closed
gavinmcfarland opened this issue Jul 19, 2019 · 4 comments
Closed

Code formating for Prettier #681

gavinmcfarland opened this issue Jul 19, 2019 · 4 comments

Comments

@gavinmcfarland
Copy link

Hello,

Is there any way to support formatting with Prettier for jsonnet files? I noticed this issue #73 talking about a formatting tool but I'm unfamiliar with go fmt. Could it be ported to Prettier?

Many thanks

@gavinmcfarland gavinmcfarland changed the title format Code formating for Prettier Jul 19, 2019
@sbarzowski
Copy link
Collaborator

There exists an official formatting tool called jsonnetfmt. It should be pretty straightforward to use.

Regarding Prettier, I'm not familiar with it. If it can act as a simple facade to our official tool, then why not (not sure if possible/consistent with how Prettier is supposed to be used).

@gavinmcfarland
Copy link
Author

Ok thanks, is jsonnet fmt a CLI tool only? I'm looking for support for VScode. I've seen there is a VScode extension, but when I tried it, it didn't work. I've have jsonnet installed and in my PATH but no luck. Support for Prettier would be useful, but I'm not sure how much of a demand there would be for it.

@sbarzowski
Copy link
Collaborator

jsonnetfmt is a separate command since 0.13 and it generally should be distributed together with jsonnet.

I have never used it with an editor integration, but it should be quite trivial. Even without an extension you can set up a "task" in VS Code which just runs the command. The autopep8 example from the vs code tasks tutorial should be easy to adapt for jsonnetfmt.

Of course an extension would be more convenient. The existing (3rd party) VS Code extension has some pretty advanced features (like very smart autocompletion), but is quite out of date (perhaps a simpler extension which just runs official tools should be created and that would be easier to keep up to date).

@sbarzowski
Copy link
Collaborator

We want to focus on jsonnetfmt I think and use it as the source of truth (and all editors should use it for autoformatting Jsonnet). Closing this.

If anyone has trouble using jsonnetfmt for their formatting needs, feel free to open an issue.

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