Sublime Forum

Cannot find my New Syntax definition file in ST3

#1

In Sublime Text 3 I am trying to create a new syntax definition for my company’s programming language which proprietary. I’m having issues getting off the ground here. So here’s what I’ve done:

  1. I went to Tools --> Developer --> New Syntax
  2. I read up on how to create a syntax definition on the official documentation page and I entered a few basic rules to try to get started
  3. I saved the file under the default location here: C:\Users<username>\AppData\Roaming\Sublime Text 3\Packages\User<file name>.sublime-syntax EDIT: There is a \ after User folder in the path here, I thought I mistyped it but it’s there, I don’t know why it’s not showing.
  4. My syntax file was not loading for the the file extensions it was defined to, and I cannot find it in the list of syntax files when I go to View --> Syntax.
  5. I checked online and found threads like this one with a similar issue. It looks like my syntax file is either supposed to be found in the main list of syntax files or it’s found under the View --> Syntax --> User submenu, neither of which exist.
  6. I suspect my syntax files has errors, as it’s the first thing I’ve ever written in YAML, as well as my first time really diving into Regex, but I wouldn’t think issues in my syntax file would prevent it from showing up in the menus.

Any idea of what I’m missing here and how I can get my new syntax file to show up in the View --> Syntax list?

0 Likes

#2

My guess would be that your suspicion is correct and there’s something broken about the syntax. Syntaxes automatically appear in the menus (and the command palette), but they are indeed hidden if they’re broken in some fashion.

My guess would be that at the lowest levels only syntaxes that compile are considered to exist, since if there was an error the only thing known about them would be their name, and then assigning them as a syntax would have no visible result. In that case you might spend a bunch of time as the syntax developer trying to trouble-shoot why your matches aren’t working before eventually discovering that the file isn’t compiling at all.

If you check the Sublime console with View > Show Console or Ctrl+`, you will probably see an error generated there when you save the syntax. For example:

error parsing lexer: Packages/User/untitled.sublime-syntax: patterns must be a vector at line 11 column 3
generating syntax summary

The generating syntax summary line is always displayed when a syntax changes, so you can use that as an indication that Sublime has noticed a syntax change and tried to recompile; if everything works, that’s all you see.

Otherwise you see errors such as the above that point out the general location of the problem and the error (though as is usually the case in these sorts of things, the actual error message may be somewhat cryptic if you’re not familiar).

1 Like

#3

Thank you - I did read about using the console to check for errors in other threads and when I looked there I saw nothing of interest. It was the act of saving the file that I was missing and the console does indeed point me to issues in my syntax file. I have a path now to move forward, so thanks again!

1 Like