Optimize Lua complete

pull/1224/head
Zef Hemel 2025-01-26 09:00:10 +01:00
parent 71a414d1d4
commit 9f47c3df30
1 changed files with 33 additions and 31 deletions

View File

@ -68,46 +68,47 @@ event.listen {
failed = true
end
end
if failed then
return
end
local last_prop = prop_parts[#prop_parts]
if table.includes(LUA_KEYWORDS, last_prop) then
return
end
if not failed then
local options = {}
for key, val in pairs(current_value) do
if string.startswith(key, last_prop) and val then
if val.call then
-- We got a function
if val.body then
-- Function defined in Lua
table.insert(options, {
label = key .. "(" .. table.concat(val.body.parameters, ", ") ..")",
apply = key .. "(",
detail = "Lua function"
})
else
-- Builtin
table.insert(options, {
label = key .. "()",
apply = key .. "(",
detail = "Lua built-in"
})
end
else
-- Table
local options = {}
for key, val in pairs(current_value) do
if string.startswith(key, last_prop) and val then
if val.call then
-- We got a function
if val.body then
-- Function defined in Lua
table.insert(options, {
label = key,
detail = "Lua table"
label = key .. "(" .. table.concat(val.body.parameters, ", ") ..")",
apply = key .. "(",
detail = "Lua function"
})
else
-- Builtin
table.insert(options, {
label = key .. "()",
apply = key .. "(",
detail = "Lua built-in"
})
end
else
-- Table
table.insert(options, {
label = key,
detail = "Lua table"
})
end
end
if #options > 0 then
return {
from = pos - string.len(last_prop),
options = options
}
end
end
if #options > 0 then
return {
from = pos - string.len(last_prop),
options = options
}
end
end
}
@ -139,6 +140,7 @@ template.define_slash_command {
template = template.new 'query[[from index.tag "|^|"]]'
}
-- A query embedded in ${}
template.define_slash_command {
name = "query",