ocaml / ocaml-lsp

OCaml Language Server Protocol implementation
Other
768 stars 121 forks source link

Is knowing Merlin a prerequisite for contributing? #1357

Open jpoly1219 opened 2 months ago

jpoly1219 commented 2 months ago

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:

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!

voodoos commented 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:

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.