I'm excited to announce Playdate-LUACATS a complete set of types and comments for the PlaydateSDK. This is compatible with the Lua Language Server and VSCode Lua Extension (sumneko.lua) to support type checking, autocomplete and inline documentation in your IDE. LuaLSP supports VSCode, NeoVim and any editor with LSP support.
Looking for testers and feedback. I've been using it for a while privately and caught some subtle bugs. in my own projects. One note: you may need to restart VSCode after installing the Lua VSCode Extension and editing your settings to point to the playdate-luacats library.
This is excellent! I just added the extension and it's already been extremely helpful. It feels so nice to have proper completions on the API. Haven't run into any problems yet but I'll keep an eye out.
Thank you for creating and sharing this! Strong vote to include this in the SDK or at least in the extensions marketplace.
Yeah, I hadn't actually considered publishing my own extension. Conceivably I could publish an extension that requires sumneko.lua with an auto-updating bundle of types. Or maybe piggy back on Orta.playdate.
I'm a relative novice with respect to vscode extensions and have found sumneko.lua to pretty opaque. It's written entirely in Lua, has been localized into multiple languages (en, pt-br, zh-tw, zh-cn) and uses a bunch of lua scripts at build time to generate JSON for the build artifacts (e.g. instead of package.json there's a lua script which programmatically generates a nested table which is then serialized). And those lua build scripts are not cross platform (windows-targeted).
I'm open to any suggestion of how to distribute updates to users -- right now it's "do a git pull on your local clone periodically? Which is a terrible strategy. For reference, you can see a list of releases or even subscribe to the Atom XML Feed like it's 2005.
It's minimally documented but you can also disable rules for the current line, next line or entire file.
Just type ---@diagnostic in VSCode and the completions will guide you to:
---@diagnostic disable-next-line duplicate-set-field
function playdate.update() end
Potential fix:
Looks like Love2D declares their callback functions as aliases [link]:
---Callback function used to update the state of the game every frame.
---@alias love.update fun(dt: number)
Since there's a easy workaround, I'm not rushing to fix it or complain upstream. The workaround also encourages the creation of more modular code by hinting that callback can be altered at runtime so I'll take that as a win.
tldr: I've improved playdate-luacats types. git pull your local clone to get them.
I am excited to announce that I finally figured out how to do types for object.lua classes including extends(), super(), init() and the Object base class. You can see the changes here:
Also came up with a small workaround you may want to consider to explicitly show lua-language-server where a new class in the global namespace was created.