reddit / emacs

TypeScript development with Emacs, tree-sitter and LSP in 2022

cpbotha · 2022-06-12 20:02
jkdufair · 2022-06-13 02:22
This is about to improve my already awesome typescript world in emacs
vfclists · 2022-06-13 05:00
The joy of illustrations, good examples and explanations. I can probably get going with this stuff now.
flyin1501 · 2022-06-13 11:19
How is the performance with eglot? In my experience editing JavaScript with eglot is really sluggish until I set `eglot-events-buffer-size` to 0, which disables events logging (which is slow because for some reason it logs with `pp-to-string`).
doolio_ · 2022-06-13 11:19
To use tree-sitter does one have to disable the regex syntax highlighting typically offered by the different language major modes?
cpbotha · 2022-06-13 11:32
I had a look at the code this morning, and specifically `tree-sitter-hl--setup` -- it's currently trying to cooperate with the existing font-lock logic as far as possible. Ideally though, programming modes will start relying on tree-sitter directly.
cpbotha · 2022-06-13 11:34
On this native-compilation build of latest Emacs trunk I've not experienced any subjective slowdowns. That being said, that's a great tip to disable events logging when you're happy that everything works as it should.
doolio_ · 2022-06-13 11:35
Ok thanks. Yes, I expect the various language major-modes shipped with Emacs will be updated to remove the regex syntax highlighting once tree-sitter is part of Emacs core. It will be great.
GujjuGang7 · 2022-06-15 22:12
Does eglot support dap-mode? I'm currently trying to narrow down my "ide experience" with emacs. So far I have: tree-sitter, lsp-mode, company, dap-mode, project.el (built-in) and package.el (built-in). Do you recommend any alternatives to these? I have heard of packages like vertico, corfu, eglot, etc. But I'm not sure where they fit in.
Shivalicious · 2022-06-21 12:05
tsi.el sounds cool, but is there any point in using it if you’re also using apheleia-mode?
cpbotha · 2022-06-21 12:40
You are right with regard to the end-result, there's indeed not much difference. Personally however, I prefer having the indentation correct as I'm typing, versus apheleia which formats only on save. :)
Shivalicious · 2022-06-21 12:41
Gotcha. Thanks for clarifying!
Sevenstrangemelons · 2022-08-04 22:49
Hey this is random but I'm wondering any tips for typescript dev in emacs, or maybe you config for reference. Thanks.
jkdufair · 2022-08-05 13:36
I'm working with `typescript-mode`, `lsp`, and now `tree-sitter`. It's downright delightful. LSP is just excellent and the more I commit to learning it the more the barriers between thinking and doing disappear. I do also have two F-key bindings for quickly switching between `typescript-mode` and `web-mode` since `typescript-mode` doesn't parse JSX in a way I can navigate/edit JSX as if it were s-expressions. Here's my current config. A bit of a mess, but look in the "Programming / JS/TS", "Programming / LSP" and also in the "Incubator / Tree-sitter" sections, specifically. One of these days I'll go in there and tighten everything up 😂
jkdufair · 2022-08-05 13:36
Oops. https://gitlab.com/jkdufair_home/dotfiles/-/blob/master/emacs.d/dufair-init.org
Sevenstrangemelons · 2022-08-06 00:35
thanks
chmanie · 2022-08-17 18:00
Thanks a lot for sharing this. I didn't quite understand yet, do I need `typescript.el` if I only want `.ts` file syntax highlighting? You write > By adding the code below to your init, you’ll automatically get tree-sitter syntax highlighting for all supported languages Is TypeScript a supported language? I added those lines of code to my config but I still don't get syntax highlighting in my TypeScript files.