diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lsp.c | 21 |
1 files changed, 12 insertions, 9 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" "}"; @@ -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 } |
