diff options
Diffstat (limited to 'src')
| -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" "}"; |
