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:
+21
-7
@@ -920,17 +920,31 @@ function handlers.textDocument_completion(params)
|
||||
local params = call_name and resolve_call_params(call_name, doc.variables, doc.types)
|
||||
if params then
|
||||
add_param_items(items, params, "")
|
||||
elseif doc.functions then
|
||||
for _, func in ipairs(doc.functions) do
|
||||
end
|
||||
|
||||
-- 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, {
|
||||
label = func.name,
|
||||
kind = 3,
|
||||
detail = func.kind:upper(),
|
||||
insertText = func.name .. "()",
|
||||
insertTextFormat = 2,
|
||||
label = "#" .. name,
|
||||
filterText = "#" .. name,
|
||||
kind = 13,
|
||||
detail = "Variable (" .. (info.type or "VAR") .. "): " .. (info.data_type or "unknown"),
|
||||
insertText = "#" .. name,
|
||||
insertTextFormat = 1,
|
||||
})
|
||||
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
|
||||
-- Check if we're inside a function call (e.g., after instTestTimer()
|
||||
local call_name = get_call_context(line, col)
|
||||
|
||||
Reference in New Issue
Block a user