aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-08-11 22:03:16 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-08-11 22:15:21 +0200
commit259678833ad563f43d789c33e5304b2b7c6853cb (patch)
treeb1f3dd16c06ff2633aa93db70812c56e4b002b69
parent9b904f5b7e9ea45b8ea5991f6eeb19c2f3949874 (diff)
LSP: ignore not only server notifications but all requests as wellmaster-fmsbw-ci
* 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.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/lsp.c b/src/lsp.c
index bc594df..72ce4d3 100644
--- a/src/lsp.c
+++ b/src/lsp.c
@@ -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"
"}";
@@ -1295,11 +1298,11 @@ teco_state_lsp_lookup_done(teco_machine_main_t *ctx, teco_string_t str, GError *
if (!teco_lsp.current) {
/* mimics an unsuccessful search */
- teco_interface_msg(TECO_MSG_ERROR, "No tags found");
+ teco_interface_msg(TECO_MSG_ERROR, "Nothing found");
return &teco_state_start;
#if 0
g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED,
- "No tags found");
+ "Nothing found");
return NULL;
#endif
}