vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

vscode-extension: Provide an action to open the formatter settings file

Open gorkem opened this issue 10 years ago • 17 comments

From @egamma on July 11, 2016 8:20

Copied from original issue: gorkem/java-language-server#42

gorkem avatar Aug 15 '16 13:08 gorkem

I wanted to open an enhancement-request to provide a configuration surface for the formatter. Currently I use eclipse, and I would like to move over to vs code. But I do need a way to format the code according to a formatting policy.

Is this ticket addressing the same problem?

houman-babai avatar Feb 09 '17 04:02 houman-babai

@houman-babai Yes, this is a request to use and edit eclipse formatting policies

gorkem avatar Feb 09 '17 05:02 gorkem

Thanks @gorkem. This is a great tool, but unfortunately I cannot use it without the formatter. Over the next few month I'll see if I can learn to contribute to the project :-) In the meantime i would be grateful to know if there are any workarounds...

houman-babai avatar Feb 09 '17 17:02 houman-babai

I would love to see it in future releases too!

concatime avatar Mar 19 '17 01:03 concatime

Yes. please have this feature.

bowiegou avatar Mar 26 '17 00:03 bowiegou

I'd vote for that too! @gorkem any hints where one could find the configuration for formating-rule, might find some time to contribute…

Dangoo avatar Apr 05 '17 13:04 Dangoo

This is very annoying. We have a specialized eclipse formatting settings but when using visual code I muck that up and there is no documented way to change it. Is there any workaround?

magnusart avatar Jul 07 '17 08:07 magnusart

FWIW there is a maven plugin which uses the Eclipse formatter and can use any provided formatting configuration. A native solution would be better of course.

musiKk avatar Jan 25 '18 07:01 musiKk

What is teh status of the issue?

It is the only thing preventing me from using this instead of eclipse proper.

KaRkY avatar Feb 19 '18 08:02 KaRkY

Any news on this? I think this is really important.

Even a property like "java.formater.file" in vscode to point to my global company rules would really help. I don't want to copy the file in all of our projects by hand...

DiabolusExMachina avatar Feb 23 '18 12:02 DiabolusExMachina

Sorry guys, there's been no new development in that area yet. As a workaround for your formatting options, please read https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings

fbricon avatar Feb 23 '18 13:02 fbricon

Trying to use the given workaround, how do you tell vscode to pick the formatting rules from .settings/org.eclipse.jdt.core.prefs

Just including the file in the project did not work

subpandu avatar Feb 26 '18 09:02 subpandu

Yes moving the file to the .settings folder does not seem to work

DiabolusExMachina avatar Feb 28 '18 10:02 DiabolusExMachina

I can recommend the gradle/maven plugin spotless as a work around (https://github.com/diffplug/spotless). Your build tool then makes sure everything is formatted. It can reformat your code automatically via the command spotlessApply. Not a replacement but makes things more tolerable and enforces a single code formatting standard.

magnusart avatar Feb 28 '18 18:02 magnusart

can anyone provide a sample project where .settings/org.eclipse.jdt.core.prefs are ignored?

fbricon avatar Feb 28 '18 18:02 fbricon

After copying the .settings/org.eclipse.jdt.core.prefs file you need to restart vscode for the changes to be picked. It was working for me after restart. 1.21.1 version. However now i have to copy this file to each project to get formatting to work. Is there a global location to place this file?

gitorko avatar Mar 23 '18 07:03 gitorko

I would like to see this feature in the next releases. In spite of the workaround works fine, could be great declared in vscode user settings a global ./settings folder to use for each project. Also, for example, org.eclipse.jdt.ui.prefs is needed as well to sort import statements.

angelfraga avatar Apr 06 '18 09:04 angelfraga