CKolkey / ts-node-action

Neovim Plugin for running functions on nodes.
359 stars 20 forks source link

Run Node Actions in embedded code #38

Closed matthias-Q closed 1 year ago

matthias-Q commented 1 year ago

Feature request: So node actions are activated by filetype and not by the embedded code. I have SQL embedded in Julia/R and different languages embedded in Markdown. Would be nice to have the possibility to use node actions there as well.

CKolkey commented 1 year ago

Just perusing the help docs for treesitter, I don't see a way to get the name of the parser for the node under the cursor, but that's all you would need to do this. Seems like you can use vim.treesitter.get_parser(0):language_for_range({ ... }):lang() to get that, where the { ... } is a range for the current node.

matthias-Q commented 1 year ago

It should be possible. When you have treesitter-playground, you can get the name of the parser that is used for this section.

matthias-Q commented 1 year ago

Nice, works like a charm. Thank you!