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

Google Java Format #419

Closed
azdanov opened this issue Jan 24, 2018 · 6 comments
Closed

Google Java Format #419

azdanov opened this issue Jan 24, 2018 · 6 comments
Labels

Comments

@azdanov
Copy link

@azdanov azdanov commented Jan 24, 2018

Is there a way to setup formatting with Google Java Format?
Or an entirely new extension is needed which will run the jar formatter on opened file?
If so, what would be the best way to implement this as an extension, e.g running external jar?

@gorkem gorkem added the question label Jan 24, 2018
@ddcprg

This comment has been minimized.

Copy link

@ddcprg ddcprg commented Jan 26, 2018

This would be cool.

I'm looking for a way of configuring the formatter and the code organizer with similar settings to eclipse/intellij even better if I can import the files directly. Seems like this extension comes with predefined settings which cannot be changed.

@fbricon

This comment has been minimized.

Copy link
Contributor

@fbricon fbricon commented Jan 26, 2018

The only way you can set it up currently is to save the google java format as eclipse formatter settings, in your .settings/org.eclipse.jdt.core.prefs.

@fbricon

This comment has been minimized.

Copy link
Contributor

@fbricon fbricon commented Jan 26, 2018

I added an entry to the wiki

@azdanov

This comment has been minimized.

Copy link
Author

@azdanov azdanov commented Jan 26, 2018

I've found a solution that works ok.

https://code.visualstudio.com/docs/editor/tasks

For that to work make sure java-google-format can be executed from terminal. In my case:

  • Installing via brew install google-java-format does the trick.
  • Create a tasks.json file in .vscode directory inside your workspace with necessary commands.
  • Run from vscode command palette by running task and finding format task

Here's my tasks.json file:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Run google java format",
      "type": "shell",
      "command": "google-java-format --replace ${file}"
    }
  ]
}
@ddcprg

This comment has been minimized.

Copy link

@ddcprg ddcprg commented Jan 26, 2018

thanks @fbricon @azdanov for the swift response

@garymm

This comment has been minimized.

Copy link

@garymm garymm commented Dec 23, 2019

Would be nice to have this built into the extension so it can work with "format on save".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.