Skip to content

Instantly share code, notes, and snippets.

@josephholsten
Last active November 10, 2023 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephholsten/c65d6562b85329d239cc1c10dce82063 to your computer and use it in GitHub Desktop.
Save josephholsten/c65d6562b85329d239cc1c10dce82063 to your computer and use it in GitHub Desktop.
Tree Sitter Highlight Classes

I've noticed that some of the themes in helix are using undocumented highlight selectors. Well that's no surprise, these are comming from highlight.scm files in tree-sitter grammars, while the least terrible reference to these classes seems to be https://docs.helix-editor.com/themes.html

We can do better. So first I'm going to just start collecting notes from existing grammars. Two main things will be here: references to "standard" classes, and also guidance for how to change "non-standard" classes.

Standard

Current doc source: https://github.com/helix-editor/helix/blob/master/book/src/themes.md

  • attribute - Class attributes, HTML tag attributes

  • type - Types

    • builtin - Primitive types provided by the language (int, usize)
    • parameter - Generic type parameters (T)
    • enum
      • variant
  • constructor

  • constant (TODO: constant.other.placeholder for %v)

    • builtin Special constants provided by the language (true, false, nil etc)
      • boolean
    • character
      • escape
    • numeric (numbers)
      • integer
      • float
  • string (TODO: string.quoted.{single, double}, string.raw/.unquoted)?

    • regexp - Regular expressions
    • special
      • path
      • url
      • symbol - Erlang/Elixir atoms, Ruby symbols, Clojure keywords
  • comment - Code comments

    • line - Single line comments (//)
    • block - Block comments (e.g. (/* */)
      • documentation - Documentation comments (e.g. /// in Rust)
  • variable - Variables

    • builtin - Reserved language variables (self, this, super, etc.)
    • parameter - Function parameters
    • other
      • member - Fields of composite data types (e.g. structs, unions)
  • label

  • punctuation

    • delimiter - Commas, colons
    • bracket - Parentheses, angle brackets, etc.
    • special - String interpolation brackets.
  • keyword

    • control
      • conditional - if, else
      • repeat - for, while, loop
      • import - import, export
      • return
      • exception
    • operator - or, in
    • directive - Preprocessor directives (#if in C)
    • function - fn, func
    • storage - Keywords describing how things are stored
      • type - The type of something, class, function, var, let, etc.
      • modifier - Storage modifiers like static, mut, const, ref, etc.
  • operator - ||, +=, >

  • function

    • builtin
    • method
    • macro
    • special (preprocessor in C)
  • tag - Tags (e.g. <body> in HTML)

    • builtin
  • namespace

  • special

  • markup

    • heading
      • marker - the
      • 1, 2, 3, 4, 5, 6 - heading text for h1 through h6
    • list
      • unnumbered
      • numbered
      • checked
      • unchecked
    • bold
    • italic
    • strikethrough
    • link
      • url - URLs pointed to by links
      • label - non-URL link references
      • text - URL and image descriptions in links
    • quote
    • raw - verbatim code or equations
      • inline
      • block
  • diff - version control changes

    • plus - additions
      • gutter - gutter indicator UNUSED
    • minus - deletions
      • gutter - gutter indicator UNUSED
    • delta - modifications
      • moved - renamed or moved files/changes
      • gutter - gutter indicator UNUSED

Non-Standard

  • boolean -> constant.builtin.boolean
  • repeat -> keyword.control.repeat, or possibly function.builtin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment