cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Refactor tree-sitter / LanguageDefinitions code

Open pokey opened this issue 1 year ago • 3 comments

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

pokey avatar Jul 12 '24 15:07 pokey

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?

AndreasArvidsson avatar Jul 27 '24 10:07 AndreasArvidsson

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

pokey avatar Jul 27 '24 11:07 pokey

That sound simplest and also the correct priority wise.

That is also one solution.

AndreasArvidsson avatar Jul 27 '24 11:07 AndreasArvidsson