How to enable the editor action to switch between implementation and interface (ml/mli) files for neovim?

I have been using ocamllsp with neovim using neovim’s native LSP client. However, it lacks the functionality of switching between implementation and interface. The functionality is implemented in ocamllsp under the name ocamllsp/switchImplIntf.

Can someone share how to configure neovim to use this action? or just configuration you used to enable this feature with any editor that has a built-in language server protocol client.


I use <localleader> s bound to vim-ocaml/ocaml.vim at 755d96ccebbe08fb0e25d0d4f8ffaf0cf86e3217 · ocaml/vim-ocaml · GitHub


thanks. ocaml-lsp 1.13.0 has implemented the code action but I don’t know how to integrate this with neovim lsp config.

While waiting for some vim geek to share their configs, I will use vim-ocaml solution for now.

Looking at the implementation of the OCaml lsp server the “open alternate” code action depends on the LSP client having the showDocument capability. If you use Neovim’s native LSP support then you might have to wait until feat(lsp): support window/showDocument (#19977) · neovim/neovim@0773a9e · GitHub makes its way into a release (it isn’t in NVIM v0.8.0).

Also I wasn’t aware that the LSP server has so many code actions, I can only see a tiny fraction of those in neovim… (I get offered only 1 or 2 code actions).

You can check the client capabilities with this command in Neovim: :lua print(vim.inspect(vim.lsp.protocol.make_client_capabilities())) (it is possible to modify that prior to passing it to the LSP, it might be possible to implement the missing functionality in Lua, but I’d rather wait until Neovim gets it properly).

1 Like