LookML VSCode Extension - Syntax Highlighter

After having read this topic: 

https://community.looker.com/open-source-projects-78/anyone-interested-in-a-vscode-plugin-9353

 many times, I decided to give it a shot. I was told by Looker Staff that they can’t share the regular expressions for the grammar for internal reasons and, as suspected, the red tape due to being sold to Google. 

I tried to do it on my own in my spare time since it seemed like a cool project. I did it with the help of the code that Ladvien has already written (https://github.com/Ladvien/vscode-looker)

This is just a first try and proof of concept. The colours are crazy just so that I can easily differentiate between different patterns 🙂 In terms of grammar recognition I believe It’s close to what we have in the LookML editor, and perhaps slightly more. (recognising the SQL in SQL parameters (where we could use SQL grammar recognition that I think Ladvien had in mind), values in arrays, and so on)

4224958c-6877-4712-b7d6-36d6a2484907.png
5d897fe5-83a2-4b86-bc41-13dd1bf68061.png

Let me know what other things would be useful in terms of syntax highlighting and here is a list of what I’ve done so far:

  1. Scopes (anything that has opening and closing bracket {}) - would apply to view,  explore, parameter, dimension, measure, set
    1. Type - yellow
    2. Name  green
  2. SQL Parameters - any line that starts with sql and finishes with ;;
    1. Name of the parameter - orange
    2. Value - red
      1. Liquid - pink
      2. LookML variable or field reference - purple
  3. Parameters - all other parameters
    1. Name - blue
    2. Value - lighter blue
      1. Strings - brown
      2. Yesno - Pink-ish
      3. Array - light purple
      4. Variable - purple

Did not colourise the parenthesis as I’m using a separate extension called Bracket Pair Colorizer 2 that works in all languages and helps me identify matching parenthesis.

Let me know if there’s anything else that would be useful in the syntax highlighting and whether it’s a plugin that you would be useful for you. I’m still learning the grammar and how to name and reference it properly. 

These are the settings that then can be used to change colours of the different part of the syntax:

efc44abf-39d5-4837-a607-4459e8855202.png
7 4 2,758
4 REPLIES 4
Top Labels in this Space
Top Solution Authors