Open jpoly1219 opened 2 months ago
Hi @jpoly1219 !
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:
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.custom_request
folder.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!