Sublime Forum

Custom Syntax Highlight: Adding comments

#1

Hi!

I’m currently trying to make my own syntax highlight using the .sublime-syntax and I seem to have an issue with adding the comments part. In the documentation, it is specified I should just add the following:

prototype:

  • include: comments

string:

  • meta_include_prototype: false

However, when I add it, nothing happens. The code looks something like this (minus the header).

Tried adding it at the very top, before main, but it gives me a mapping error or a parse error. Any thoughts?

Thanks!

0 Likes

#2

I guess if you check the ST console, you will see a warning that there is no such context as comments - perhaps you meant to use line_comment or make a comments context that will match block comments and include line_comments?

1 Like

#3

In the console I usually get this error:

context line_comment has a scope name, but is unreachable, so the name will never be used

0 Likes

#4

Every context except main and prototype needs to be included somewhere to take effect. Otherwise it is just like declaring a variable in your program: in itself it does nothing.

You declared a context line_comment but it is not included either in Main or in prototype, so that’s why you get the error.

0 Likes