Sublime Forum

SQL syntax highlighting doesn't recognize double dash with no space after it as comments

#1

With the latest update to SQL syntax highlighting in Build 4200, comments in .sql files that start with double dash but have no space before the first word (ie “--word”) are not recognized or highlighted as comments. Putting a space after the dash triggers the correct highlighting. At least in PostgreSQL, the double dash does not need a space after it to be a comment, anything after the double dash is a comment. This update has made existing sql files using this syntax visually confusing. This occurs with the default dark and light color schemes (Breakers and Mariana).

image

0 Likes

#2

Old naive SQL syntax definition has been replaced by more sophisticated implementations which follow official language specs more closely. Due to SQL using dedicated grammar for each statement/expression, providing nearly complete syntaxes is however hard.

Primary SQL dialects, currently supported are MySQL, T-SQL and Cassandra. PostgreSQL is available but more or less a copy of MySQL, but far away from feature complete.

SQL syntax is an alias for MySQL for historical reasons, which requires a space after --.

The following little helper may be used to change default dialect (which is also used in all embedded SQL code sections) can be found at:

Something like that would be part of SQL package, ideally.

0 Likes

#3

I have made a PR with a fix:


follow the instructions in the readme of the repo if you want to try it out early :slight_smile:

1 Like

#4

you’re a rockstar! I made the change locally and it works like a charm. thank you!

0 Likes