From f897a6a62e9572f1f3cc6c7905192d49d7868c9a Mon Sep 17 00:00:00 2001 From: pommicket Date: Thu, 5 Jan 2023 11:34:11 -0500 Subject: lsp-reset command --- README.md | 3 +++ command.c | 10 ++++++++++ command.h | 1 + main.c | 1 - 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c2982d..e905510 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,9 @@ to navigate between them, just like build errors. If these features aren't working properly and you don't know why, try running ted in a terminal (non-Windows) or a debugger (Windows) so you can see the stderr output from the server. +If an LSP server crashes or is having difficulty, you can run the `lsp-reset` command (via the command palette) +to reset all running LSP servers. + You can integrate any LSP server with ted by setting the `lsp` option in the `[core.]` section of `ted.cfg` to the command which starts the server. Some defaults will already be there, and are listed below. Make sure you install the LSP(s) you want and put the executables in your PATH (or change the `lsp` variable diff --git a/command.c b/command.c index bf76b74..7e33229 100644 --- a/command.c +++ b/command.c @@ -71,6 +71,7 @@ static CommandName const command_names[] = { {"goto-definition-at-cursor", CMD_GOTO_DEFINITION_AT_CURSOR}, {"goto-declaration-at-cursor", CMD_GOTO_DECLARATION_AT_CURSOR}, {"goto-type-definition-at-cursor", CMD_GOTO_TYPE_DEFINITION_AT_CURSOR}, + {"lsp-reset", CMD_LSP_RESET}, {"find", CMD_FIND}, {"find-replace", CMD_FIND_REPLACE}, {"tab-close", CMD_TAB_CLOSE}, @@ -427,6 +428,15 @@ void command_execute(Ted *ted, Command c, i64 argument) { buffer_goto_word_at_cursor(buffer, GOTO_TYPE_DEFINITION); } } break; + case CMD_LSP_RESET: + for (int i = 0; i < TED_LSP_MAX; ++i) { + LSP *lsp = ted->lsps[i]; + if (lsp) { + lsp_free(lsp); + ted->lsps[i] = NULL; + } + } + break; case CMD_FIND_USAGES: usages_find(ted); break; diff --git a/command.h b/command.h index c29f01d..3d1b98d 100644 --- a/command.h +++ b/command.h @@ -77,6 +77,7 @@ typedef enum { CMD_GOTO_DEFINITION_AT_CURSOR, CMD_GOTO_DECLARATION_AT_CURSOR, CMD_GOTO_TYPE_DEFINITION_AT_CURSOR, + CMD_LSP_RESET, CMD_COPY, CMD_CUT, diff --git a/main.c b/main.c index 033eddd..e99f12f 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,5 @@ /* @TODO: -- :lsp-reset command - can we display publishDiagnostics notifications from rust-analyzer (& others)? - phantom completions - debug-lsp option (which logs LSP messages) -- cgit v1.2.3