visual studio code syntax highlighting not working

  • Last Update :
  • Techknowledgy :

Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords like if or for in JavaScript differently than strings and comments and variable names.,The Color Theme guide describes how to create a color theme. Theming for semantic tokens is explained in the Semantic Highlighting guide.,Themes map scopes to colors and styles to provide syntax highlighting. TextMate provides list of common scopes that many themes target. In order to have your grammar as broadly supported as possible, try to build on existing scopes rather than defining new ones.,The TextMate tokenization engine runs in the same process as the renderer and tokens are updated as the user types. Tokens are used for syntax highlighting, but also to classify the source code into areas of comments, strings, regex.

Each grammar contribution specifies: the identifier of the language the grammar applies to, the top-level scope name for the tokens of the grammar, and the relative path to a grammar file. The example below shows a grammar contribution for a fictional abc language:

{
   "contributes": {
      "languages": [{
         "id": "abc",
         "extensions": [".abc"]
      }],
      "grammars": [{
         "language": "abc",
         "scopeName": "source.abc",
         "path": "./syntaxes/abc.tmGrammar.json"
      }]
   }
}

The example abc grammar marks the letters a, b, and c as keywords, and nestings of parens as expressions.

{
   "scopeName": "source.abc",
   "patterns": [{
      "include": "#expression"
   }],
   "repository": {
      "expression": {
         "patterns": [{
            "include": "#letter"
         }, {
            "include": "#paren-expression"
         }]
      },
      "letter": {
         "match": "a|b|c",
         "name": "keyword.letter"
      },
      "paren-expression": {
         "begin": "\\(",
         "end": "\\)",
         "beginCaptures": {
            "0": {
               "name": "punctuation.paren.open"
            }
         },
         "endCaptures": {
            "0": {
               "name": "punctuation.paren.close"
            }
         },
         "name": "expression.group",
         "patterns": [{
            "include": "#expression"
         }]
      }
   }
}

The grammar engine will try to successively apply the expression rule to all text in the document. For a simple program such as:

a
   (
      b
   )
x
   (
      (
         c xyz
      )
   )
   (
      a

The embeddedLanguages contribution point maps a scope in the embedded language to a top-level language scope. In the example below, any tokens in the meta.embedded.block.javascript scope will be treated as JavaScript content:

{
   "contributes": {
      "grammars": [{
         "path": "./syntaxes/abc.tmLanguage.json",
         "scopeName": "source.abc",
         "embeddedLanguages": {
            "meta.embedded.block.javascript": "javascript"
         }
      }]
   }
}

VS Code can only load json grammars, so yaml based grammars must be converted to json. The js-yaml package and command-line tool makes this easy.

# Install js - yaml as a development only dependency in your extension
$ npm install js - yaml--save - dev

# Use the command - line tool to convert the yaml grammar to json
$ npx js - yaml syntaxes / abc.tmLanguage.yaml > syntaxes / abc.tmLanguage.json

Suggestion : 2
vsliv368cf: 30146710
vsreu685: 30147344
python383: 30185418
pythonvspyt602: 30300191
vspor879: 30202332
vspor708: 30202333
vspor363: 30204092
vswsl492cf: 30256860
vstes627: 30244334
pythonvspyt639: 30300192
pythontb: 30283811
pythonptprofiler: 30281270
vshan820: 30294714
vstes263: 30335439
pythondataviewer: 30285071
pythonvsuse255: 30340121
vscod805: 30301674
pythonvspyt200: 30340761
vscextlang: 30333561
binariesv615: 30325510
vsccppwt: 30364497
pythonvssor306: 30344512
bridge0708: 30335490
pygetstartedc2: 30360494
bridge0723: 30353136
pythonrunftest32: 30365366
pythonf5test824: 30361777
javagetstartedc: 30364665
pythonvspyt187cf: 30365362
pydsgst2: 30361792
vssid140: 30363603
vssur157: 30367808

Suggestion : 3

I've searched the VSCode theme files and they don't seem to make any mention of URLs or links or any regex involving "http.*" or anything. So where the heck is that syntax highlighting rule defined and how can I tweak it?,Connect and share knowledge within a single location that is structured and easy to search.,One answer is to just turn off linkifying of URLs altogether:, Oh, wow, I was about to conclude that this was impossible, based on github.com/microsoft/vscode/wiki/Semantic-Highlighting-Overview But sure enough, your solution works! I never would've figured that out in a million years. Thank you! – dreeves Apr 30 at 20:01

One answer is to just turn off linkifying of URLs altogether:

"[html]": {
   "editor.links": false
},

Suggestion : 4

Open VS Code editor to change the syntax colors.,To change the text and syntax colors in visual studio code follow the steps given below:, Visual Studio Code ,To change the syntax colors, follow the steps in the below video tutorials.

"editor.tokenColorCustomizations": {
   "textMateRules": [{
      "scope": [
         "support.function.session.php",
      ],
      "settings": {
         "foreground": "#569CD6",
      }
   }, ]
}