"rename all refs" in neovim / OCaml / LSP?

Here is the situation:

  1. the code currently compiles
  2. we have OCaml lsp running on nvim
  3. we have a variable we want to rename (say, from do_calc_ab to do_calculation_ab
  4. type signatures stay the same, the only thing that changes is the name

question: can we rename all references of the variable correctly ?

argument for yes: IntelliJ F2 does this fine for Rust / Java / Scala / …

argument for no: apparently “jump to def” is non-trivial in OCaml, and “list all refs” is unsolved in Merlin; so “rename all refs” seems by definition not solved

I currently do NOT have this working in neovim. I’m trying to figure out if (1) this is my fault, i.e. there is a way to do this in OCaml LSP, but I’m unaware of (2) this is currently not possible with OCaml LSP.

Thanks!

1 Like

VS Code F2 renames within a file for OCaml in a syntax-sensitive way, even respecting the parameter label vs argument distinction. So there is LSP support within a file, but not across files (not even across x.ml and x.mli).

2 Likes

Ah, this makes sense, being consistent with Merlin’s go-to ref.

P.S. I only had good experiences with “go to definition”, it would not work sometimes but never where that would be annoying (e.g. “remote” external libraries). So I think LSP renaming could “try harder” (and correspondingly also collecting references). But it wouldn’t provide enough value for me to complain personally.