summaryrefslogtreecommitdiffstatshomepage
path: root/plugins
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2016-11-05 18:32:03 -0500
committer cracyc <cracyc@users.noreply.github.com>2016-11-06 13:41:45 -0600
commitfad9a96cb0c49d693ab59504091cb9c522910f1a (patch)
tree862e4e0d698f18e0bf7fec8d725eb70c59f919ee /plugins
parent2de04414ed0fdff027eb99c83faca2074a944bc6 (diff)
plugins/console: better completions (nw)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/console/init.lua19
1 files changed, 14 insertions, 5 deletions
diff --git a/plugins/console/init.lua b/plugins/console/init.lua
index fea0f930d42..b4f42acf48e 100644
--- a/plugins/console/init.lua
+++ b/plugins/console/init.lua
@@ -37,11 +37,12 @@ function console.startplugin()
return type(t) == 'table' or (mt and mt.__pairs)
end
local comps = ","
- local table, last = str:match("([(]?[%w.:()]-)[:.]?([%w]*)$")
- if last == "" then
- return comps
- end
+ local table = str:match("([(]?[%w.:()]-)[:.]?[%w_]*$")
+ local rest, last = str:match("(.-[:.]?)([%w_]*)$")
local err
+ if table == "" then
+ table = "_G"
+ end
err, tablef = pcall(load("return " .. table))
if (not err) or (not tablef) then
return comps
@@ -49,7 +50,15 @@ function console.startplugin()
if is_pair_iterable(tablef) then
for k, v in pairs(tablef) do
if k:match("^" .. last) then
- comps = comps .. "," .. table
+ comps = comps .. "," .. rest .. k
+ end
+ end
+ end
+ local tablef = getmetatable(tablef)
+ if is_pair_iterable(tablef) then
+ for k, v in pairs(tablef) do
+ if k:match("^" .. last) then
+ comps = comps .. "," .. rest .. k
end
end
end