aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cmdline.c
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-08-19 01:53:55 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-10-04 23:07:47 +0200
commite7e539f20c50bd276d63a1c279e2bc8706df8a5c (patch)
tree10496f7efbaf97309e045cf3c639b8d4dab5428e /src/cmdline.c
parentbfafc42fc3e6ae33eec68f0eae07739df6ae5c2b (diff)
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.
Diffstat (limited to 'src/cmdline.c')
-rw-r--r--src/cmdline.c22
1 files changed, 21 insertions, 1 deletions
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 <TAB> indention */
+ case '\t': { /* insert <TAB> 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();