Sublime Forum

SQL syntax coloring not being applied to .sql files

#1

Hi, I have had a very weird behavior in ST4 for a few weeks now, where I repeatedly try to assign .sql-files to the SQL syntax, which as far as I can tell is built in to ST. (Can disable it via Package Control, it then says “disable built-in v4189”).

Despite my best efforts, whenever I open an SQL file:

  • It opens without any syntax highlighting (all text is white)
  • It says in the bottom right corner that the syntax is “SQL” (not “Plain text”), but when I click it to open the list of available syntaxes, the option “SQL” does not have a checkmark next to it
  • Clicking in the bottom right corner and explicitly selecting “SQL” does apply syntax highlighting (and if I open the menu again, the option “SQL” does have a checkmark, indicating it is selected)
  • Clicking in the bottom right corner, selecting “Open all with current extension as…” and selecting SQL also applies syntax highlighting, but the next time I open a .sql file (even the same one), the text is just white again

I.e., it seems like SQL syntax is selected, but that the coloring is not applied before I re-select it.
This only applies to SQL. I have yaml, python and markdown files in the same project, which all behave correctly. (Update while typing: It seems like toml files, where I want the syntax “editorconfig”, might have the same problem)

  • I’m on the latest version (build 4189)
  • I have repeatedly restarted ST4
  • I have repeatedly disabled and re-enabled the SQL package
  • running window.run_command('apply_format') in the console does not apply the highlighting, even when it says “SQL” as the selected syntax and the highlighting is wrong
  • running sublime.set_timeout(lambda: window.run_command('apply_format'), 1) also does not apply the highlighting

Does anyone have any idea what might be going on? I am soon out of hair to rip out!

0 Likes

#2

I have never heard of such a command…

The thing to check is when you open a sql file and it doesn’t have colors, see what view.settings().get('syntax') returns when you execute it in the ST console. It may be a plugin with an on load hook applying a different syntax called SQL etc.

0 Likes

#3

Sounds very much like you have Monokai Pro theme installed.

see: https://github.com/monokai-pro/sublime-text/issues/178

0 Likes

#4

THANK YOU!
Ah, yes, I did have the theme installed, and removing it solved the problem – this was indeed crazymaking

0 Likes