Visual Studio Code syntax highlighting not working
Asked Answered
P

10

21

I am using Visual Studio Code (VSC) as my IDE. My computer just updated to Catalina 10.15.2 (19C57) and since the update, VSCode is no longer highlighting syntax errors. The extensions I have seem to be working and it recognizes my miniconda Python environment.

Is there a solution for this yet? I was avoiding Catalina as I know it has caused a lot of issues but now that I was forced to install it I need a solution.

code with errors

enter image description here

Paperboard answered 16/1, 2020 at 17:35 Comment(6)
Was it able to detect that precise error earlier?Skilled
Yes, no syntax errors are being highlighted. That error is just to provide an example.Paperboard
What were you using to detect syntax errors? And is your Python environment still valid? For instance, if you were using the global install of Python previously that is now gone in Catalina, so that would prevent e.g. pylint from working.Mablemabry
@BrettCannon you got it. After updating to Catalina, was uninstalled from my VS Code extensions and is not available in the market place. I just opened my command palette (Command + Shift + p) and typed python: select linter. Then selected pylint, selected the install with conda option, Close/Open VS Code and now it's working (though it's still not shown in my extensions). Do you want to submit the answer or must I?Paperboard
I had to disable the 'Python for VSCode' extensionSerendipity
This solution from a similar StackOverflow thread worked for me: https://mcmap.net/q/403549/-how-can-i-get-vs-39-s-python-syntax-highlighting-in-vs-codeOstap
P
6

In my case, the Catalina installation didn't remove my Python installation.

After checking as suggested by @Brett Cannon in his comment, the update to Catalina uninstalled some extensions from VS Code. These are not available in the VS Code extension Marketplace anymore so there must be an issue regarding compatibility.

I fixed it by doing the following:

  1. Open the command palette (Command + Shift + P)
  2. Type Python: Select Linter and select pylint
  3. Select the Install with Conda option
  4. Restart VS Code

Now it's working correctly, though it's still not shown in my extensions section in VS Code.

It's necessary to point out that you will have to install pylint in every Python environment you are using, in my case I have multiple Conda environments.

Paperboard answered 22/1, 2020 at 23:9 Comment(3)
Just checking to be sure this is a typo, have to install pylint (not pytint) right? Doing that, then select & restart worked great for me in vs code 1.48.0 running on catalina 10.15.6.Wilser
Yes it was a typo, should be pylint, I just fixed the text.Paperboard
I'm am writing from years in the future on Sonoma 14.4.1. Not sure what caused it (not an OS upgrade) but I mysteriously had my linter uninstalled and reinstalled it through VS Code extensions menu. All appears to be fixed now.Dressing
F
27

In my case, it was just the theme issue. After the latest update, VSCode changed the theme to Dark Modern which is fine, but I wanted to use my existing one so I selected the Dark Theme (but my previous one was actually Dark+).

The difference between the two is the syntax highlighting feature so switching to the Dark+ Theme fixed the syntax highlighting not being enabled.

Forestay answered 8/5, 2023 at 6:32 Comment(3)
How did you fix it? I'm having the same problem. Can I not use the older theme anymore?Aeromedical
As i mentioned in the answer, "Dark +" is the theme which supports the code highlighting and is the older default theme of vs code,so click on the gear icon in the bottom left corner (settings), there, select theme > Dark + and you are good to goForestay
I got a similar problem while using the vscode-server, and I fixed this by disabling the dark reader extension.Rosenarosenbaum
O
11

I also had the same problem for TypeScript React (.tsx) files though in my case it was due to the JavaScript & TypeScript Nightly extension so disabling it fixed my syntax highlighting.

Oskar answered 17/11, 2022 at 14:10 Comment(3)
Assume this is a recent issue if we are all just now experiencing it? Looks like they released some updates today...Mikaelamikal
utterly insane this is the solution. thanks for this fix! If someone can expand on the issue in these comments, that would be helpful.Sugarplum
For me this was the plugin id evgeniypeshkov.syntax-highlighter plugin (Syntax Highlighter). It worked well but the latest update must have caused it to break. Uninstalling fixed my highlighting.Pyrosis
P
6

