all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tad Lispy <hello@tad-lispy.com>
To: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Tree Sitter and highlights.scm file
Date: Thu, 30 Nov 2023 11:35:42 +0000	[thread overview]
Message-ID: <lui_X7s-LvP5tVNiPp-nsjVo4QmU1AYSDOkdwnv0O94u2sWnjGSQzWNEqz53hlWfZ0Oys_LutQIF2gcUJLa_9ISltOCPFNyEjz57whHYWKI=@tad-lispy.com> (raw)

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



             reply	other threads:[~2023-11-30 11:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 11:35 Tad Lispy [this message]
2023-12-01  8:25 ` Tree Sitter and highlights.scm file Eli Zaretskii
2023-12-02  3:40   ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='lui_X7s-LvP5tVNiPp-nsjVo4QmU1AYSDOkdwnv0O94u2sWnjGSQzWNEqz53hlWfZ0Oys_LutQIF2gcUJLa_9ISltOCPFNyEjz57whHYWKI=@tad-lispy.com' \
    --to=hello@tad-lispy.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.