reddit / emacs

Is anyone working on a ruby tree sitter mode?

pedzsanReddit · 2022-12-06 17:57
I'm looking at the Emacs 29 `typescript-ts-mode.el` and see that to leverage tree sitter, the mode is far different than programming modes before -- which isn't surprising. What is surprising is that I can't find what I'll call `ruby-ts-mode` anywhere. I'm goofy enough to leap off and start my own but thought I'd poke the bushes a little to see if one already exists.
x64_Toaster · 2022-12-06 19:35
It might be worth asking on emacs-devel as well - there was a call for volunteers a couple of months ago, and I didn't see anyone claim ruby (though I also don't check that list too often): https://lists.gnu.org/archive/html/emacs-devel/2022-10/msg00707.html
nnreddit-user · 2022-12-06 20:08
The way Commercial Emacs works is, if the language has: 1. a parser (e.g., github.com/tree-sitter-ruby) 2. a highlights.scm (e.g., github.com/tree-sitter-ruby/queries) 3. an indents.scm (e.g., github.com/nvim-treesitter/queries/ruby) Then a three-line boilerplate mode fits the bill. Here's the three minute video [Depeche Modes with Emacs](https://youtu.be/QHlB6w8HFao).
pedzsanReddit · 2022-12-07 01:16
Cool. But now I'm a little confused. Why are there foo-ts-mode.el files? And, for example, the typescript-ts-mode.el is more complex than his example. Looks like I have a lot to learn... Update: Ahh... I see now. I didn't know what "Commercial Emacs" was.
codemuncher · 2022-12-07 05:46
So I just installed the ruby treesitter shared library, and treesit-{inspect,explore}-mode worked instantly. ​ Looking at the c-ts-mode.el file, looks like you have to primarily define: \- Indentation rules \- Syntax highlighting rules And maybe some boiler plate on top of that. ​ I'd recommend checking out [https://github.com/casouri/tree-sitter-module](https://github.com/casouri/tree-sitter-module) for building the native treesit libraries that are required to enable the various languages.