tomatoaway · 2022-12-20 16:17
So I took the plunge and upgraded to emacs29. Smooth so far, just having trouble getting tree-sitter to work.
I've downloaded and generated the libraries for the various languages from:
https://github.com/casouri/tree-sitter-module
Then I copied all of them from `dist` to `/usr/local/bin`, and set the treesitter load path, and checked that tree-sitter can see them
(require 'treesit)
(treesit-available-p) ;; t
(setq treesit-extra-load-path '("/usr/local/lib"))
;; open a javascript document to test.
(treesit-ready-p 'javascript) ;; t
My javascript document only has the JavaScript (major?) mode, but I'm not getting any error messages or anything when I type invalid statements.
Is there something I'm missing? Do I also need to install the [tree-sitter](https://emacs-tree-sitter.github.io/getting-started/) package and enable `(global-tree-sitter-mode)`?
Where is `tree-sitter-hl-mode ` in the native implementation?
orzechod · 2022-12-20 16:27
the `tree-sitter` and `tree-sitter-langs` third-party packages are no longer required. third-party shared libraries, describing the grammar of various programming languages, are still required but according to the code you provided it looks like those are already in place.
try enabling `tsx-ts-mode` and see what happens. (it should be completely compatible with vanilla JavaScript). at least for me, with emacs 29, I get the expected syntax highlighting and indentation goodies.
error messages will come from either an external linter or LSP integration like `eglot` or `lsp-mode`. (treesit can help make these features more accurate but itself does not provide these features).
my configuration is here, if you want to have a look: https://github.com/orzechowskid/duomacs/blob/emacs-29/language-modes/duomacs-javascript-typescript.el
lianacrossk7n · 2022-12-20 16:51
you need to enable the major mode too, so run `js-ts-mode`. the built-in treesitter modes replace the standard modes instead of adding a minor mode on top, like the 3rd party tree-sitter package.
Since these are not enabled by default, I use the following in my config to map overrides:
(push '(css-mode . css-ts-mode) major-mode-remap-alist)
(push '(python-mode . python-ts-mode) major-mode-remap-alist)
(push '(javascript-mode . js-ts-mode) major-mode-remap-alist)
(push '(js-json-mode . json-ts-mode) major-mode-remap-alist)
(push '(typescript-mode . typescript-ts-mode) major-mode-remap-alist)
(push '(c-mode . c-ts-mode) major-mode-remap-alist)
(push '(c++-mode . c++-ts-mode) major-mode-remap-alist)
tomatoaway · 2022-12-20 19:44
Ah, this was the solution -- thank you so much!
tomatoaway · 2022-12-20 19:48
> error messages will come from either an external linter or LSP integration like eglot or lsp-mode. (treesit can help make these features more accurate but itself does not provide these features).
Ah I see, so I still need lsp-mode for error messages. Okay, good to know, thanks!
jumpUpHigh · 2022-12-20 20:23
Eglot would be [built-in emacs 29](https://www.reddit.com/r/emacs/comments/y94nxp/eglot_is_merged_into_emacs_git_master/). lsp-mode may not be needed separately.
tomatoaway · 2022-12-20 20:28
THIS is the winning combination I was looking for! Eglot + Tree-sitter are perfect!
tryptych · 2022-12-21 00:00
TIL about `major-mode-remap-alist` \-- thanks!