You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I was hoping to get a better understanding of the project to be able to implement custom requests. Lots of Fiber and stream code aside, I noticed that the main logic is in the on_request function in ocaml_lsp_server.ml, where it pattern matches against the type of request method.
I looked at a couple of <lsp_method>.ml files in the ocaml_lsp_server/src/ directory, and noticed that they accomplish the following:
the handler calls Document.Merlin to do something, saving it to a result.
result is then passed to a method-specific logic to generate some data, which is sent back to the client by the handler.
I'll admit that I don't have lots of experience with OCaml or the OCaml ecosystem, but I was slightly lost in the document.ml file, mostly because I have no idea what the Document module is doing, nor do I know how Merlin works. How important is it to know which Merlin method to call, and how can I get better at it?
Thank you!
The text was updated successfully, but these errors were encountered:
jpoly1219
changed the title
Prerequisites for contributing?
Is knowing Merlin a prerequisite for contributing?
Aug 14, 2024
A quick answer to the title "Is knowing Merlin a prerequisite for contributing?" is: it depends on what your trying to do. Most of the time a query is forwarded to Merlin using the protocol described here. This is simple plumbing and requires little knowledge of how Merlin. If you want to perform custom analysis then you need to understand how Merlin internals work.
The usual route a of a request is something like this:
The client sends the request, encoded using the LSP protocol to the ocaml-lsp server.
The server decodes the request and dispatch it it the Ocaml_lsp_server module which is the heart of the server and main entry point when adding support for new requests. You can grep for Req_ to see how custom requests are plugged in here.
The requests themselves are implemented in a standardized way (thanks @xvw!) in the custom_request folder.
Usually this means parsing the query, querying Merlin and return the encoded the answer.
Querying Merlin is done by obtaining the Merlin instance attached to the current Document and using the dispatch function with the appropriate query from Merlin's own protocol. A canonical example of how to do that is the get_documentation request.
Hi! I was hoping to get a better understanding of the project to be able to implement custom requests.
Just a warning: we try not to clutter the server with custom request that also require custom client support. Every feature that can be implemented via the official protocol should be done that way. If your goal is to have your custom request merged upstream, I encourage you to open an issue describing precisely its interface and the reason why you think it would be useful.
Hi! I was hoping to get a better understanding of the project to be able to implement custom requests. Lots of Fiber and stream code aside, I noticed that the main logic is in the on_request function in
ocaml_lsp_server.ml
, where it pattern matches against the type of request method.I looked at a couple of
<lsp_method>.ml
files in theocaml_lsp_server/src/
directory, and noticed that they accomplish the following:Document.Merlin
to do something, saving it to aresult
.result
is then passed to a method-specific logic to generate some data, which is sent back to the client by the handler.I'll admit that I don't have lots of experience with OCaml or the OCaml ecosystem, but I was slightly lost in the
document.ml
file, mostly because I have no idea what the Document module is doing, nor do I know how Merlin works. How important is it to know which Merlin method to call, and how can I get better at it?Thank you!
The text was updated successfully, but these errors were encountered: