A script to generate LÖVE API autocomplete files for EmmyLua, based off of Emmy-love-api.
- Download this repository.
- Download the version of the LÖVE API that you want.
- Ensure that the
apifolder exists. If not, create it. - Copy both the LÖVE API's
modulesfolder and thelove_api.luafile into this repository's root directory. - Run
genEmmyAPI.luausing your computer's installation of Lua. Ex.lua genEmmyAPI.lua. - Copy the
apifolder into your project's source folder, the same folder wheremain.luais (you can rename it whatever you want, it doesn't have to be calledapi). - In your project, add the directory you just created into your
.emmyrc.json, in the array inworkspace->library.
Once you start or refresh your IDE (might be automatic) you should have autocomplete and quick documentation for LÖVE!
When you want to regenerate the autocomplete files, delete the contents of the api folder (not the folder itself!) and redo the steps.
-
Nothing included in this repository by default to avoid people using old versions of the LÖVE API
-
Optional arguments are now properly generated
- Marked as optional in the
---@paramdefines - Appends
(Defaults to <default>.)to the description - Marked as optional in overloads (although you can't add descriptions to them unfortunately)
- Overloads are now sorted, so the function signature should have the most arguments
- Marked as optional in the
-
Should now work with modern EmmyLua:
- Definition files now use
---@metarather than classes m.functionandreturn mwere removed, now relying on meta syntax- All files have a namespace definition for
love, meaning thatlove.Objectis the type, which will not conflict with your ownObjecttype - Enums are now
---@aliases rather than (unannotated) tables. Originally I just added---@enum, but you can't actually access those tables in LÖVE. - Region comments now have proper newlines around them
- Class definitions are now above the tables
- Definition files now use
-
Added console output
-
Styling changes
- Replaced generated tabs with spaces
- Indents should now be more consistent
- None of the generated files should have default warnings
-
Supertypes are now generated properly. For example, anything which takes
love.Drawablewill now acceptlove.Imagewithout a cast. -
Small organization changes
Original script by @tangzx
Modifications & original README by @kindfulkirby
Updated for modern EmmyLua by @NyakoFox