Search code examples
visual-studio-codeconfigurationjsonlines

How to add syntax highlighting for a data-format, JSON Lines, that doesn't yet have syntax-highlighting support?


I would like to gain syntax highlighting support for the JSONL data format — "JSON-Lines" — as the format is not yet supported in 'V.S. Code'.

The JSONL website recommends that I search for an extension that adds support for JSON Lines, however, all attempts I made to find such an extension did not return any useful results.

I also searched Visual Studio Marketplace for "JSON Lines" and ".jsonl", but once again, the search did not return any helpful results.

At this point I am left wondering if it is possible to add support for the data format?


Solution

  • Asa result of this commit: https://github.com/microsoft/vscode/commit/0adddd82816db666c52038e8277312dc55da2756 in the Insider's Build v1.79.0 now is built-in support for the JSON Lines language definition. There is a new jsonl language identifier and the examples below use the .jsonl extension, the JSON Lines lnaguage identifier is automatically chosen.

    Here is the default syntax coloring:

    JSON Lines default syntax colors

    However, you can examine the scopes of these JSON Lines tokens and change the colors yourself through "editor.tokenColorCustomizations" setting like this:

    "editor.tokenColorCustomizations": {
        "textMateRules": [
    
          {
            "scope": "string.quoted.double.json.lines",   // values
            "settings": {
              "foreground": "#7300ff",
              "fontStyle": "bold"
            }
          },
          {
            "scope": "support.type.property-name.json.lines",   // keys/property names
            "settings": {
              "foreground": "#FF0000",
              "fontStyle": "bold"
            }
          }
        ]
    },
    

    There are more scopes to investigate. Here is what those token color changes look like:

    JSON Lines custom syntax colors