folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.57k stars 34 forks source link

feature: Include language injections for Treesitter node selections #242

Closed Trildar closed 1 year ago

Trildar commented 1 year ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

When writing in languages that use language injections in their parsers, e.g. Astro, Flash Treesitter mode does not allow selecting nodes inside of language injections.

Describe the solution you'd like

Include nodes from language injections in Flash Treesitter selection.

Excuse me if I'm wrong, but I think this can be done just by including ignore_injections = false in the call to LanguageTree:named_node_for_range.

Describe alternatives you've considered

A configuration option could also be added for whether language injections should be skipped, though I'm not sure what situations that would be useful for.

EDIT: After trying it I realised that the TSNode:parent() traversal apparently does not cross outside of a language injection (which seems odd to me, but suppose that's for Neovim or Treesitter to decide, not sure which one is responsible). So I suppose having a config would make more sense because of that.

Additional context

No response

folke commented 1 year ago

It did work like that, but a change in Neovim disabled that by default. Fixed now