Sublime Forum

Question about default syntax highlighting

#1

I was wondering if there was a way I could change the behavior of an already built-in syntax highlighter. I use a version of lua that adds c-style comments to the language, and with the default highlighting it breaks it like shown:

0 Likes

#2

Save the following in a file my_lua.sublime-syntax in your package user directory:

%YAML 1.2
---
name: My Lua
scope: source.lua
contexts:
  main:
    - match: ""
      push: "Packages/Lua/Lua.sublime-syntax"
      with_prototype:
      - match: /\*
        scope: punctuation.definition.comment.begin.lua
        push:
          - meta_scope: comment.block.lua
          - match: \*/
            scope: punctuation.definition.comment.end.lua
            pop: true

It might not work in all cases (like trying to put thiskind of comment right in the middle of function declaration or things like that, but it should be fine in general.

0 Likes