reddit / emacs
Emacs 29: Install Tree-Sitter parser modules with a minor mode
cjk101010 · 2022-12-25 21:08
cjk101010 · 2022-12-25 21:08
This is my first Emacs plugin, I hope it helps some fellow Emacs users :-)
Pay08 · 2022-12-25 22:45
This doesn't seem to be a minor mode? Also, you can call straight from use-package.
ieoa · 2022-12-25 23:05
This is really cool. It'll help people adopt TS just that bit more easily.
kr1kun · 2022-12-26 05:19
does it complies to lsp?
why do I need it?
Pay08 · 2022-12-26 07:25
I'm surprised there's no built-in way to do this.
Pay08 · 2022-12-26 07:27
>does it complies to lsp?
LSP is a protocol. You don't "compile to it".
>why do I need it?
Read the article.
NoisyFrequency · 2022-12-26 07:52
It'll probably come with the upcoming Emacs release, at least I hope so.
kr1kun · 2022-12-26 08:17
comply - not compile
I read the article, but it seems that TreeSitter - just a parser, without code analysis tools.
That's why I asked wether that parser is complies to lsp. Because nowadays you don't expect only parsing functionality. And as part of lsp implementation - it could be usable.
I used a couple lsp providers to write ts code, and I'm trying to understand, if this parser can be used with other analysis tools, for code navigation and refactoring purposes.
And first of all, I'm trying to understand, how is it connected to https://github.com/emacs-lsp/lsp-mode? I'm sure, that existed lsp implementations already parse source code. Why TreeSitter?
cjk101010 · 2022-12-26 08:23
Yeah, you are right. I don't know why I called it minor mode – it is just a bunch of functions. Must've blacked out. Thanks for the pointer, will fix the article.
emax-gomax · 2022-12-26 08:25
Also this https://github.com/casouri/tree-sitter-module/issues/13
cjk101010 · 2022-12-26 08:29
TreeSitter provides an concrete syntax tree to the editor. You can use it to navigate through the code, to transform it, etc, pp. LSP has nothing to do with it.
You can implement refactoring functions using the provided tree, or you can implement something like „move point to the next expression,“ etc, pp
Tree-Sitter is IMHO a game changer for editors. Look at Neovim what it did to their ecosystem, eg the [nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects) plugin.
cjk101010 · 2022-12-26 08:29
I wouldn't bet on it. Eli seems to think this should be done by 3rd party tooling.
cjk101010 · 2022-12-26 08:34
Oh, that's neat! Didn't see this.
NoisyFrequency · 2022-12-26 08:37
Oh ok
casouri · 2022-12-27 02:39
What do you use tree-sitter-cli for? I’d suggest not requiring it, since installing it is yet more work, while this package’s purpose is to save work. Also technically you need a C & C++ compiler ;-)
cjk101010 · 2022-12-27 05:54
I don't need it (anymore). Thanks for the pointer, it was left from an earlier draft. I removed it from the documentation.