Treesitter module developement

This file contains links and information pertinent to the tree sitter module.

design decisions

  • should tree sitter support for languages be opt in? (like lsp) This would make sense as tree sitter support is spotty at best and people can opt in with a +treesitter flag

languages

Hacks in testing

  • scss currently this snippet adds scss “support”. it mostly works but the tree errors on most scss specific syntax. I have not gone very deep but it does work for basics examples
        (after! tree-sitter
          (pushnew! tree-sitter-major-mode-language-alist
                    '(scss-mode . css)))
    

text objects

  • bind keys to tree sitter text objects

  • only rebind to tree sitter text-objs if the language supports tree sitter

    • This can be achieved by either making a variable of major modes that have tree

    sitter support (which requires a little bit of fore thought)

    • or rebind keys if a tree-sitter error is raised (which is slower but easier to maintain:tm:)
  • Handle bad bounding 0 1 error to emmit a more useful message

Current bugs

  • text objects can’t seem to be rebound? currently i can’t rebind text objects using the conventional methods

  • in some conditions a Bad bounding indices: 0, 1 error is raised. This is due to the query needed not existing. The easiest fix would be to add these querys but this is easier said than done

  • Tree sitter somehow is being eager loaded

plugins

To look for / write

To consider adding

misc

Witticism

  • current candidate:
    • the :emacs vc module stole our tree joke
7 Likes

Hi @jeetelongname, did not know where else to ask this, so putting here.

I see Elixir module does not have tree-sitter flag, but there is grammar for it already present. Any chance to get it enabled? Otherwise, how much added complexity would it be to add it? Asking because my elisp-fu is barely novice level, but might even give it a shot.

Hi,

It should do. I have it added to my init.el and its documented in the elixir readme [1]. It does not have a highlights file (though one is in the works afik). though. everything else should work :tm:

Footnotes ─────────

[1] https://github.com/doomemacs/doomemacs/blob/c44bc81a05f3758ceaa28921dd9c830b9c571e61/modules/lang/elixir/README.org#module-flags Regards, – Jeetaditya Chatterjee /Sent using my text editor/

Ah indeed it does. My bookmark to modules.org was for develop branch and turns out it was never updated after switch to master.

Thank you for confirming and working on it!

1 Like

As of Emacs 29, there are various treesitter modes for languages, is there any news of supporting that? I know that 29 is unsupported, but i would be happy to contribute.

Once I am able to sit on 29 I will work on adding support for that to doom. If you have any suggestions then feel free to leave them here

I just got the upgrade to emacs 29.1 on Fedora 39 and wanted to use the built-in tree-sitter library. I think the biggest issue, are the new major-modes that are used for this: <lang>-ts-mode. This seems to break all configuration for that language in doom, as all of that is applied only to the original <lang>-mode, so I think supporting the built-in treesitter might require quite a lot of changes in other modules as well.

Hi, are there any plans to support the built-in treesitter?

It seems there are plans to support the built-in treesitter, see Use built-in treesitter on Emacs 29+ · Issue #7623 · doomemacs/doomemacs · GitHub.

And it requires an upstream change, see: Request: Enable use with Emacs 29's built-in tree-sitter modes · Issue #144 · emacs-tree-sitter/tree-sitter-langs · GitHub.