-
Notifications
You must be signed in to change notification settings - Fork 719
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
Add tree-sitter based highlighter #5099
base: master
Are you sure you want to change the base?
Conversation
Hello, |
{ create_tree_sitter_highlighter, &tree_sitter_desc } }); | ||
registry.insert({ | ||
"tree-sitter-injection", | ||
{ create_tree_sitter_injection_highlighter, &tree_sitter_injection_desc } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I don't care about about highlighting but I'm interested in commands to select syntax tree nodes etc.
LSP provides some of that but it's not optimized for it.
In general, integrations with external tools live in scripts in rc/
.
I wonder if that could work for this feature too?
We can add any missing generic highlighter types like the InjectionHighlighterApplier
to support these cases.
I think there is great value in having an obvious boundary between C++ core and scripts. It keeps us honest.
With the shared library approach, tree sitter can do something that other integrations cannot.
I wonder what's the difference to https://github.com/phaazon/kak-tree-sitter ?
As a user, I think it would be great if we concentrate most effort on one approach.
In either case, I think tree sitter integration is highly valuable and I'd probably follow whichever approach gains traction.
Thanks
Hello, I think it’s an interesting approach, but in the same time, it bothers me a bit. Not because I’m the author of However, I do think that what I made with KTS is super complex and that Kakoune needs more toolings to make it easier to integrate (and I think @krobelus would also benefit from that for |
This is indeed an impressive PR, but I do not intend to merge it for a few reason. First I do not want to have multiple, competing, built-in highlighting to maintain, and I do not want to solely rely on tree-sitter for highlighting. Having both will likely lead to one bitrotting with time. Second (and most importantly), as noted by @phaazon, this goes against Kakoune's design principles. Introducing a dependency directly in core for a functionality that could be implemented externally. I do agree that there are some limitations at the moment, I have not looked at kak-tree-sitter but I suspect it is a far more complex codebase than what you did in that PR, I hope we can find a way to simplify how external plugins that rely on buffer content work. |
MotivationI just spend some time with
|
About the partial updates / edit in place, I have this still open about that topic. It’s not something I have started working on because I want to stabilize the performance and features already (and I think it’s more important to have semantic text-objects first before going full optimizations), but clearly yes, it can have a negative impact on “how fast you see highlighting”. Also, the speed at which |
if the slow part is parsing you can probably work around it by computing a diff so you can use the incremental API.
not necessarily; you can write to Kakoune's socket directly, see https://github.com/tomKPZ/pykak
That's an interesting problem indeed. |
can we have something like vim's text-properties |
Description
This introduces a
tree-sitter
highlighter that maps tree-sitter captures to kakoune faces.This allows kakoune to highlight some recursive grammars that the regions based highlighting is not able to parse (e.g. Nix, Shell, Python).
Example - Nix
This is an example from a Nix codebase i recently visited.
The problem here is that a Nix string can contain interpolated nix expression, which in turn can have nested strings with the same delimiter (e.g
"outer string ${ let var = "inner string"; in var }"
).Building
This highlighter is optional and can be excluded by passing
tree_sitter=no
tomake
.Related Issues
TODO
%val{runtime}/grammars
)combined
injections this would allow us to e.g. highlight the embedded Bash in the example above)