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

[Suggestion] Add ability to define an enum without using a table

Open mycroftjr opened this issue 1 year ago • 6 comments

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Annotations, Type Checking, Completion

Suggestion

For existing codebases where enums are defined like this:

OPERATING_SYSTEM_WINDOWS = 1
OPERATING_SYSTEM_MAC = 2
KEY_A = 1
KEY_B = 2

it would be nice to be able to define all lines that follow (until the next blank line) as part of an enum without changing anything by introducing a table: i.e.

@enum OPERATING_SYSTEM
OPERATING_SYSTEM_WINDOWS = 1
OPERATING_SYSTEM_MAC = 2

@enum KEY
KEY_A = 1
KEY_B = 2

This would be convenient for type annotating when the values are passed as parameters and what-not. I'm not able to find any existing ways to designate these values as a "group" (or union) that maintains their use as global constants.

mycroftjr avatar Jun 19 '24 23:06 mycroftjr