How to enable autocomplete for enums #2828
-
| I have a table of text lines that correspond to lines in various locale files. It's formatted like this ---@enum (key) textLine
return {
  genericOK = true,
  warning = true,
  ...
}These lines are filtered through a function ---@param locale table
---@param line textLine
---@param ... string
---@return string | table
local function processor (locale, line, ...)
...Is there a way to enable autocomplete for the  | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            tomlau10
          
      
      
        Aug 28, 2024 
      
    
    Replies: 1 comment
-
| seems  ---@enum (key) textLine
local t = {
  genericOK = true,
  warning = true,
  ...
}
return tNow  ---@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 | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
      Answer selected by
        BestMordaEver
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
seems
@enumcannot be used on a return expression 😕I tested and you have to use a local variable to do so (before returning it):
Now
textlinewill be equal to---@alias "genericOK"|"warning"and you can have suggestion for it