fix: return full item set on ( trigger to survive auto-close

When LazyVim auto-close inserts () after (, nvim-cmp sees ) as the
last character and may suppress the popup. By returning variables,
builtins, and data types alongside the function params, the response
is rich enough that the next keystroke (e.g. typing I after auto-close)
triggers a fresh TextChanged completion that re-detects the call
context via get_call_context in the else branch.
This commit is contained in:
2026-07-22 15:30:30 +02:00
parent 2184007cf6
commit 8d5bf9f99f
+21 -7
View File
@@ -920,17 +920,31 @@ function handlers.textDocument_completion(params)
local params = call_name and resolve_call_params(call_name, doc.variables, doc.types) local params = call_name and resolve_call_params(call_name, doc.variables, doc.types)
if params then if params then
add_param_items(items, params, "") add_param_items(items, params, "")
elseif doc.functions then end
for _, func in ipairs(doc.functions) do
-- Also add variables and builtins so completion popup stays rich
-- even if auto-close ( or client-side filtering interferes
if doc.variables then
for name, info in pairs(doc.variables) do
table.insert(items, { table.insert(items, {
label = func.name, label = "#" .. name,
kind = 3, filterText = "#" .. name,
detail = func.kind:upper(), kind = 13,
insertText = func.name .. "()", detail = "Variable (" .. (info.type or "VAR") .. "): " .. (info.data_type or "unknown"),
insertTextFormat = 2, insertText = "#" .. name,
insertTextFormat = 1,
}) })
end end
end end
for type_name, _ in pairs(builtin.DATA_TYPES) do
table.insert(items, { label = type_name, kind = 7, detail = "Data type", insertText = type_name, insertTextFormat = 1 })
end
for fb_name, _ in pairs(builtin.FUNCTION_BLOCKS) do
table.insert(items, { label = fb_name, kind = 6, detail = "Function block", insertText = fb_name, insertTextFormat = 1 })
end
for func_name, _ in pairs(builtin.FUNCTIONS) do
table.insert(items, { label = func_name, kind = 3, detail = "Function", insertText = func_name, insertTextFormat = 1 })
end
else else
-- Check if we're inside a function call (e.g., after instTestTimer() -- Check if we're inside a function call (e.g., after instTestTimer()
local call_name = get_call_context(line, col) local call_name = get_call_context(line, col)