Diego Serrano
Diego Serrano

Reputation: 1026

Visual Studio Code syntax highlighting not working

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

Upvotes: 25

Views: 119102

Answers (11)

tobahhh
tobahhh

Reputation: 381

Sometimes I get this issue when switching between interpreters (e.g. a conda environment and a pip venv). Restarting the language server often resolves the issue without having to change any configuration. This can be done by:

  1. Open the command palette (Command + Shift + P)
  2. Type Python: Restart Language Server

Upvotes: 0

Monika
Monika

Reputation: 1

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!

Upvotes: 0

M_droid
M_droid

Reputation: 2788

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.

Upvotes: 2

Diego Serrano
Diego Serrano

Reputation: 1026

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.

Upvotes: 7

Lasithds
Lasithds

Reputation: 2291

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.

Upvotes: 12

Irfan wani
Irfan wani

Reputation: 5094

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.

Upvotes: 40

Skully
Skully

Reputation: 3126

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

Upvotes: 8

astroflyer
astroflyer

Reputation: 248

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.

Upvotes: 5

Nasenbaer
Nasenbaer

Reputation: 4900

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

Upvotes: 3

Be Kind
Be Kind

Reputation: 5182

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.

Upvotes: 0

Brett Cannon
Brett Cannon

Reputation: 16080

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.

Upvotes: 1

Related Questions