cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.14k stars 80 forks source link

Refactor tree-sitter / LanguageDefinitions code #2498

Open pokey opened 3 months ago

pokey commented 3 months ago

Instead of passing in two tree-sitter-specific components here https://github.com/cursorless-dev/cursorless/blob/bc50059a8b702bf02dd1be864a30b48fed7d8fa6/packages/cursorless-engine/src/cursorlessEngine.ts#L47-L48 we should instead just pass in a LanguageDefinitions. Note that we'll need to rework ParseTreeAction, as that still requires tree-sitter. The proper way to do that would be to support passing in a map of custom actions, but maybe there's an easier way to do it in the short term

AndreasArvidsson commented 3 months ago

We also still have getNodeAtLocation on the language definitions interface. If we want to separate Tree sitter from the language definition we can't really return a Tree sitter syntax node :D

I think the right way of doing this is that once we have migrated all the scope handlers away from legacy we can remove get node at location and create a new Tree sitter package containing the language definitions implementation. Maybe we can make a canonical tree representation that language definition can return for the parse tree action?

pokey commented 3 months ago

yeah we prob should wait till all legacy languages migrated I guess?

Yeah not sure bout parse tree action. Was initially thinking that could be a custom action exposed by the same tree-sitter package that exposes the language definitions impl. I think we prob want to move to supporting actions defined outside of the engine as we move towards lean core

AndreasArvidsson commented 3 months ago

That sound simplest and also the correct priority wise.

That is also one solution.