redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 439 forks source link

Provide a way to let Formatter profile settings take precedence over VS Code's #672

Open RuiffCardoso opened 6 years ago

RuiffCardoso commented 6 years ago

I have a configured formatter profile which has, among others, the following property:

<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>

If I go to a file and change, using the the option on the bottom right of VSCode to use a different attribute (ex.: space: 8) to code automatically formats to that selection, ignoring the formatted profile.

The problem is that after doing that, the formatter option for tabulations stop working. There should be a way to force format according the formatter profile, or to remove these individual file formatter options. Right now, I have some files where I pressed this and I don't know which ones, and can't force them to be formatted properly

Environment
Steps To Reproduce
  1. Create and apply a formatter profile with tabulation char TAB and size: 4
  2. Open .java file and format it. It applies this profile format
  3. Using VSCode bottom right menu, change tabulation char and size. Ex.: SPACE and size: 8. The file applies this profile format.
  4. Now you can't change this specific file to apply the profile configured tabulation char and size.
Current Result

The project applies to manually selected configuration. Can't revert to use profile format.

Expected

One of the following:

fbricon commented 6 years ago

Yeah we need to ensure formatting profile preferences take precedence over editor settings. Need a new preference for that. Until then your best option is to make vscode settings for your project/folder match the ones from your eclipse formatting profile:

    "[java]":{
        "editor.insertSpaces": true,
        "editor.detectIndentation": false,
        "editor.tabSize": 4,
    },
RuiffCardoso commented 6 years ago

Yeah we need to ensure formatting profile preferences take precedence over editor settings. Need a new preference for that. Until then your best option is to make vscode settings for your project/folder match the ones from your eclipse formatting profile:

    "[java]":{
        "editor.insertSpaces": true,
        "editor.detectIndentation": false,
        "editor.tabSize": 4,
    },

Thanks for the workaround, it will do for now

astrelsky commented 4 years ago

Yeah we need to ensure formatting profile preferences take precedence over editor settings. Need a new preference for that. Until then your best option is to make vscode settings for your project/folder match the ones from your eclipse formatting profile:

    "[java]":{
        "editor.insertSpaces": true,
        "editor.detectIndentation": false,
        "editor.tabSize": 4,
    },

I am currently struggling with this. How may I know that the formatter settings I have selected are actually being used?

There is a new setting editor.defaultFormatter with the following description: "Defines a default formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter." Going through the list of options shows "redhat.java". However, setting the java settings as follow still doesn't make the formatter profile take precedence.

"[java]": {
        "editor.defaultFormatter": "redhat.java"
    }
WisnuCakraa commented 3 years ago

can we have auto give ";" ?

marco-belonio commented 7 months ago

+1 - I do NOT want to separate my formatter options across thousands of definition files....