summaryrefslogtreecommitdiff
path: root/lsp.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-29 18:44:37 -0500
committerpommicket <pommicket@gmail.com>2022-12-29 18:44:37 -0500
commitd77782564bf0a090a4e7fa4f4c4bb685383275dc (patch)
treea4bc3c0bf142c663ea7f293b4381927adc896f1c /lsp.c
parent5f7af06a9085835a3d1ad3a51374c245859d7d97 (diff)
textDocument/definition for ctrl+click
Diffstat (limited to 'lsp.c')
-rw-r--r--lsp.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/lsp.c b/lsp.c
index 50947ce..830f90d 100644
--- a/lsp.c
+++ b/lsp.c
@@ -3,8 +3,6 @@
// print client-to-server communication
#define LSP_SHOW_C2S 0
-#define write_bool lsp_write_bool
-
static void lsp_request_free(LSPRequest *r);
static void lsp_response_free(LSPResponse *r);
@@ -13,6 +11,7 @@ static void lsp_response_free(LSPResponse *r);
strbuf_printf(lsp->error, __VA_ARGS__);\
SDL_UnlockMutex(lsp->error_mutex);\
} while (0)
+#include "lsp-json.c"
#include "lsp-write.c"
#include "lsp-parse.c"
@@ -44,6 +43,7 @@ static void lsp_request_free(LSPRequest *r) {
case LSP_REQUEST_COMPLETION:
case LSP_REQUEST_SIGNATURE_HELP:
case LSP_REQUEST_HOVER:
+ case LSP_REQUEST_DEFINITION:
case LSP_REQUEST_DID_CLOSE:
case LSP_REQUEST_WORKSPACE_FOLDERS:
case LSP_REQUEST_JDTLS_CONFIGURATION:
@@ -80,6 +80,9 @@ static void lsp_response_free(LSPResponse *r) {
case LSP_REQUEST_SIGNATURE_HELP:
arr_free(r->data.signature_help.signatures);
break;
+ case LSP_REQUEST_DEFINITION:
+ arr_free(r->data.definition.locations);
+ break;
default:
break;
}
@@ -145,6 +148,8 @@ static bool lsp_supports_request(LSP *lsp, const LSPRequest *request) {
return cap->workspace_folders_support;
case LSP_REQUEST_HOVER:
return cap->hover_support;
+ case LSP_REQUEST_DEFINITION:
+ return cap->definition_support;
}
assert(0);
return false;
@@ -542,4 +547,18 @@ bool lsp_document_position_eq(LSPDocumentPosition a, LSPDocumentPosition b) {
return a.document == b.document && lsp_position_eq(a.pos, b.pos);
}
-#undef write_bool
+
+LSPDocumentPosition lsp_location_start_position(LSPLocation location) {
+ return (LSPDocumentPosition) {
+ .document = location.document,
+ .pos = location.range.start
+ };
+}
+
+LSPDocumentPosition lsp_location_end_position(LSPLocation location) {
+ return (LSPDocumentPosition) {
+ .document = location.document,
+ .pos = location.range.end
+ };
+}
+