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.