From 4a4fa3992ea197e7e381019630454fafec1f78e9 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Tue, 17 Mar 2020 13:50:01 -0400 Subject: Show XPM images in Lua command entry completions. --- modules/textadept/command_entry.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'modules/textadept/command_entry.lua') 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 -- cgit v1.2.3