helix/helix-lsp/src
Michael Davis 7e7a98560e
LSP: Eagerly decode request results in the client
Previously the `call` helper (and its related functions) returned a
`serde_json::Value` which was then decoded either later in the client
(see signature help and hover) or by the client's caller. This led to
some unnecessary boilerplate in the client:

    let resp = self.call::<MyRequest>(params);
    Some(async move { Ok(serde_json::from_value(resp.await?)?) })

and in the caller. It also allowed for mistakes with the types. The
workspace symbol request's calling code for example mistakenly decoded a
`lsp::WorkspaceSymbolResponse` as `Vec<lsp::SymbolInformation>` - one of
the untagged enum members (so it parsed successfully) but not the
correct type.

With this change, the `call` helper eagerly decodes the response to a
request as the `lsp::request::Request::Result` trait item. This is
similar to the old helper `request` (which has become redundant and has
been eliminated) but all work is done within the same async block which
avoids some awkward lifetimes. The return types of functions like
`Client::text_document_range_inlay_hints` are now more verbose but it is
no longer possible to accidentally decode as an incorrect type.

Additionally `Client::resolve_code_action` now uses the `call_with_ref`
helper to avoid an unnecessary clone.
2025-03-22 14:40:29 -04:00
..
client.rs LSP: Eagerly decode request results in the client 2025-03-22 14:40:29 -04:00
file_event.rs LSP: Remove future wrapper from `Client::notify`, `Client::reply` 2025-02-01 19:32:37 -05:00
file_operations.rs make path changes LSP spec conform (#8949) 2024-01-29 01:34:45 +09:00
jsonrpc.rs LSP Client: Accept floats with trailing zeros as valid JSONRPC IDs (#12376) 2024-12-31 12:45:47 -06:00
lib.rs LSP: Fix offset encoding test case 2025-03-06 17:13:38 -05:00
transport.rs minor: Tweak some verbose LSP logs 2025-03-04 11:25:11 -05:00