leostera / caramel

:candy: a functional language for building type-safe, scalable, and maintainable applications
https://caramel.run
Apache License 2.0
1.06k stars 25 forks source link

Tooling support #41

Open leostera opened 3 years ago

leostera commented 3 years ago

We'll need things like:

Formatting

Calling caramel fmt should reformat all inputs.

Doc Generation

Calling caramel docs *.mli *.rei --output ./docs should create docs from those interface files.

Language Server

What I'm considering atm is bundling Merlin within Caramel, so we have control over the subset of the language being accepted.

Calling caramel language-server should be the equivalent to booting a Merlin daemon, and we'll need a way to create the right .merlin files as well, possibly through a separate command that can be properly guided by a build system (e.g. caramel language-server setup ./path/to/lib/a ./path/to/lib/b ...)

REPL

TBD

nicobao commented 3 years ago

Language Server

[...]

Calling caramel language-server should be the equivalent to booting a Merlin daemon, and we'll need a way to create the right .merlin files as well, possibly through a separate command that can be properly guided by a build system (e.g. caramel language-server setup ./path/to/lib/a ./path/to/lib/b ...)

Besides the fork of Merlin, we'll also need our custom language server supporting the standard MS protocol (and running Merlin behind be scene to do the hard work, as you suggested!) I suppose we can fork either Erlang LS or OCaml LS, or even Elixir LS which is more mature, and work on that. It's a shame that Erlang LS/Elixir LS don't rely on a shared library implementing a language agnostic LSP.

I guess the biggest challenges will be:

leostera commented 3 years ago

I've been looking more into the ocaml-lsp project and I think it makes most sense to vendor since it already comes with Merlin vendored as well.

On top of this, we may get away by submitting a patch to the vscode-ocaml-lsp plugin that makes the actual lsp binary path configurable so it points to caramel lsp instead. I can't promise it'll be that easy, but it can't be that hard 🙌🏽

nicobao commented 3 years ago

Yes! We might benefit from looking into that project: https://github.com/axelson/ls_proxy @axelson recommended it ^^, he's the maintainer of elixir-ls

axelson commented 3 years ago

I'd love to collaborate on LSP Proxy! It's a bit rough around some of the edges but it can be very helpful in understanding all of the messages that are going back and forth between the server and client.