18

I need to disable error highlighting in Java files in VS Code. VS Code tries to check a Groovy file while thinking it is a Java file.

As you can see in the picture all imports after the first and the types after the first field are highlighted red (due to missing semicolons). However I do not want the error check for this Groovy file. enter image description here

NOTE: I only have the plugins Clang, RedHat.Java, Markdown PDF, Sort Lines, and Uncrustify installed. Even if I disable all the red highlighting is visible.

Jörg Rech
  • 1,339
  • 2
  • 13
  • 25

5 Answers5

11

open your preferences file and add this

"java.validate.enable": false

I didn't try it for java, but it works for typescript.

John Henckel
  • 10,274
  • 3
  • 79
  • 79
6

I found this:

"problems.decorations.enabled": false,
Dharman
  • 30,962
  • 25
  • 85
  • 135
Anacarde
  • 109
  • 2
  • 7
  • 6
    This only affects the Files and Folders view, not the source code view – Mecki Feb 25 '22 at 10:36
  • thanks, this works for me for file and folder, but it still not ignore the source code content view :( – Luke Nov 30 '22 at 16:43
2

You should disable the linter, which is by default enable in VS Code. To do so you can go to File-> Prefrences -> setting

Ajinkya Dhote
  • 1,389
  • 3
  • 13
  • 26
  • 1
    Is there a secret setting for the java linter? I only see "css.lint", "less.lint", and "SCSS.lint" as well as "php.validate" – Jörg Rech Sep 05 '17 at 19:42
0

I wouldn't think this is necessary but you might try:

"files.associations": {
   ".groovy": "groovy"
}

in your user settings, assuming your file extension is .groovy. If it is something else, just set it to "groovy" as well. When I create a .groovy file with your content or gibberish I get no error linting at all. What is your file extension and what does Vscode call it in the bottom right of the editor? You can click on that file type to change its file associations. See modifying Vscode file extensions.

Mark
  • 143,421
  • 24
  • 428
  • 436
  • This is what I disabled by setting ".groovy": "java". What I'm trying to do is to get the Clang or Uncrustify code formatting working for groovy but the menu entry is only available for java files. I would be happy just by disabling the error highlighting for java files. – Jörg Rech Sep 06 '17 at 00:59
  • I don't know what you mean by "the menu entry is only available for java files." Which menu entry? I don't know how to remove error checking from .java files. – Mark Sep 06 '17 at 03:11
0

I had a similar issue. I work with some input files that look better if VSCode thinks of them as Python files. When I open them in VScode it marks several lines as errors (underlining them).

I Solved this by disabling the Python extensions on the left "Extensions Menu" and restarting VSCode. Now it opens the file and displays it as Python, but without checking for errors. Way cleaner to the eyes!

CarlosL
  • 1
  • 1