# Ocaml-lsp-server: Text object queries

**URL:** <https://discuss.ocaml.org/t/ocaml-lsp-server-text-object-queries/16852>\
**Category:** Ecosystem\
**Tags:** ocaml-lsp-server\
**Created:** [June 18, 2025, 10:20am UTC](https://discuss.ocaml.org/t/ocaml-lsp-server-text-object-queries/16852 "2025-06-18T10:20:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joelreymont](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/joelreymont/32/5937_2.png) [@joelreymont](https://discuss.ocaml.org/u/joelreymont)\
**Post date:** [June 18, 2025, 10:20am UTC](https://discuss.ocaml.org/t/ocaml-lsp-server-text-object-queries/16852/1 "2025-06-18T10:20:50Z")

</div>

I noticed that text object queries are not supported by ocaml-lsp-server.

```auto
❯ hx --health ocaml
Configured language servers:
  ✓ ocamllsp: /Users/joel/.opam/5.2.0+ox/bin/ocamllsp
Configured debug adapter: None
Configured formatter: ocamlformat
Binary for formatter: /Users/joel/.opam/5.2.0+ox/bin/ocamlformat
Tree-sitter parser: ✓
Highlight queries: ✓
Textobject queries: ✘
Indent queries: ✓

```

What does it take to add them?

---

<div class="post-metadata">

**Author:** ![Release-Candidate](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/release-candidate/32/3550_2.png) [@Release-Candidate](https://discuss.ocaml.org/u/Release-Candidate)\
**Post date:** [June 18, 2025, 10:26am UTC](https://discuss.ocaml.org/t/ocaml-lsp-server-text-object-queries/16852/2 "2025-06-18T10:26:21Z")

</div>

Helix’ “text object queries” aren’t a LSP thing (or they use a strange name for some LSP feature [Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/)), but a Treesitter feature that has to be added to Helix itself, if I understand this page [Adding textobject queries](https://docs.helix-editor.com/guides/textobject.html) correctly

---

<div class="post-metadata">

**Author:** ![joelreymont](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/joelreymont/32/5937_2.png) [@joelreymont](https://discuss.ocaml.org/u/joelreymont)\
**Post date:** [June 18, 2025, 10:28am UTC](https://discuss.ocaml.org/t/ocaml-lsp-server-text-object-queries/16852/3 "2025-06-18T10:28:38Z")

</div>

I don’t think that’s the case. Same Helix gives me the ability to select a type, function, etc. with Zig.

```auto
❯ hx --health zig
Configured language servers:
  ✓ zls: /opt/homebrew/bin/zls
Configured debug adapter: lldb-dap
Binary for debug adapter: /opt/homebrew/opt/llvm/bin/lldb-dap
Configured formatter: zig
Binary for formatter: /opt/homebrew/bin/zig
Tree-sitter parser: ✓
Highlight queries: ✓
Textobject queries: ✓
Indent queries: ✓

```

---

<div class="post-metadata">

**Author:** ![Release-Candidate](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/release-candidate/32/3550_2.png) [@Release-Candidate](https://discuss.ocaml.org/u/Release-Candidate)\
**Post date:** [June 18, 2025, 10:37am UTC](https://discuss.ocaml.org/t/ocaml-lsp-server-text-object-queries/16852/4 "2025-06-18T10:37:32Z")

</div>

> [@joelreymont](#):
>
> I don’t think that’s the case.

Here is the `textobjects.scm` file for zig in the Helix source:

> <https://github.com/helix-editor/helix/blob/1491cbc8f3694e52a565d192eaef1a7bf200d33f/runtime/queries/zig/textobjects.scm>

whereas for Ocaml it is missing: [helix/runtime/queries/ocaml at 1491cbc8f3694e52a565d192eaef1a7bf200d33f · helix-editor/helix · GitHub](https://github.com/helix-editor/helix/tree/1491cbc8f3694e52a565d192eaef1a7bf200d33f/runtime/queries/ocaml)

---

<div class="post-metadata">

**Author:** ![amongonz](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@amongonz](https://discuss.ocaml.org/u/amongonz)\
**Post date:** [June 18, 2025, 10:38am UTC](https://discuss.ocaml.org/t/ocaml-lsp-server-text-object-queries/16852/5 "2025-06-18T10:38:51Z")

</div>

Text objects are a Helix feature, not an LSP one, and they require a tree-sitter grammar (ugh) and tree-sitter queries file for language-specific support.

---

<div class="post-metadata">

**Author:** ![joelreymont](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/joelreymont/32/5937_2.png) [@joelreymont](https://discuss.ocaml.org/u/joelreymont)\
**Post date:** [June 18, 2025, 10:39am UTC](https://discuss.ocaml.org/t/ocaml-lsp-server-text-object-queries/16852/6 "2025-06-18T10:39:58Z")

</div>

Mea culpa!

I’ll add it to my list of OCaml-related things to fix.

---

<div class="post-metadata">

**Author:** ![beajeanm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/beajeanm/32/189_2.png) [@beajeanm](https://discuss.ocaml.org/u/beajeanm)\
**Post date:** [June 19, 2025, 8:25am UTC](https://discuss.ocaml.org/t/ocaml-lsp-server-text-object-queries/16852/7 "2025-06-19T08:25:23Z")

</div>

I tried to add some to a similar neovim projects [nvim-treesitter-textobjects/queries/ocaml/textobjects.scm at master · nvim-treesitter/nvim-treesitter-textobjects · GitHub](https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/master/queries/ocaml/textobjects.scm).  
I’m far from a treesitter expert, so I expect things can be done better, but it’s starting point.
