From e7e539f20c50bd276d63a1c279e2bc8706df8a5c Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 19 Aug 2026 01:53:55 +0200 Subject: LSP: auto-complete symbols via the textDocument/completion request This currently only works in insert commands after enabling the immediate editing modifier via CTRL+G and if the LSP was already launched (e.g. by an explicit `FT$`). File name completions are still performed with an activated ^G modifier only if the LSP is shut down. Just like for file names, the modifier is automatically cancelled after a successful completion - there is little sense in completing several symbols in a row. --- src/cmdline.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/cmdline.c') diff --git a/src/cmdline.c b/src/cmdline.c index a4e2189..1abf8df 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -911,8 +911,28 @@ teco_state_insert_process_edit_cmd(teco_machine_main_t *ctx, teco_machine_t *par return stringbuilding_current->process_edit_cmd_cb(&stringbuilding_ctx->parent, &ctx->parent, key, error); switch (key) { - case '\t': { /* insert indention */ + case '\t': { /* insert indention or auto complete */ + if (teco_cmdline.modifier_enabled && !teco_qreg_current && teco_lsp_is_running()) { + if (teco_interface_popup_is_shown()) { + /* cycle through popup pages */ + teco_interface_popup_scroll(); + return TRUE; + } + + g_auto(teco_string_t) new_chars, new_chars_escaped; + gboolean unambiguous = teco_lsp_buffer_auto_complete(teco_ring_current, &new_chars); + teco_machine_stringbuilding_escape(stringbuilding_ctx, new_chars.data, + new_chars.len, &new_chars_escaped); + if (unambiguous) { + teco_string_append_c(&new_chars_escaped, ' '); + teco_cmdline_modifier_set(FALSE); + } + + return teco_cmdline_insert(new_chars_escaped.data, new_chars_escaped.len, error); + } + if (teco_cmdline.modifier_enabled || teco_interface_ssm(SCI_GETUSETABS, 0, 0)) + /* perhaps auto-complete file name */ break; teco_interface_popup_clear(); -- cgit v1.2.3