Wrapper around the OCaml lsp library to make it easier to write LSP servers
Find a file
Heitor Toledo Lassarote de Paula 5388f58530
Handle server requests
Problem: Linol can only send notifications from the server to the
client, but not requests.

Solution: The solution was inspired by Haskell's `lsp` package. We first
maintain a `server_request_handler_pair` data structure which represents
some server request and its associated response handler. Now
`notify_back` may take these fields and use it to actually handle a
request and its response. Changes to `notify_back` are propagated
throughout `server.ml`.

On `jsonrpc2.ml`, we refactor the notification and request handlers so
that we may handle the response and batch response handlers and batch
call as a courtesy. For a response, we keep a hash table that tracks an
ID to the `server_request_handler_pair` in other to be able to call the
handler that was associated with the response. After we get such
response (indexed by the server request's ID), we remove it from the
hash table to prevent a memory leak.

Since the server needs to keep track of the server request IDs, I added
a mutable `id_counter` in order to generate a fresh LSP ID (using
`fresh_lsp_id`) for every outgoing request.

For debugging, if we error while decoding a JSON, I now print the
exception too.
2023-03-14 14:46:46 -03:00
.github/workflows ci 2022-05-01 10:07:59 -04:00
example/template autoformat 2023-03-10 23:12:41 -05:00
src Handle server requests 2023-03-14 14:46:46 -03:00
.gitignore gitignore 2023-03-10 22:44:11 -05:00
.ocamlformat add ocamlformat 2023-03-10 23:12:29 -05:00
dune-project refactor: split into lwt server and abstract interface 2021-02-09 19:40:31 -05:00
linol-lwt.opam opam 2023-03-11 00:05:04 -05:00
linol.opam move to lsp 1.14 2023-03-10 23:12:13 -05:00
Makefile prepare for 0.3 2021-05-05 13:44:09 -04:00
README.md doc: build badge in readme 2021-03-25 17:36:42 -04:00

Linol build

This is a wrapper around the lsp library, which provides base types for the protocol. Linol ("linol is not ocaml-lsp") provides an object abstraction so that users can override only the methods they provide, and a Lwt implementation of the jsonrpc wire protocol.

License

MIT license.