question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google Java Format

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:13
  • Comments:8

github_iconTop GitHub Comments

9reactions
azdanovcommented, 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}"
    }
  ]
}
5reactions
garymmcommented, Dec 23, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

google/google-java-format: Reformats Java source code to ...
google -java-format is a program that reformats Java source code to comply with Google Java Style. Using the formatter. from the command-line. Download...
Read more >
Google Java Style Guide
4 Formatting · 4.1 Braces · 4.2 Block indentation: +2 spaces · 4.3 One statement per line · 4.4 Column limit: 100 ·...
Read more >
google-java-format - IntelliJ IDEs Plugin
Formats source code using the google-java-format tool. This version of the plugin uses version 1.15.0 of the tool. Plugin Site. Issue Tracker. Source...
Read more >
Format your Java code with google-java-format
Google's code style guide is, by far, my most favourite. And I am going to walk you through how to set it up...
Read more >
com.google.googlejavaformat » google-java-format
A Java source code formatter that follows Google Java Style. License, Apache 2.0. Tags, formatgoogle. Ranking, #3099 in MvnRepository (See Top Artifacts).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found