Commit graph

92 commits

Author SHA1 Message Date
Simon Cruanes
075361a3b3
move to ocamlformat 0.27; format 2025-04-07 15:03:22 -04:00
Simon Cruanes
691eac4863
format 2025-04-07 14:03:39 -04:00
nojaf
d7dd8ecec0
Add filter_text_document 2025-04-07 14:03:34 -04:00
Simon Cruanes
43839963e1
format 2025-04-07 13:32:27 -04:00
Simon Cruanes
f83580c8c1
Merge branch 'vendor-lsp' 2025-04-07 13:32:20 -04:00
Simon Cruanes
5b264f9f67
fixes and updates 2025-04-07 13:31:04 -04:00
Sacha-Élie Ayoun
5ba6f40a3c remove useless file
Signed-off-by: Sacha-Élie Ayoun <sachaayoun@gmail.com>
2025-04-03 17:20:32 +01:00
Sacha-Élie Ayoun
aae7605aff re-expose lsp and jsonrpc without requiring lsp.linol and lsp.
Signed-off-by: Sacha-Élie Ayoun <sachaayoun@gmail.com>
2025-04-03 16:45:42 +01:00
Sacha-Élie Ayoun
b188de9c7d minor changes
Signed-off-by: Sacha-Élie Ayoun <sachaayoun@gmail.com>
2025-04-03 16:22:27 +01:00
Sacha-Élie Ayoun
09d9ccce04 test because opammmm
Signed-off-by: Sacha-Élie Ayoun <sachaayoun@gmail.com>
2025-04-03 16:09:24 +01:00
Sacha-Élie Ayoun
68314089ee forgot to import linol_lsp in eio
Signed-off-by: Sacha-Élie Ayoun <sachaayoun@gmail.com>
2025-04-03 15:01:06 +01:00
Sacha-Élie Ayoun
7f1c20700a remove lsp dependency in dune files
Signed-off-by: Sacha-Élie Ayoun <sachaayoun@gmail.com>
2025-04-03 14:47:35 +01:00
Simon Cruanes
50cc7a9527
format code 2025-04-03 08:16:22 -04:00
Vincent Laporte
e43f2e588a Drop redundant dependency on atomic
Some checks failed
github pages / deploy (push) Has been cancelled
build / build4 (4.14.x, ubuntu-latest) (push) Has been cancelled
build / build5 (1.19.0, 5.1.x, ubuntu-latest) (push) Has been cancelled
build / build5 (1.19.0, 5.2.x, ubuntu-latest) (push) Has been cancelled
build / build5 (1.19.0, 5.3.x, ubuntu-latest) (push) Has been cancelled
build / build5 (1.20.1, 5.1.x, ubuntu-latest) (push) Has been cancelled
build / build5 (1.20.1, 5.2.x, ubuntu-latest) (push) Has been cancelled
build / build5 (1.20.1, 5.3.x, ubuntu-latest) (push) Has been cancelled
build / build5 (1.22.0, 5.1.x, ubuntu-latest) (push) Has been cancelled
build / build5 (1.22.0, 5.2.x, ubuntu-latest) (push) Has been cancelled
build / build5 (1.22.0, 5.3.x, ubuntu-latest) (push) Has been cancelled
The linol library already depends on OCaml ≥ 4.14

