[ANN] Advanced Code Navigation coming to OCaml-LSP

Jump to Target

Currently, the standard LSP protocol only allows for generalized code navigation (goto definition, goto declaration, goto implementation, goto type-definition), which is not very useful when it comes to precise movements.

Coming to OCaml-lsp soon will be the ability to jump from one point in your code to another based on Merlin’s Jump command.

Implementing this functionality took a bit of thinking as we wanted a solution that works for all supported editors (Vscode, Emacs and Vim) without any additional specific client implementations.
We used a combination of call actions plus the LSP showDocumentRequest to move the cursor to the interesting position.

The call actions display are contextual and will display only if it’s relevant to the code under the cursor.

Here is a demo in VSCode.

merlinjumptest-ezgif.com-video-to-gif-converter

16 Likes

Just got this working in Emacs with lsp-mode using the execute code action keybinding s-l a a.

Thank you for adding that functionality, first impressions is it navigates nicely going forward but I would like to navigate back to where I came from. That probably requires some additional Emacs integration and configuration.

2 Likes

This looks very cool. Great idea to use a key binding

Happily, most of the Emacs LSP integration can be driven by keybindings Keybindings - LSP Mode - LSP support for Emacs

1 Like