From ca6617873e15abce0641c426f56047202e68b457 Mon Sep 17 00:00:00 2001 From: pommicket Date: Thu, 29 Dec 2022 13:44:25 -0500 Subject: hover-enabled option --- README.md | 2 ++ config.c | 3 ++- hover.c | 4 +++- main.c | 1 - signature-help.c | 6 +++--- ted.cfg | 4 +++- ted.h | 3 ++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e90467b..b3ab8aa 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,8 @@ Press Ctrl+space to autocomplete. If there is only one possible completion from Otherwise, you'll get a popup showing all possible completions. You can press tab to select a completion (or click on it), and press Ctrl+space/Ctrl+shift+space to cycle between suggestions. +Hover over a variable or function and press Shift to see its type and documentation ("hover information"). + 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. diff --git a/config.c b/config.c index ecd1cb2..e4c0ac6 100644 --- a/config.c +++ b/config.c @@ -259,8 +259,9 @@ static OptionBool const options_bool[] = { {"indent-with-spaces", &options_zero.indent_with_spaces, true}, {"trigger-characters", &options_zero.trigger_characters, true}, {"identifier-trigger-characters", &options_zero.identifier_trigger_characters, true}, - {"signature-help", &options_zero.signature_help, true}, + {"signature-help-enabled", &options_zero.signature_help_enabled, true}, {"lsp-enabled", &options_zero.lsp_enabled, true}, + {"hover-enabled", &options_zero.hover_enabled, true}, }; static OptionU8 const options_u8[] = { {"tab-width", &options_zero.tab_width, 1, 100, true}, diff --git a/hover.c b/hover.c index e9f8e36..9742e58 100644 --- a/hover.c +++ b/hover.c @@ -76,6 +76,9 @@ void hover_process_lsp_response(Ted *ted, LSPResponse *response) { } void hover_frame(Ted *ted, double dt) { + const Settings *settings = ted_active_settings(ted); + if (!settings->hover_enabled) + return; Hover *hover = &ted->hover; bool shift_down = SDL_GetKeyboardState(NULL)[SDL_SCANCODE_LSHIFT] @@ -112,7 +115,6 @@ void hover_frame(Ted *ted, double dt) { - const Settings *settings = ted_active_settings(ted); const float padding = settings->padding; const float border = settings->border_thickness; const u32 *colors = settings->colors; diff --git a/main.c b/main.c index 9f0fef7..28c22ed 100644 --- a/main.c +++ b/main.c @@ -5,7 +5,6 @@ - find usages - refactoring? - test full unicode position handling -- hover-enabled, hover-time settings - check if there are any other non-optional/nice-to-have-support-for server-to-client requests - better non-error window/showMessage(Request) - document lsp.h and lsp.c. diff --git a/signature-help.c b/signature-help.c index 1db8104..97dc8c3 100644 --- a/signature-help.c +++ b/signature-help.c @@ -14,7 +14,7 @@ static void signature_help_clear(SignatureHelp *help) { void signature_help_send_request(Ted *ted) { SignatureHelp *help = &ted->signature_help; Settings *settings = ted_active_settings(ted); - if (!settings->signature_help) { + if (!settings->signature_help_enabled) { signature_help_clear(help); return; } @@ -57,7 +57,7 @@ void signature_help_close(Ted *ted) { void signature_help_process_lsp_response(Ted *ted, const LSPResponse *response) { Settings *settings = ted_active_settings(ted); - if (!settings->signature_help) return; + if (!settings->signature_help_enabled) return; if (response->request.type != LSP_REQUEST_SIGNATURE_HELP) return; @@ -95,7 +95,7 @@ void signature_help_process_lsp_response(Ted *ted, const LSPResponse *response) void signature_help_frame(Ted *ted) { Settings *settings = ted_active_settings(ted); - if (!settings->signature_help) + if (!settings->signature_help_enabled) return; SignatureHelp *help = &ted->signature_help; diff --git a/ted.cfg b/ted.cfg index 42a0d14..f81c079 100644 --- a/ted.cfg +++ b/ted.cfg @@ -38,7 +38,9 @@ identifier-trigger-characters = off lsp-enabled = yes # display function signature help? (only with LSP running) # this is the thing at the bottom of ted which shows the parameters to the function you're calling -signature-help = on +signature-help-enabled = yes +# display hover info when shift key is pressed? (only with LSP running) +hover-enabled = yes # maximum editable file size. # ted will set the buffer to view-only if a file larger than this is loaded. # NOTE: ted is not really meant for absolutely massive files. diff --git a/ted.h b/ted.h index f081c46..774b5f5 100644 --- a/ted.h +++ b/ted.h @@ -152,8 +152,9 @@ typedef struct { bool indent_with_spaces; bool trigger_characters; bool identifier_trigger_characters; - bool signature_help; + bool signature_help_enabled; bool lsp_enabled; + bool hover_enabled; u8 tab_width; u8 cursor_width; u8 undo_save_time; -- cgit v1.2.3