diff --git a/src/main.lua b/src/main.lua index e196d4e..5b888b0 100644 --- a/src/main.lua +++ b/src/main.lua @@ -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)