I am developing my own Domain Specific Language (DSL) and the filename extension is .xyz
.
Emacs doesn't know how to highlight syntax in .xyz
files so I uausally turn on typescript-mode
or json-mode
. But the available syntax highlight mode is not good enough for me, so I am considering writing my own syntax highligher for Emacs editor. Any tips on this task? Any toolkit recommendation?
Alternatively, I would be happy with any available mode that highlights common keywords such as class
, string
, list
, variables before =
sign and after @
sign, braces {}
, brackets []
, question mark ?
and exclamation mark !
. Any existing languages have similar syntax?
I am not color-blind and not picky on colors. Any syntax highligher that highlights above syntax can solve my problem.
If you are satisfied with simple syntax highlighting for keywords and comments only, there is a helper for this called define-generic-mode
, which is documented in the elisp manual.
Some examples of using it can be found in generic-x.el
distributed with Emacs.
But highlighting of variable names is not covered by this. For that, you need to be able to parse the DSL using semantic
/bovine
, as whether a particular string is interpreted as a variable name depends on context, and not just simple regexp matching.