Sublime Forum

Syntax Highlighting for Custom Language Assistance

#1

Hi, I made a programming language with similar syntax to Lisp. I tried the syntax highlighting for Lisp, but it does not suffice. How can I create my own syntax highlighting for Sublime Text 3?

I tried looking it up, but most of the posts I found seemed to only work for Sublime Text 2.

Thanks!

0 Likes

#2

There is documentation available for the new Sublime 3 YAML syntax highlighting here.

Based on my own (recent) experience, I would suggest a combination of this and looking at the syntax definition for something with similar (in your case Lisp) syntax rules. The default packages for Sublime 3 are available on github, and the file for Lisp formatting in particular is here.

You could either use the Lisp file as a basis for your own syntax or use it as a guide to see how various constructs in Lisp are being handled to help you with how the whole system hangs together.

1 Like

#3

Thank you so much! Do you know where I would save .sublime-syntax file on a Mac?

0 Likes

#4

Preferences->Browse Packages… will open up a finder that shows you where the package directory is (The Preferences menu is located under Sublime Text in the menu on MacOS). You can drop the file directly into the User folder there.

If you plan on/have already created things like snippets and completions for your language, then a better thing to do would be to create a directory at that location named after your language, and the put all of the stuff in there. That would keep everything related to the language support all in one location.

It still works either way, though.

2 Likes

#5

Awesome, thank you very much!

0 Likes