[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tree Sitter and highlights.scm file
From: |
Tad Lispy |
Subject: |
Tree Sitter and highlights.scm file |
Date: |
Thu, 30 Nov 2023 11:35:42 +0000 |
Hi! It's my first post ever to a mailing list, so I hope I do everything
right. I'm also not very experienced with Emacs Lisp.
Here is my context. I'm working on a major mode for a new programming
language. I'd like to leverage the built-in Tree Sitter support for
syntax highlighting. My colleague works on the Tree Sitter grammar. In
their repository there is a file called `queries/highlights.scm`. It's a
scheme file that contains queries for different syntactic elements. Most
other grammars I see also have such file, so I think it's standard in
Tree Sitter grammars. I think it's generated by the `tree-sitter`
command line program and later customized by a grammar author. It looks
like all the necessary information for syntax highlighting is there.
Since it's also a lisp, it should be possible to use this file to
automatically derive font lock rules. But all examples of tree sitter
modes I see re-implement all the queries in Emacs Lisp with
`treesit-font-lock-rules` function. Why is that?
Before Emacs 29 there was a suite of 3rd party packages maintained by
Tuấn-Anh Nguyễn. One of the packages is a library of Tree Sitter
languages, that for each language contains the `highlights.scm` file.
See for example
https://github.com/emacs-tree-sitter/tree-sitter-langs/blob/master/queries/elm/highlights.scm.
So it looks like previously it was possible to utilize this file. Can we
still do it with Emacs 29?
Kind regards,
Tad Lispy
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Tree Sitter and highlights.scm file,
Tad Lispy <=