lua-language-server
lua-language-server copied to clipboard
Support enums with runtime values
I have written an LuaDoc api documentation file for a library of mine, and I currently cannot abstract away the values of an enum that makes use of the ---@enum annotation. I've tried forcing the enum values to not be known before runtime, but it seems the annotation does not support such a case.
We can see that intellisense is happy to suggest each enum variation for when the enum values are known before runtime:

However, if we provide the enum values as some runtime value, it does not suggest anything:

Ideally, it would still suggest enum.A, enum.B, and enum.C.
An alternative solution may be to support an enum defined fully via LuaDoc as such:
---@enum TestEnum
---@field A number
---@field B number
local enum = {}