Look for clarification I guess on how nvim-treesitter handles injected languages and folds.
For example, with tools/languages like Vue, they embed html, css, and javascript into a single filetype.
<template>
<div>Hello World</div>
</template>
<style>
div {
color: red
}
</style>
<script>....</script>
Now Treesitter can parse this and provide the correct syntax highlighting, and I can confirm this with TSPlayground. But I cannot figure out how folds are applied/triggered based on this.
In queries/vue/folds.scm
, there are queries for the template, script, and style tags that define a “vue” file.
[
(element)
(template_element)
(script_element)
(style_element)
] @fold
So my understanding is that these nodes will only get folds applied to them. If that’s the case, trying to expand them to include more from javascript leads to an “Invalid Node Type”.
I guess this is a long way of asking, are fold defs for injected languages handled by the injected language, or the parent language?