Creating a Custom Grammar or Language Package


I’ve been searching but I can not find it.

I’m working with a language for which there is no syntax highlighting package (Not a “syntax-theme”), and actual grammar (often called Syntax Highlight).

This is where I define a regex and bind that regex to some color.
Say I have the custom keyword “atom” I want that to be purple when I write it inside the editor.

Not a “Syntax Theme”, but a “syntax highlighter”.

Whenever I see a topic here; most answers are too abstract.

Please stop. No. I need a clear and concrete example.
An example package that is minimal and shows just a few regexes changing the color of the code would be great.


The term I believe you’re looking for is “grammar”. Grammars are defined by language packages, such as language-ruby.

Also, to correct a misconception, as I stated here:

Making a certain chunk of text a certain color on screen is a two-step process:

  1. The grammar determines which chunks of text belong to which “scopes”
  2. The syntax theme determines which scopes are given which colors (or other visual effects)

The most minimal grammar I can think of is my language-generic-config package. But, once again, the grammar does not control the color of the code.


An odd choice of the word grammar, as we’re actually only looking at lexemes, unless the grammars contain entire parsers. This I doubt.

Anyhow, when I put your package into my .atom/language-generic-config-master and go to packages to install it I get the following.
Request for package information failed: Not Found


Just enter apm install language-generic-config into a command line.

Edit: And then use open in atom from the settings view.


apm is not installed on my system. Do I need to use it?


It is supposed to be installed with atom. Without it things like install are not going to work, even from within atom. Is it possible it is installed but not in your path?

There is a command in atom to install such tools but I can’t find it at the moment. Can someone help out here?


Is it possible for there to be multiple choices of lexemes for a grammar? If not then specifying grammar is all that is needed.


I dun goofed: apm is working fine it’s just that the Cygwin terminal (mintty) can’t work with the awkward pathing of Atom. Normal terminal (on windows) works fine.

Edit: now I don’t see the “Generic Configuration” option in the list of available “grammars”. How do I activate it after installing? It worked when I used the package manager but I don’t want the internet-relatedness, just a local package.

Edit 2: got it to activate by disabling and enabling it inside Atom using the package manager. Why was this needed? Also I changed the match from # to Q but it still considers # to be a comment. Why does this happen and how can I fix this?

Edit 3: I had to restart atom for the change to take effect. Is there a method to reload a package whilst atom still runs? Activating and deactivating it did not work.

Edit 4: ctrl + alt + r, reloads everything… Always a slight hassle to learn this new stuff :). Now to find out a list of all types of css values we can give lexemes…


I really think there should be much better documentation on this. I’ve done similar stuff with Sublime and I understand its pretty similar and both are based on TextMate but there really should be something in the documentation here like there is for Themes.


Agreed. There needs to be better documentation for lots of things :grinning:


For anyone still looking for information regarding custom syntaxes, I found really good source of information. Since most grammar packages are converted from Textmate, they also have nice documentation.

It’s pretty simple to apply these principles to CSON syntax.


I’ve started a guide here

Feedback is appreciated. I want it to be good for both people learning from scratch, and a technical reference for those who are already familiar with the process. If you have any trouble, or would like me to expand on or include a topic, please leave a comment.


:heart: Awesome. May I suggest that you create a PR to add on to the existing grammar tutorial at


I made the PR and checks are now passing (after an external link was down yesterday). I also added links to other sites I found useful when writing the package.