You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: integrate tree-sitter injections for known filetypes
## Details
Discussed here: #141
When using this plugin with multiple filetypes it would be nice if the
tree-sitter injection logic could be offloaded from the user and be
handled by the plugin. Especially when the way markdown would be
injected is likely to be the same for anyone that wants the plugin to
work within the filetype.
Turns out this is fairly straightforward using the
vim.treesitter.query.set API, and specifying the injections query name.
The only slight complication is that in order to be able to extend the
existing injections (instead of overwriting them) we need a way to get
the current injection query as a string. The only way I found to do that
is to pull the files associated with injections then read and append
them together. All other ways to get the query return different kinds of
objects that would need to be serialized back into a string.
I have made this part of the configuration users can modify with the top
level `injections` field. Currently a value is only specified for the
gitcommit filetype. Injections are only processed if this plugin is
meant to run on that filetype, meaning additional configurations can be
added without impacting users who do not use this plugin on multiple
file types.
Users are free to:
- modify the queries used
- disable the injection, by setting enabled to false
- add entirely new queries that are coupled to this plugin rather than needing to
live in their global queries configuration
0 commit comments