-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LSP frontend #905
Add LSP frontend #905
Conversation
This is required when we introduce merlin-lsp.opam package in the next commits.
This library implements LSP. The initial implementation of protocol structures is based on @bryphe work in bryphe/merlin-language-server[1] and then with additions from facebook/flow[2]. This uses `ppx_deriving_yojson` for JSON encoding/decoding. Implemented only subset of LSP for now, see src/lsp/protocol.ml. [1]: https://github.com/bryphe/merlin-language-server [2]: https://github.com/facebook/flow
This adds `ocamlmerlin-lsp` executable which implements lsp frontend for merlin using `lsp` library introduced in the previous commit. The implementation is simple - it translates LSP requests into merlin new protocol query commands for the exception of `textDocument/typeDefinition` which is implemented from scratch as there's no analogue in existing protocol. The executable is being installed as a part of a new `merlin-lsp.opam` package. The reason is partly b/c `merlin-lsp.opam` requires more 3rd-party dependencies (`ppx_deriving_yojson` in particular) and partly because the implementation is relatively untested.
See tests-lsp/README.md for more info. They are not configured to run on CI yet.
Ok, it's green now on 4.02: I moved By the way |
I think the |
@hcarty good catch! Will update the constraint. |
For the record the implementation is based heavily off bryphe/melrin-language-server by @bryphe with protocol additions from facebook/flow. I already mentioned that in commit messages but should have mentioned that here too. |
Great to see this feature! However, we need to be careful of not having any license violations. In particular, the |
This looks interesting! Would this warrant a new release of merlin any time soon? |
This adds
ocamlmerlin-lsp
which is a part of a newmerlin-lsp.opam
package.ocamlmerlin-lsp
adds LSP frontend for merlin with the following initial set of features:textDocument/definition
— analogue oflocate
textDocument/typeDefinition
— no analogue in current merlin frontend, likelocate
but locates the type of the specified expression.textDocument/completion
— analogue ofcomplete-prefix
textDocument/publishDiagnostics
— analogue oferrors
query, pushed by server on changes to sources.textDocument/documentSymbol
— analogue ofoutline
query.Structure:
merlin-lsp.opam
— newmerlin-lsp
package definitionsrc/lsp
— LSP protocol librarysrc/frontend/lsp
—ocamlmerlin-lsp
frontendtests-lsp
— tests forocamlmerlin-lsp
(far from comprehensive)I'm using this with neovim/ALE now and have vscode plugin which I'm not submitting in this PR but will do after some cleanup. For now it's hosted at https://github.com/andreypopp/vscode-merlin.