From 8eeef0af7f63b466c1ecb1cec0a7024bda5f5fae Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Tue, 5 Apr 2016 20:46:44 -0400 Subject: Reworked Lua completions; modules/textadept/command_entry.lua In addition to code cleanup, ':' limits results to functions. --- modules/textadept/command_entry.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'modules') diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua index 325db3cb..fb8726cd 100644 --- a/modules/textadept/command_entry.lua +++ b/modules/textadept/command_entry.lua @@ -146,26 +146,26 @@ local function complete_lua() if (not ok or type(result) ~= 'table') and symbol ~= '' then return end local cmpls = {} part = '^'..part - if not ok then -- shorthand notation - local pool = { - buffer, view, ui, _G, _SCINTILLA.functions, _SCINTILLA.properties - } + if not ok or symbol == 'buffer' then + local pool + if not ok then + -- Consider `buffer`, `view`, `ui` as globals too. + pool = {buffer, view, ui, _G, _SCINTILLA.functions, _SCINTILLA.properties} + else + pool = op == ':' and {_SCINTILLA.functions} or + {_SCINTILLA.properties, _SCINTILLA.constants} + end for i = 1, #pool do for k in pairs(pool[i]) do if type(k) == 'string' and k:find(part) then cmpls[#cmpls + 1] = k end end end - else - for k in pairs(result) do - if type(k) == 'string' and k:find(part) then cmpls[#cmpls + 1] = k end - end - if symbol == 'buffer' and op == ':' then - for f in pairs(_SCINTILLA.functions) do - if f:find(part) then cmpls[#cmpls + 1] = f end - end - elseif symbol == 'buffer' and op == '.' then - for _, t in ipairs{_SCINTILLA.properties, _SCINTILLA.constants} do - for p in pairs(t) do if p:find(part) then cmpls[#cmpls + 1] = p end end + end + if ok then + for k, v in pairs(result) do + if type(k) == 'string' and k:find(part) and + (op == '.' or type(v) == 'function') then + cmpls[#cmpls + 1] = k end end end -- cgit v1.2.3