diff options
author | pommicket <pommicket@gmail.com> | 2023-01-03 17:29:19 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-01-03 17:29:19 -0500 |
commit | 87c8bd6eb27edb4bfc539967235c3a1e2f8d77e4 (patch) | |
tree | 4dbcb24ce4fca226e5b70bc5f01d71158d891426 /ide-definitions.c | |
parent | 0d92c03f3998fe4d16f3ba928d3a94583755e1ce (diff) |
go to declaration
Diffstat (limited to 'ide-definitions.c')
-rw-r--r-- | ide-definitions.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/ide-definitions.c b/ide-definitions.c index 0152376..7873630 100644 --- a/ide-definitions.c +++ b/ide-definitions.c @@ -51,13 +51,22 @@ static SymbolKind symbol_kind_to_ted(LSPSymbolKind kind) { return SYMBOL_OTHER; } -void definition_goto(Ted *ted, LSP *lsp, const char *name, LSPDocumentPosition position) { +void definition_goto(Ted *ted, LSP *lsp, const char *name, LSPDocumentPosition position, GotoType type) { Definitions *defs = &ted->definitions; if (lsp) { // cancel old request ted_cancel_lsp_request(ted, defs->last_request_lsp, defs->last_request_id); + LSPRequestType request_type = LSP_REQUEST_DEFINITION; + switch (type) { + case GOTO_DEFINITION: + request_type = LSP_REQUEST_DEFINITION; + break; + case GOTO_DECLARATION: + request_type = LSP_REQUEST_DECLARATION; + break; + } // send that request - LSPRequest request = {.type = LSP_REQUEST_DEFINITION}; + LSPRequest request = {.type = request_type}; request.data.definition.position = position; LSPRequestID id = lsp_send_request(lsp, &request); defs->last_request_id = id; @@ -132,8 +141,9 @@ void definitions_process_lsp_response(Ted *ted, LSP *lsp, const LSPResponse *res defs->last_request_id = 0; switch (response->request.type) { - case LSP_REQUEST_DEFINITION: { - // handle textDocument/definition response + case LSP_REQUEST_DEFINITION: + case LSP_REQUEST_DECLARATION: { + // handle textDocument/definition or textDocument/declaration response const LSPResponseDefinition *response_def = &response->data.definition; if (!arr_len(response_def->locations)) { |