lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Support enums with runtime values

Open Feez opened this issue 3 years ago • 0 comments

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: image

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

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 = {}

Feez avatar Jul 30 '22 19:07 Feez