Closed adrianmoya closed 1 year ago
You may want to take a look at https://github.com/eclipse/eclipse.jdt.ls/pull/640
@snjeza so this is not possible today, until the expose formatting properties feature gets released? I didn't see anything in the thread regarding this particular issue...
external formatter feature is released on 0.24.0. you should grab the google formatter mentioned on the PR and try
@gorkem I'm using the google formatting file and those settings, sorry I didn't specify that. That's why i comment that the import spaces don't comply, even when using the formatting style setting.
Back to this, is it only me getting the undesired result? My setup:
{
"java.jdt.ls.vmargs": "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication -javaagent:\"/home/adrian/.vscode/extensions/GabrielBB.vscode-lombok-0.9.4/server/lombok.jar\" -Xbootclasspath/a:\"/home/adrian/.vscode/extensions/GabrielBB.vscode-lombok-0.9.4/server/lombok.jar\"",
"maven.executable.path": "./mvnw",
"java.completion.importOrder": [
"com",
"java",
"javax",
"lombok",
"org"
],
"workbench.editor.enablePreviewFromQuickOpen": false,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.insertSpaces": true,
"extensions.autoUpdate": false,
"java.import.gradle.enabled": false,
"java.format.settings.url": "/home/adrian/java/eclipse-java-google-style.xml",
"java.format.comments.enabled": false,
"java.trace.server": "verbose",
"git.autofetch": true,
"git.confirmSync": false,
"java.errors.incompleteClasspath.severity": "ignore"
}
Expected behavior: no space between imports, as the formating settings set <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="0"/>
Current behavior: A space between import groups.
Any update on this issue?
@kfstorm You can try the following settings:
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml"
@snjeza Thanks. I just found that only java.format.settings.url
is not enough, I have to set "java.format.settings.profile": "GoogleStyle"
too.
For me this wasn't enough to follow google style. Following steps helped me
$ code --install-extension emeraldwalk.RunOnSave
$ brew install google-java-format
and add the following config to settings.json
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.java$",
"cmd": "google-java-format --replace ${file}"
},
],
},
further reading: https://www.sethvargo.com/using-google-java-format-with-vs-code/
When I "Organize Imports" I get a blank line between import blocks ie:
Is there a way to prevent this? It doesn't comply with Google Java Style.
P.S.: I'm using the java.format.url setting pointing to a local eclipse-java-google-style.xml file