Sublime Forum

Sublime-syntax: regex to detect end of file (as opposed to end of line?

#1

I’d want my syntax highlighting to detect unclosed brackets, by tinting as invalid_illegal the ending spaces of a file if their are in a context other than main.

For this, I was thinking of adding a match rule like this

  - match: \s*\Z
    scope: invalid.illegal

The problem is that \Z seems to be the same semantics as $ in sregex. So is there any other way to test with a regex in the syntax lexer wether we met the end of file as opposed to the end of line? Event in a line-based engine, one would thing that a special patter would be exposed to test if the line is the last line in the buffer without us having to resorts to linting the file.

0 Likes

#2

No, there is no way to know when EOF is reached in a syntax definition - you are better off using a linter for such tasks as highlighting unclosed brackets than the syntax definition itself

0 Likes

#3

That’s what I feared. I need to do research on making linters from scratch then

0 Likes