luttje / glua-api-snippets

Scrapes the Garry's Mod Wiki in order to build Lua Language Server comments that will provide IDE suggestions and autocompletion.
MIT License
15 stars 5 forks source link

Functions and variables that need to be hardcoded #9

Closed Vurv78 closed 1 year ago

Vurv78 commented 1 year ago

Also, vgui.Create could return the proper subtype based on the first parameter using generic captures, although this is likely LuaLS specific, so unsure of what you want to do with this:

---@generic T: Panel
---@param classname `T`
---@param parent Panel?
---@param name string?
---@return T
local function vgui_Create(classname, parent, name)
    return vgui.Create(classname, parent, name)
end

So calling vgui_Create("DLabel") would assign it the type DLabel which extends Panel.

luttje commented 1 year ago

Thanks so much for the detailed report, this will save me a ton of time.

Seeing how LuaLS seems the most maintained and extensive, I'll likely drop support for EmmyLua and use that Generic Capture annotation.

For this issue, along with #7 I will likely implement a file in root (e.g: _overloads.lua) that gets copied after getting the api from the wiki. It can contain all the fixes you mentioned.

For the Color() function to return a Color instead of a table, I would prefer the wiki to be corrected (though there does seem some inconsistency about Color tables so I'm not sure if that fix would be correct). But until that time we could keep our fixes in that proposed _overloads.lua.