The ts
, js
, and css
are all tree-sitters
based grammars.
I do not think this is possible at the moment. I however done a similar feature request for this on the dev forum not long ago. It is actually something very useful with countless use cases including the one you mentioned here. Hopefully as more of us start asking, they would eventually add support?
It is definitely technically possible but I am not sure how they would implement it. I hope the API is a clean one!
There is also a NeoVim example on the feature request on how you might be able to achieve this, once, if ever supported, but again this is very dirty, you need to dig and mess around with each tree-sitters
grammar manually which in turn might break things etc. I am really not a fan of that for sure!