Replies: 2 comments
-
I don't really understand the question (what do you mean by "item" and "chosen"?) but I will try to explain how the completer system works. Note If you don't need custom completions you can just pass in one of the pre-defined completers: When the user types
If only a single If you want a complete example you can look at how some existing plugins do it. As a simple example my local subcommands = {
["branch"] = gh_branch,
["file"] = gh_file,
["issues"] = gh_issues,
["pr"] = gh_pr,
}
function init()
local gh_completer = function (buf)
local s = buf:Line(0):gsub("^gh ", "")
local completions = {}
local suggestions = {}
for subcomm, _ in pairs(subcommands) do
if string.find(subcomm, s, 1, true) == 1 then
table.insert(completions, subcomm:sub(#s + 1, #subcomm) .. " ")
table.insert(suggestions, subcomm)
end
end
return completions, suggestions
end
config.MakeCommand("gh", gh, gh_completer)
end |
Beta Was this translation helpful? Give feedback.
-
|
thank you for your response, I appreciate it. What I'm looking for is the completion not to be placed into the buffer, but rather returned to my LUA code so that I can act on it, e.g. it might show a set of options: [Option1] [Option2] [Option3] the user would choose one and then my code would get the chosen response. Maybe completion isn't the correct object for me to use for this purpose? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
testCompletion returns two tables of strings.
in testCommand, args is 'userdata' type. How do I determine which item from the testCompletion routine was chosen?
Beta Was this translation helpful? Give feedback.
All reactions