-
Notifications
You must be signed in to change notification settings - Fork 78
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
Implement experimental TSX-support via tree-sitter, if available. #155
Conversation
The following seems to do the trick without any changes to (add-hook
'typescript-mode-hook
(lambda ()
(setq-local font-lock-defaults '(()))
(tree-sitter-hl-mode 1)))
;; and
(tree-sitter-require 'tsx)
(add-to-list
'tree-sitter-major-mode-language-alist
'(typescript-mode . tsx)) There is no need for tsx mode - it is just typescript and some projects I have seen are using See my Thus, possibly, we just need a small manual of how to setup |
I think |
352c6d5
to
087e220
Compare
Converted to draft since this is very much a wip for some time. People are free to start using it and adding patches. Hopefully we can do this one quickly :) |
@josteink if you're feeling adventurous I've added some instructions for how to get the tree sitter integration to work for the new emacs proper version. It is pretty much done, but seeing how it isn't even in a feature branch of core emacs, setup is a little involved. I'd love some input though, if you or someone else wants to try! (I also vendored and modified the indentation engine for the rust tree sitter package so that we don't need to depend on too many things. I expect the rust tree sitter variant not to make it into master, but that is up for debate) |
For me these last 2 weeks I've been really busy with organizational stuff at work or things which are otherwise 100% C#, so I haven't yet had time to fully look into your changes. Because I know how frustrating it can be to feel that there is complete "radio-silence" when you are making big changes, and are looking for feedback, and getting none... So just to be clear: I'm definitely watching the changes as they are chugging along, and I'm very excited about the progress you report 😄 From what I understand, besides our (or more like it, your) implementation of TypeScript & TSX-support in typescript-mode using tree-sitter... There's a few issue we need to address or at least decide on:
Is that a correct understanding? Or are there other things I've missed? Or some things I've gotten 100% backwards? Both the Emacs & tree-sitter ecosystems are clearly in motion, and things are feeling a bit "messy" right now. That said, I don't think that should be a reason not to try to get onto the band-wagon. We just need to be somewhat considerate about how we do it 😉 As for questions of my own...
|
Oh don't worry, I'm just reporting things when I remember them
Great :)
Yes, or mac. I can add back the mac compat to the
It is prioritized for emacs 29, so I think it'd be wise to try to support it, much like many people supported nativecomp when it still was in a feature branch.
I think you're on the money!
Yes I agree. I think personally that we should support both variants. However I'm not sure how to do this either. I believe the rust variant will wither slowly if the upstream variant is good enough, which it has to be. So a part of me wants to just support the upstream variant. Another reason for the upstream variant to be the blessed one is that indentation is just that much easier.
This is the exact reasoning. It is a choice made upstream, but we should support both yet again.
Not sure. I was even thinking starting an effort of something like |
I think that idea sounds pretty neat, but it might come across in a way which is not entirely expected by the rest of the Emacs ecosystem (in that many packages still pressume major-mode = language)? That said, perhaps That way a typescript-tsx-mode becomes purely a derived-mode which bundles its config-along. And it could be in the same package, because as you say, there's not that much reason for each mode having its own repo if implementing them is simple enough. For a central model to succeed though, I guess one would also want a more structured approach to testing? Testing is always a bit more ad-hoc and messy than one expects it to 😉 |
Absolutely. I'm thinking something in the lines of nvim-treesitter. But not sure. I think it'll be smart to wait out the feature branch a little first. |
@josteink now the feature branch has landed, and if you (or anybody else) want to try things the installation is "pretty simple" and described at the bottom of the readme on |
5bd2305
to
fba29e0
Compare
Sounds exciting! I'll see what I get time for tomorrow. My latest project at work is heavy into TSX so it's definitely a welcome feature 🙂 |
fba29e0
to
22ad4f1
Compare
I actually think this is ready for merge into master, but I'll hold off until you've tried it. Need to look at ci now anyways.... |
f182be8
to
9e977a4
Compare
There are for the time being two tree sitter implementations. The first one is the older, rust based variant written by @ubolonton which is widely used in the emacs community, and the other is the newer variant from emacs proper, which for the time being is situated in the feature/tree-sitter branch.
9e977a4
to
2e2995d
Compare
Ok, so I've tested and tried your latest work... Ready for the verdict? It's gonna be a long one! 😄 Executive executive summary:
After that initial shocker, let's get down and dirty with the details! As for
|
WAAAAAAA :)
No, but as you've discovered, it is a little more inconsistent. This is mainly due to the indentation engine being what it is. It is just not really that good... This is for me the biggest showstopper. I'm not really sure how to deal with that. But more details later!
Highlighting is for now relayed completely over to the highlights described by the emacs-tree-sitter project. We could define our own, but I haven't.
Really? I haven't noticed that. I can look into that.
Yep!
That is very good to hear.
Agreed!
This can be due to two things.
Most likely it is a mix of the two. I've seen number 1 lots of times. You can usually see it when font-locking suddenly malfunctions, and is fixed by reverting the buffer. This is a known and reported bug.
Great! I've put at lot more effort in
They are supposed to be equals, but I'm not sure whether or not we really should support both variants. I think it will become a messy world, and I'd rather support the native version myself.
Hearsay! ... No, that's correct.
My opinion is to not use the melpa tree sitter, but I'm open to suggestions.
I think the best idea is to be dependency free. By that I think that we should only use what emacs itself supports, even if that requires installing some libraries to your computer.
Yeah, This can get messy.
This is true. We need to defcustom it, I think. If we keep tree-sitter in this repo.
I agree.
+10
Yeah it is pretty new. I've bothered @casouri a lot trying to get this mainlined, hehe:)
I'm very thankful for some level-headed advice and great suggestions! I think the wisest plan is to go for the separate repo. I also think that keeping this repo tree sitter free is smart, because it has some lineage, while tree sitter does not. I'll steal my code then and create the repo. As far as I can tell this issue is settled, and I'll make my own package for this. Thanks again for looking at this. I really think @casouri has done some amazing work here, and hope it'll be mainlined very soon! |
Make it so number one 😉
Then I guess we're at a 100% agreement.
Thanks for putting in the effort! I'm too busy to implement this code from scratch myself, but I'm more than happy to provide feedback and guidance in the ways that I can 😄 |
My pleasure! Closing this! |
If this is about
Which bug is this? AFAICT there is no such bug confirmed for
This is my vote too, though not (yet) on a technical ground. |
This is not a bug in your package :) this is a bug in the new native version.
Right! |
Sorry, I misread 😅 |
Any news on this? :) |
I have started work on this over at https://git.sr.ht/~theo/tree-sitter-modes for now! I might just move the tree sitter over to this org, but I'm still waiting for the feature branch to settle a little. The api changes from time to time, so it might be smart to hold off just a little bit. But if you are interested, the code is there, and works with the feature branch in core. |
RIghto. Was just curious about how things were going since there had been absolute radio silence for a month or so now 😁 |
Yeah, I know, sorry! I'm just waiting for now, but development hasn't halted at least :) |
Implement support using recipe suggested by @josemiguelo in this
comment: #4 (comment)
This closes #4.