diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-08-11 22:03:16 +0200 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-08-11 22:09:27 +0200 |
| commit | 2332530360ede8559275367ad0a0eda20dd2bf30 (patch) | |
| tree | 47a6fb570c16a8104e67ee39b3ca8a3c6cfc68f8 | |
| parent | 9b904f5b7e9ea45b8ea5991f6eeb19c2f3949874 (diff) | |
LSP: ignore not only server notifications but all requests as welllsp
* We use 23 now as the "id" for all JSON-RPC requests.
* Every message with a different "id" can be ignored,
as it is a request, we haven't advertised to support.
Alternatively, we should perhaps send an error response to
unexpected requests?
* Fixes support for the ccls server which sends window/workDoneProgress/create
even though I didn't advertise it.
ccls cannot practically be used with FTsymbol$ though since it returns
full declarations.
You can perform a fuzzy symbol search, though.
| -rw-r--r-- | src/lsp.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -49,6 +49,9 @@ #include "qreg.h" #include "lsp.h" +/** Id to use for all JSON-RPC requests */ +#define TECO_LSP_ID "23" + static gboolean teco_lsp_shutdown(GError **error); /* @@ -414,7 +417,7 @@ teco_lsp_recv(teco_string_t *resp, GError **error) sj_Value key, val; while (sj_iter_object(&reader, obj, &key, &val)) - if (teco_json_eq(key, "id")) + if (teco_json_eq(key, "id") && teco_json_eq(val, TECO_LSP_ID)) /* it's a proper response */ return TRUE; @@ -514,7 +517,7 @@ teco_lsp_launch(GError **error) g_autofree gchar *root_uri_escaped = teco_json_escape(root_uri, strlen(root_uri)); g_autofree gchar *req = g_strdup_printf("{" "\"jsonrpc\":\"2.0\"," - "\"id\":1," + "\"id\":" TECO_LSP_ID "," "\"method\":\"initialize\"," "\"params\":{" /* @@ -894,7 +897,7 @@ teco_lsp_lookup_symbol(teco_string_t str, gboolean match_exact, GError **error) g_autofree gchar *symbol_escaped = teco_json_escape(str.data, str.len); g_autofree gchar *req = g_strdup_printf("{" "\"jsonrpc\":\"2.0\"," - "\"id\":1," + "\"id\":" TECO_LSP_ID "," "\"method\":\"workspace/symbol\"," "\"params\":{" "\"query\":\"%s\"" @@ -988,7 +991,7 @@ teco_lsp_symbol_auto_complete(const gchar *symbol, teco_string_t *insert) g_autofree gchar *symbol_escaped = teco_json_escape(symbol, symbol_len); g_autofree gchar *req = g_strdup_printf("{" "\"jsonrpc\":\"2.0\"," - "\"id\":1," + "\"id\":" TECO_LSP_ID "," "\"method\":\"workspace/symbol\"," "\"params\":{" "\"query\":\"%s\"" @@ -1085,7 +1088,7 @@ teco_lsp_lookup_definition(teco_buffer_t *buffer, teco_int_t pos, GError **error g_autofree gchar *uri_escaped = teco_json_escape(uri, strlen(uri)); g_autofree gchar *req = g_strdup_printf("{" "\"jsonrpc\":\"2.0\"," - "\"id\":1," + "\"id\":" TECO_LSP_ID "," "\"method\":\"textDocument/definition\"," "\"params\":{" "\"textDocument\":{" @@ -1156,7 +1159,7 @@ teco_lsp_lookup_references(teco_buffer_t *buffer, teco_int_t pos, GError **error g_autofree gchar *uri_escaped = teco_json_escape(uri, strlen(uri)); g_autofree gchar *req = g_strdup_printf("{" "\"jsonrpc\":\"2.0\"," - "\"id\":1," + "\"id\":" TECO_LSP_ID "," "\"method\":\"textDocument/references\"," "\"params\":{" "\"textDocument\":{" @@ -1213,7 +1216,7 @@ teco_lsp_shutdown(GError **error) static const gchar req[] = "{" "\"jsonrpc\":\"2.0\"," - "\"id\":1," + "\"id\":" TECO_LSP_ID "," "\"method\":\"shutdown\"," "\"params\":null" "}"; |
