diff options
author | pommicket <pommicket@gmail.com> | 2022-12-28 12:25:18 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-28 12:25:18 -0500 |
commit | d6b2cc80723ce6e8454449bcdcdcb495f7a08ad9 (patch) | |
tree | 0c51db5f1b26b2634ef3d3e6fd7916b612d748e8 /signature-help.c | |
parent | 92e8db6a364b8d1c38f3c15b8e040f6fb7c564f0 (diff) |
refresh signature help when cursor moved or buffer switched
Diffstat (limited to 'signature-help.c')
-rw-r--r-- | signature-help.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/signature-help.c b/signature-help.c index 4b7e847..27f9203 100644 --- a/signature-help.c +++ b/signature-help.c @@ -1,14 +1,26 @@ // deals with textDocument/signatureHelp LSP requests -void signature_help_open(Ted *ted, char32_t trigger) { - (void)trigger; // for now we don't send context +void signature_help_send_request(Ted *ted) { TextBuffer *buffer = ted->active_buffer; if (!buffer) return; LSP *lsp = buffer_lsp(buffer); + if (!lsp) return; LSPRequest request = {.type = LSP_REQUEST_SIGNATURE_HELP}; LSPRequestSignatureHelp *s = &request.data.signature_help; s->position = buffer_cursor_pos_as_lsp_document_position(buffer); lsp_send_request(lsp, &request); + ted->signature_help.retrigger = false; +} + +void signature_help_retrigger(Ted *ted) { + // don't just send the request here -- we don't want to send more than + // one request per frame. + ted->signature_help.retrigger = true; +} + +void signature_help_open(Ted *ted, char32_t trigger) { + (void)trigger; // for now we don't send context + signature_help_send_request(ted); } bool signature_help_is_open(Ted *ted) { @@ -66,6 +78,8 @@ void signature_help_process_lsp_response(Ted *ted, const LSPResponse *response) void signature_help_frame(Ted *ted) { SignatureHelp *help = &ted->signature_help; + if (help->retrigger) + signature_help_send_request(ted); u16 signature_count = help->signature_count; if (!signature_count) return; @@ -74,6 +88,7 @@ void signature_help_frame(Ted *ted) { TextBuffer *buffer = ted->active_buffer; if (!buffer) return; + Settings *settings = buffer_settings(buffer); u32 *colors = settings->colors; float border = settings->border_thickness; |