-
Notifications
You must be signed in to change notification settings - Fork 247
Extend ocaml textobjects #853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for contributing. Can you describe what it fixes and what the previous function capture was doing? |
3c981dd to
9743310
Compare
|
Added some inline comments to make it easier for future devs to understand it as well. |
|
I would also appreciate some guidance on how to test it directly in this repo. README explains how to install it but it looks like it mostly focuses on the official package and not the locally developed one. |
|
I managed to test it locally:
|
|
So, I think this doesn't actually cover some cases, e.g. It won't match |
9743310 to
e3da70a
Compare
|
That's really useful, would you mind if I add that to https://github.com/nvim-treesitter/nvim-treesitter-textobjects?tab=contributing-ov-file? I pushed the changes to handle the "standalone" fun & function now, so I think it's ready. |
|
I also added struct & module support, which worked great locally, but those seem to be rejected 😢 I could go with using |
|
I just did. |
446915d to
be417ac
Compare
I opened #856 |
|
assignment.inner should also select lhs as a separate query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR extends OCaml textobject support by adding patterns for more function definition styles and introducing assignment textobjects. The changes aim to provide better navigation and text selection capabilities for OCaml code in tree-sitter-based editors.
Key changes:
- Added function textobject patterns for lambda expressions (
funandfunctionsyntax) in both standalone and parenthesized contexts - Added assignment textobjects with left-hand side, right-hand side, inner, and outer captures
- Added module definition textobjects using the
@classcapture - Refined existing function textobjects to only match actual functions (with parameters)
- Removed generic parenthesized expression block pattern in favor of built-in editor support
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| queries/ocaml/textobjects.scm | Extended textobject queries with new patterns for functions, assignments, modules, and blocks |
| BUILTIN_TEXTOBJECTS.md | Updated documentation to reflect newly supported assignment textobjects for OCaml |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
All done, I think? |

Ocaml function textobjects updates.
I actually tested those when I wrote the change in meain/evil-textobj-tree-sitter#134 but I was kindly asked to upstream here.