In my case, the Catalina installation didn't remove my Python installation.

After checking as suggested by @Brett Cannon in his comment, the update to Catalina uninstalled some extensions from VS Code. These are not available in the VS Code extension Marketplace anymore so there must be an issue regarding compatibility.

I fixed it by doing the following:

  1. Open the command palette (Command + Shift + P)
  2. Type Python: Select Linter and select pylint
  3. Select the Install with Conda option
  4. Restart VS Code

Now it's working correctly, though it's still not shown in my extensions section in VS Code.

It's necessary to point out that you will have to install pylint in every Python environment you are using, in my case I have multiple Conda environments.

Paperboard answered 22/1, 2020 at 23:9 Comment(3)
Just checking to be sure this is a typo, have to install pylint (not pytint) right? Doing that, then select & restart worked great for me in vs code 1.48.0 running on catalina 10.15.6.Wilser
Yes it was a typo, should be pylint, I just fixed the text.Paperboard
I'm am writing from years in the future on Sonoma 14.4.1. Not sure what caused it (not an OS upgrade) but I mysteriously had my linter uninstalled and reinstalled it through VS Code extensions menu. All appears to be fixed now.Dressing
F
6

The issue in my case was the Python language server setting (python.languageServer) was set to the wrong option. It should be set to Default or Pylance though for some reason switched over to Jedi which I never changed.

  1. File > Preferences > Settings

  2. Search for python.languageServer

  3. Change the setting as required:

    VSC Image

  4. Restart Visual Studio Code

Flinn answered 13/10, 2023 at 13:5 Comment(0)
B
5

Encountered this issue for weeks now (June 2023), just found out this is due to the VScode color theme, apart from extension issue (potentially the now deprecated Python for VSCode)

  1. Ctrl + Shift + P
  2. Type Preferences: Color Theme
  3. Select either Dark Modern or Dark+

Dark (Visual studio) is the one preventing Python syntax from being highlighted properly.

Bop answered 7/7, 2023 at 11:17 Comment(0)
N
3

In my case I needed to deactivate the plugin Pylance to work in Python. With Pylance it has broken syntax highlighting. after deactivation of all plugin, the broken highlighting was gone. I then activated one after the other and found Pylance as source for the problem.

  1. Deactivate all plugins
  2. Restart VisualStudio Code
  3. Activate one plugin after the other until problem occurs

enter image description here

enter image description here

Nystatin answered 22/2, 2023 at 15:23 Comment(0)
K
2

It's very specific but for me it was a missing semicolon in my CSS, I use styled-components in React and it didn't throw an error for the missing semicolon but highlighting was suddenly gone.

Kura answered 4/3, 2021 at 11:29 Comment(0)
M
1

If you were using the global install of Python then that was removed in Catalina which would break your virtual environment. A new install of Python and recreating the virtual environment should fix things.

Mablemabry answered 21/1, 2020 at 22:56 Comment(0)
A
0

Had similar issue on new vscode setup - my problem was rather that eslint warnings are not being highlighted, only errors.

After opening my eslint setup for the project - .eslintrc.js file, saw message saying that eslint needed permission accessing some files, which I did by clicking the lightbulb next to module.exports and hitting accept button.

Azrael answered 16/12, 2020 at 8:47 Comment(0)
L
0

Same issue occurred to me yesterday. I first tried upgrading my Mac to Ventura, uninstall and install a few older versions of VScode nothing worked. Then I realised by luck that it's caused by an extension Pylance (v2023.10.53) once I switch back to pre-release version inside my VScode extension and restart everything's back to normal - the highlight, definition, underlined error - all back!

Lurlenelurline answered 1/11, 2023 at 11:7 Comment(2)
I was not able to find the "Rylance" extension. I suppose it is "Pylance" but it had a typo in it. if this is the case, the answer does not add anything new to the previous answers.Inexertion
Yes, sorry, thanks for pointing it out! It is indeed "Pylance", my laptop autocorrected it before I hit the send button.Lurlenelurline

© 2022 - 2025 — McMap. All rights reserved.