diff options
author | 2016-04-05 20:46:44 -0400 | |
---|---|---|
committer | 2016-04-05 20:46:44 -0400 | |
commit | 8eeef0af7f63b466c1ecb1cec0a7024bda5f5fae (patch) | |
tree | 9d613526d6b1888793f52e47b8cfe6d0ee56350d /modules/textadept | |
parent | 867e24ad43c2a253ba637da612f5edf7741b3ca6 (diff) | |
download | textadept-8eeef0af7f63b466c1ecb1cec0a7024bda5f5fae.tar.gz textadept-8eeef0af7f63b466c1ecb1cec0a7024bda5f5fae.zip |
Reworked Lua completions; modules/textadept/command_entry.lua
In addition to code cleanup, ':' limits results to functions.
Diffstat (limited to 'modules/textadept')
-rw-r--r-- | modules/textadept/command_entry.lua | 30 |
1 files changed, 15 insertions, 15 deletions
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 |