(cherry picked from commit 630a6226bc)
2025-02-04 17:01:45 -05:00
Sacha-Élie Ayoun
573565fbf5 support lsp 1.19 & 1.20
Signed-off-by: Sacha-Élie Ayoun <sachaayoun@gmail.com>
2025-01-10 13:38:51 -05:00
Simon Cruanes
02e678cbe2
handle End_of_file by exiting 2024-10-24 12:55:57 -04:00
Simon Cruanes
41a6c3e306
fix: make server requests thread safe 2024-10-23 16:41:02 -04:00
vbot
4ca2d55b80
Use positionEncoding advertised by clients 2024-08-08 17:06:44 +02:00
Christoph M. Wintersteiger
55a28825a3
Formatting 2024-07-31 16:58:18 +01:00
Christoph M. Wintersteiger
262e57e7c2
Use IO.catch in async 2024-07-31 16:57:03 +01:00
Christoph M. Wintersteiger
8123e95a5f
Log exceptions in async notification handler 2024-07-31 16:25:01 +01:00
Christoph M. Wintersteiger
9a7e1c221c Revert "I've gone too far, but it's too late to go back."
This reverts commit 7ccdfff203.
2024-07-31 16:20:53 +01:00
Christoph M. Wintersteiger
7ccdfff203
I've gone too far, but it's too late to go back. 2024-07-30 21:01:05 +01:00
Christoph M. Wintersteiger
845371e3a0
Rebase-fix 2024-07-30 16:50:35 +01:00
Christoph M. Wintersteiger
f2e3c4b369
Update return from on_req_shutdown 2024-07-30 16:42:39 +01:00
Simon Cruanes
e99d0d6cc4
add more error handlers and logging around notif/request handlers 2024-07-30 16:41:50 +01:00
Christoph M. Wintersteiger
6785e46492 Add on_req_shutdown 2024-07-22 12:49:02 -04:00
Nick Hu
74a9fc0dc5
Support textDocument/didSave notification 2024-05-29 13:37:32 -04:00
Nick Hu
d72988f63e
advertise inlay hints server capability 2024-05-29 13:37:32 -04:00
Nick Hu
2b02a94eba Implement Eio backend 2024-05-22 10:19:03 -04:00
Simon Cruanes
c9ade392ef
feat jsonrpc2: add ?on_received/?on_sent
this can be useful to debug
2024-04-15 12:41:47 -04:00
Simon Cruanes
6d2d6a8f40
udpate @since tags 2024-02-20 13:00:34 -05:00
Vincent Laporte
630a6226bc Drop redundant dependency on atomic
The linol library already depends on OCaml ≥ 4.14
2024-02-17 11:33:01 -05:00
Simon Cruanes
9eb9514401
update to lsp 1.17 2024-02-15 14:43:55 -05:00
Simon Cruanes
10bea1e417 small fix 2024-02-15 14:25:59 -05:00
Simon Cruanes
1f4337cda2 more tracing 2024-02-15 14:25:59 -05:00
Simon Cruanes
fa2900d8e5 feat: add trace and atomic to trace blocking IOs 2024-02-15 14:25:59 -05:00
Simon Cruanes
dda10ad74b fix: run some parts of notification handling sequentially 2024-02-15 14:25:59 -05:00
Xavier Denis
af49b048c9 Add handlers for unknown requests and notifications 2023-10-20 09:51:37 -04:00
Simon Cruanes
498c62d46f add functions in jsonrpc2 to send queries/notifs directly from server 2023-10-20 09:50:33 -04:00
Anton Sorokin
bb92d7d73b [#24] Expose get_uri for notify_back
Problem:
As in #24, it's impossible to extract `uri`  variable from
`notify_back`, but sometimes we want to do this

Solution:
Add `method get_uri = uri` to notify_back
2023-08-08 12:24:04 -04:00
Simon Cruanes
e50388a3be
expose logs_src 2023-08-04 16:41:16 -04:00
Simon Cruanes
09f2f9a1b2
expose log source 2023-08-04 16:34:56 -04:00
Anton Sorokin
09311ae258 [#22] Threat shutdown and exit requests correctly
Problem:
As in [#22], we want to shut down our LSP server correctly.
That means we should close the pipe and end process after an exit request.
This require proper `shutdown : unit -> bool` function passed
to `Jsonrpc2.Make.run` which returns `true` after
the server received an exit request.

Right now both exit and shutdown requests are setting
LSP server's internal var `_quit` to true. It's very intuitive to
use this var in `shutdown`, but we can't do it, since in this case
the server would stop receiving new messages right after the
shutdown request, despite the fact  according to the LSP specification
it had to wait the exit request.

Solution:
Instead of `_quit : bool` use
```
status : [ `Running | `ReceivedShutdown | `ReceivedExit ]
```
and suggest
```
shutdown () = s#get_status = `ReceivedExit
```
in docs for `Jsonrpc2.Make.run` and in the templete/example.
2023-08-04 09:31:23 -04:00
Simon Cruanes
c6969ab87c
api break: put spawn in the server itself, not IO 2023-08-02 14:25:07 -04:00
Anton Sorokin
8c4ca80411
[#20] Handle messages with null value for "params" field
Problem:
If an LSP client sends a request with "params":null instead
of omitting the params field or smth like "params":{},
decoding error appears.

Solution:
Replace `null` value for "params" to `{}`
2023-07-10 15:54:36 +03:00
Simon Cruanes
35e89143c4
basic docstrings 2023-04-01 21:48:40 -04:00
Heitor Toledo Lassarote de Paula
8857d5e7c5
Add a comment to send_server_req
Problem: There is an invariant that must be satisfied to call that
function.

Solution: Describe it to warn users of jsonrpc2.
2023-03-15 12:02:02 -03:00
Heitor Toledo Lassarote de Paula
431f3ea126
Disable batch processing
Problem: There was a misunderstanding when implementing this: batch
processing should not return responses individually, but rather return a
list with batch responses. This will require some further logic to group
such responses in order to process them in sequence.

Solution: We return those methods to being unhandled.
2023-03-14 15:27:32 -03:00
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