Plugin for setting options based on location in document (based on Tree-sitter)

There’s a pretty awesome Vim plugin called OnSyntaxChange that allows users to change settings based on the syntax group the cursor is currently located in.

This allows users to enable stuff like automatic text wrapping only when currently editing a comment or a triple quoted string in Python, or even change keybinds based on which part of the document you’re editing.

Obviously this doesn’t work with documents highlighted by Tree-sitter. Does anybody know if there is a similar plugin available for Tree-sitter? It seems like it should be really easy to implement, and since Tree-sitter is super fast it should be really performant too. I really miss having text-wrapping automatically enabled when I edit comments.

I have been considering creating this plugin myself, I just don’t want to reinvent the wheel.

Hey !

I think that we could make that a thing using some user autocommands.
I don’t remember any plugin that does this appart from this which is a subset of the problem you mention.

2 Likes