Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tree-sitter #305

Open
catern opened this issue May 17, 2023 · 5 comments
Open

Use tree-sitter #305

catern opened this issue May 17, 2023 · 5 comments

Comments

@catern
Copy link

catern commented May 17, 2023

Has anyone given thought to using tree-sitting in tuareg? (Or writing a new mode from scratch with tree-sitter and taking this opportunity to do some compatibility-breaking fixes on tuareg?)

@Chris00
Copy link
Member

Chris00 commented May 18, 2023

We have. IMHO, it probably would be a good idea. Someone will have to step in an do it though — I do not have the time for that.

@bbatsov
Copy link
Contributor

bbatsov commented Feb 27, 2025

Seems someone created an ocaml-ts-mode a while ago https://github.com/terrateamio/ocaml-ts-mode I see the treesitter code is like 200 lines, so perhaps we can do something similar here.

Or we can ask the author to merge his mode with Tuareg, as it seems he hasn't implemented indentation using treesitter and uses Tuareg for it. /cc @orbitz

Given the small size of our community, probably fewer major modes are better for everyone.

@monnier
Copy link
Contributor

monnier commented Feb 27, 2025

I'd welcome support for treesitter, indeed, and generally consolidating modes rather than having yet more of them (it's bad enough that we have caml-mode and tuareg-mode 😦 ).

@catern
Copy link
Author

catern commented Feb 28, 2025

If any existing tuareg-mode contributors are interested in adding treesitter support, my employer would be interested in funding that work. Since we have a number of extensions to OCaml syntax which often break tuareg-mode's syntax highlighting, it would make our life easier if tuareg-mode used a tree-sitter grammar (which, since it's useful for more than just Emacs syntax highlighting, is more likely to be kept up to date). So if anyone's interested (or knows someone who might be interested), you can email me at [email protected] (sorry if this comment is inappropriate here)

(We've also been considering making a new treesitter-based mode from scratch simply because it would be easier, and has the potential to go into core Emacs which might be nice. But improving tuareg-mode would probably be better)

@bbatsov
Copy link
Contributor

bbatsov commented Mar 4, 2025

I've started to experiment with a TreeSitter-powered OCaml mode here https://github.com/bbatsov/neocaml Let's see how far I'll be able to get. For now I prefer to work in a fresh project, just because it's much easier to play with TS this way, but if I get to a meaningful place I'd be happy to adapt the TS features for Tuareg.

My initial impressions are that getting font-lock support and structured navigation is fairly easy, but I'm guessing the indentation part will be trickier given OCaml's syntax. I'm hoping I'll be able to adapt Tuareg's SMIE approach to TS somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants