lua-language-server
lua-language-server copied to clipboard
Feature Request: Annotation to hide fields/types
Currently, if I create a class definition such as
---@class Setting
---@field __isInitialized boolean @Is the setting data properly initialized
---@field value number|boolean|string @Value for the setting
---@field description string @Setting description
I get all the fields (as one would expect).
However, convention indicates the __ field should be private. I can remove the a field definition, but that removes it from the annotations inside the module it's declared in as well.
There's at least one variant of Emmylua (for IntelliJ IDEA) that supports specifying if the field is public|private|protected (https://emmylua.github.io/annotations/field.html). I believe the intent here is to handle this very case of marking a field as internal to the module, without exposing it to external users. Ideally something similar can be defined for actual fields (e.g., __version = "1.0") intended for private usage.
One workaround I can think of is to use inherited types (e.g, Settings and SettingsWithPrivates), but this clutters the namespace unnecessarily. Of course, actual fields can be declared local, but I'm hoping there's a clean mechanism that works for both.