aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2020-03-17 13:50:01 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2020-03-17 13:50:01 -0400
commit4a4fa3992ea197e7e381019630454fafec1f78e9 (patch)
treeb325330f677e006e8a18355c7a316ade5e56f642 /modules
parent1899a12d9f22f46e69cb2d5fda8802d610359b7a (diff)
Show XPM images in Lua command entry completions.
Diffstat (limited to 'modules')
-rw-r--r--modules/textadept/command_entry.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index f69a5644..347f6ab0 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -104,21 +104,28 @@ local function complete_lua()
if (not ok or type(result) ~= 'table') and symbol ~= '' then return end
local cmpls = {}
part = '^' .. part
+ local sep = string.char(buffer.auto_c_type_separator)
+ local XPM = textadept.editing.XPM_IMAGES
if not ok or symbol == 'buffer' then
local sci = _SCINTILLA
local global_envs =
not ok and {buffer, view, ui, _G, sci.functions, sci.properties} or
op == ':' and {sci.functions} or {sci.properties, sci.constants}
- for i = 1, #global_envs do
- for k in pairs(global_envs[i]) do
- if type(k) == 'string' and k:find(part) then cmpls[#cmpls + 1] = k end
+ for _, env in ipairs(global_envs) do
+ for k, v in pairs(env) do
+ if type(k) == 'string' and k:find(part) then
+ local xpm = (type(v) == 'function' or env == sci.functions) and
+ XPM.METHOD or XPM.VARIABLE
+ cmpls[#cmpls + 1] = k .. sep .. xpm
+ end
end
end
else
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
+ local xpm = type(v) == 'function' and XPM.METHOD or XPM.VARIABLE
+ cmpls[#cmpls + 1] = k .. sep .. xpm
end
end
end