Skip to content
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

feat(ocaml): Add OCaml queries #723

Merged
merged 1 commit into from
Mar 8, 2025
Merged

Conversation

beajeanm
Copy link
Contributor

@beajeanm beajeanm commented Dec 8, 2024

I'm a treesitter queries newbie, so I'd appreciate the feedback on these queries.

This is an example of syntactically correct ocaml I used to test them:

let example_function param1 param2 = param1 + param2

class example_object =
  object (self)
    method do_stuff x = raise Not_found
  end

(* This is a comment. *)

let some_loops () =
  for variable = start_value to end_value do
    expression
  done;
  while boolean - condition do
    expression
  done

let conditionals () =
  let if_condition = if a then b else c in
  let match_cases = match a with b -> 1 | c -> 2 in
  let function_expression = function b -> 1 | c -> 2 in
  ()

let test_call =
  (* A function call, followed by 3 arguments. *)
  String.fold (fun a b -> a) 0 xs

let some_blocks =
  let begin_block = begin
    let inner_block = a in
    b
    end
  in
  let paren_block =
    (
      let inner_block = a in
      b
    )
  in c

@rbjorklin
Copy link

Hey @beajeanm! I just stumbled over this plugin and now I'm curious if you have been using this with OCaml? If you are would you mind updating the README in the PR to show which built-in textobjects you have implemented?

@beajeanm
Copy link
Contributor Author

beajeanm commented Mar 6, 2025

Hey @beajeanm! I just stumbled over this plugin and now I'm curious if you have been using this with OCaml? If you are would you mind updating the README in the PR to show which built-in textobjects you have implemented?

Hey, yes, I'm using this in my fork of the plugin. It work fine for the way I write my OCaml 😄 .
I'll try to update the README in the next couple of days.

@kiyoon
Copy link
Collaborator

kiyoon commented Mar 6, 2025

The README is generated automatically, no need to change it!

And I had no time to test it but if you say it's been working for months, I'd accept it.

@rbjorklin
Copy link

For what it's worth I ended up trying your fork after posting and it has worked well with my rudimentary usage as well.

@kiyoon kiyoon merged commit a68af6f into nvim-treesitter:master Mar 8, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants