Skip to content

How to enable autocomplete for enums #2828

Closed Answered by tomlau10
BestMordaEver asked this question in Q&A
Discussion options

You must be logged in to vote

seems @enum cannot be used on a return expression 😕
I tested and you have to use a local variable to do so (before returning it):

---@enum (key) textLine
local t = {
  genericOK = true,
  warning = true,
  ...
}
return t

Now textline will be equal to ---@alias "genericOK"|"warning"
and you can have suggestion for it

---@param locale table
---@param line textLine
---@param ... string
---@return string | table
local function processor (locale, line, ...)
    if line == --< here will suggest "genericOK" and "warning"
end

processor({}, --< here will suggest the enum keys as well

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BestMordaEver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants