diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..62e67163 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lua-language-server \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..ceaaeca6 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# LÖVE Definitions + +Definitions for the LÖVE 2D game framework, generated from +[love-api](https://github.com/love2d-community/love-api) using +[LLSs meta build script](https://github.com/LuaLS/lua-language-server/blob/master/tools/build-3rd-meta.lua) + +## Usage + +Run [`update.sh`](update.sh) to update, commit, and push changes. diff --git a/library/love/audio.lua b/library/love/audio.lua index 1978e63e..13a08f02 100644 --- a/library/love/audio.lua +++ b/library/love/audio.lua @@ -15,7 +15,7 @@ love.audio = {} --- ---[Open in Browser](https://love2d.org/wiki/love.audio.getActiveEffects) --- ----@return table effects # The list of the names of the currently enabled effects. +---@return string[] effects # The list of the names of the currently enabled effects. function love.audio.getActiveEffects() end --- @@ -79,12 +79,12 @@ function love.audio.getMaxSourceEffects() end --- ---[Open in Browser](https://love2d.org/wiki/love.audio.getOrientation) --- ----@return number fx # Forward vector of the listener orientation. ----@return number fy # Forward vector of the listener orientation. ----@return number fz # Forward vector of the listener orientation. ----@return number ux # Up vector of the listener orientation. ----@return number uy # Up vector of the listener orientation. ----@return number uz # Up vector of the listener orientation. +---@return number fx # Forward x of the listener orientation. +---@return number fy # Forward y of the listener orientation. +---@return number fz # Forward z of the listener orientation. +---@return number ux # Up x of the listener orientation. +---@return number uy # Up y of the listener orientation. +---@return number uz # Up z of the listener orientation. function love.audio.getOrientation() end --- @@ -108,7 +108,7 @@ function love.audio.getPosition() end --- ---[Open in Browser](https://love2d.org/wiki/love.audio.getRecordingDevices) --- ----@return table devices # The list of connected recording devices. +---@return love.RecordingDevice[] devices # The list of connected recording devices. function love.audio.getRecordingDevices() end --- @@ -178,7 +178,7 @@ function love.audio.newSource(filename, type) end --- ---@overload fun(source: love.Source, ...) ---@overload fun(sources: table) ----@return table Sources # A table containing a list of Sources that were paused by this call. +---@return love.Source[] Sources # A table containing a list of Sources that were paused by this call. function love.audio.pause() end --- @@ -416,7 +416,7 @@ function Source:clone() end --- ---[Open in Browser](https://love2d.org/wiki/Source:getActiveEffects) --- ----@return table effects # A list of the source's active effect names. +---@return string[] effects # A list of the source's active effect names. function Source:getActiveEffects() end --- diff --git a/library/love/filesystem.lua b/library/love/filesystem.lua index 945352df..94bfd488 100644 --- a/library/love/filesystem.lua +++ b/library/love/filesystem.lua @@ -76,7 +76,7 @@ function love.filesystem.getCRequirePath() end --- ---@overload fun(dir: string, callback: function):table ---@param dir string # The directory. ----@return table files # A sequence with the names of all files and subdirectories as strings. +---@return string[] files # A sequence with the names of all files and subdirectories as strings. function love.filesystem.getDirectoryItems(dir) end --- diff --git a/library/love/graphics.lua b/library/love/graphics.lua index e428b96c..3ac2545d 100644 --- a/library/love/graphics.lua +++ b/library/love/graphics.lua @@ -945,14 +945,12 @@ function love.graphics.present() end --- ---[Open in Browser](https://love2d.org/wiki/love.graphics.print) --- ----@overload fun(text: string, transform: love.Transform) ----@overload fun(text: string, font: love.Font, transform: love.Transform) ----@overload fun(text: number, transform: love.Transform) ----@overload fun(test: number, font: love.Font, transform: love.Transform) ---@overload fun(coloredtext: table, x?: number, y?: number, angle?: number, sx?: number, sy?: number, ox?: number, oy?: number, kx?: number, ky?: number) +---@overload fun(text: string, transform: love.Transform) ---@overload fun(coloredtext: table, transform: love.Transform) +---@overload fun(text: string, font: love.Font, transform: love.Transform) ---@overload fun(coloredtext: table, font: love.Font, transform: love.Transform) ----@param text string|number # The text to draw. +---@param text string # The text to draw. ---@param x? number # The position to draw the object (x-axis). ---@param y? number # The position to draw the object (y-axis). ---@param r? number # Orientation (radians). @@ -981,14 +979,11 @@ function love.graphics.print(text, x, y, r, sx, sy, ox, oy, kx, ky) end ---@overload fun(text: string, font: love.Font, x: number, y: number, limit: number, align?: love.AlignMode, r?: number, sx?: number, sy?: number, ox?: number, oy?: number, kx?: number, ky?: number) ---@overload fun(text: string, transform: love.Transform, limit: number, align?: love.AlignMode) ---@overload fun(text: string, font: love.Font, transform: love.Transform, limit: number, align?: love.AlignMode) ----@overload fun(text: number, font: love.Font, x: number, y: number, limit: number, align?: love.AlignMode, r?: number, sx?: number, sy?: number, ox?: number, oy?: number, kx?: number, ky?: number) ----@overload fun(text: number, transform: love.Transform, limit: number, align?: love.AlignMode) ----@overload fun(text: number, font: love.Font, transform: love.Transform, limit: number, align?: love.AlignMode) ---@overload fun(coloredtext: table, x: number, y: number, limit: number, align: love.AlignMode, angle?: number, sx?: number, sy?: number, ox?: number, oy?: number, kx?: number, ky?: number) ---@overload fun(coloredtext: table, font: love.Font, x: number, y: number, limit: number, align?: love.AlignMode, angle?: number, sx?: number, sy?: number, ox?: number, oy?: number, kx?: number, ky?: number) ---@overload fun(coloredtext: table, transform: love.Transform, limit: number, align?: love.AlignMode) ---@overload fun(coloredtext: table, font: love.Font, transform: love.Transform, limit: number, align?: love.AlignMode) ----@param text string|number # A text string. +---@param text string # A text string. ---@param x number # The position on the x-axis. ---@param y number # The position on the y-axis. ---@param limit number # Wrap the line after this many horizontal pixels. @@ -1443,7 +1438,8 @@ function Canvas:newImageData() end ---[Open in Browser](https://love2d.org/wiki/Canvas:renderTo) --- ---@param func function # A function performing drawing operations. -function Canvas:renderTo(func) end +---@vararg any # Additional arguments to call the function with. +function Canvas:renderTo(func, ...) end --- ---Superclass for all things that can be drawn on screen. This is an abstract type that can't be created directly. @@ -1562,7 +1558,7 @@ function Font:getLineHeight() end --- ---[Open in Browser](https://love2d.org/wiki/Font:getWidth) --- ----@param text string|number # A string or number. +---@param text string # A string. ---@return number width # The width of the text. function Font:getWidth(text) end @@ -1577,7 +1573,7 @@ function Font:getWidth(text) end ---@param text string # The text that will be wrapped. ---@param wraplimit number # The maximum width in pixels of each line that ''text'' is allowed before wrapping. ---@return number width # The maximum width of the wrapped text. ----@return table wrappedtext # A sequence containing each line of text that was wrapped. +---@return string[] wrappedtext # A sequence containing each line of text that was wrapped. function Font:getWrap(text, wraplimit) end --- @@ -1792,7 +1788,7 @@ function Mesh:getVertexFormat() end --- ---[Open in Browser](https://love2d.org/wiki/Mesh:getVertexMap) --- ----@return table map # A table containing the list of vertex indices used when drawing. +---@return number[] map # A table containing the list of vertex indices used when drawing. function Mesh:getVertexMap() end --- @@ -2082,7 +2078,7 @@ function ParticleSystem:getPosition() end --- ---[Open in Browser](https://love2d.org/wiki/ParticleSystem:getQuads) --- ----@return table quads # A table containing the Quads used. +---@return love.Quad[] quads # A table containing the Quads used. function ParticleSystem:getQuads() end --- @@ -2264,20 +2260,13 @@ function ParticleSystem:setBufferSize(size) end --- ---[Open in Browser](https://love2d.org/wiki/ParticleSystem:setColors) --- ----@overload fun(self: love.ParticleSystem, rgba1: table, rgba2: table, rgba8: table) +---@overload fun(self: love.ParticleSystem, rgba1: table, ...) ---@param r1 number # First color, red component (0-1). ---@param g1 number # First color, green component (0-1). ---@param b1 number # First color, blue component (0-1). ---@param a1? number # First color, alpha component (0-1). ----@param r2? number # Second color, red component (0-1). ----@param g2? number # Second color, green component (0-1). ----@param b2? number # Second color, blue component (0-1). ----@param a2? number # Second color, alpha component (0-1). ----@param r8? number # Eighth color, red component (0-1). ----@param g8? number # Eighth color, green component (0-1). ----@param b8? number # Eighth color, blue component (0-1). ----@param a8? number # Eighth color, alpha component (0-1). -function ParticleSystem:setColors(r1, g1, b1, a1, r2, g2, b2, a2, r8, g8, b8, a8) end +---@vararg number # Additional colors. +function ParticleSystem:setColors(r1, g1, b1, a1, ...) end --- ---Sets the direction the particles will be emitted in. @@ -2392,8 +2381,8 @@ function ParticleSystem:setPosition(x, y) end --- ---@overload fun(self: love.ParticleSystem, quads: table) ---@param quad1 love.Quad # The first Quad to use. ----@param quad2 love.Quad # The second Quad to use. -function ParticleSystem:setQuads(quad1, quad2) end +---@vararg love.Quad # Additional Quads to use. +function ParticleSystem:setQuads(quad1, ...) end --- ---Set the radial acceleration (away from the emitter). @@ -2571,8 +2560,8 @@ function Quad:getViewport() end ---@param y number # The top-left corner along the y-axis. ---@param w number # The width of the viewport. ---@param h number # The height of the viewport. ----@param sw number # The reference width, the width of the Image. (Must be greater than 0.) ----@param sh number # The reference height, the height of the Image. (Must be greater than 0.) +---@param sw? number # Optional new reference width, the width of the Texture. Must be greater than 0 if set. +---@param sh? number # Optional new reference height, the height of the Texture. Must be greater than 0 if set. function Quad:setViewport(x, y, w, h, sw, sh) end --- @@ -2663,8 +2652,8 @@ function Shader:send(name, number, ...) end ---[Open in Browser](https://love2d.org/wiki/Shader:sendColor) --- ---@param name string # The name of the color extern variable to send to in the shader. ----@param color table # A table with red, green, blue, and optional alpha color components in the range of 1 to send to the extern as a vector. ----@vararg table # Additional colors to send in case the extern is an array. All colors need to be of the same size (e.g. only vec3's). +---@param color number[] # A table with red, green, blue, and optional alpha color components in the range of 1 to send to the extern as a vector. +---@vararg number[] # Additional colors to send in case the extern is an array. All colors need to be of the same size (e.g. only vec3's). function Shader:sendColor(name, color, ...) end --- diff --git a/library/love/joystick.lua b/library/love/joystick.lua index 039674f1..9bdd8a97 100644 --- a/library/love/joystick.lua +++ b/library/love/joystick.lua @@ -36,7 +36,7 @@ function love.joystick.getJoystickCount() end --- ---[Open in Browser](https://love2d.org/wiki/love.joystick.getJoysticks) --- ----@return table joysticks # The list of currently connected Joysticks. +---@return love.Joystick[] joysticks # The list of currently connected Joysticks. function love.joystick.getJoysticks() end --- diff --git a/library/love/math.lua b/library/love/math.lua index 48a444e7..8fd90c98 100644 --- a/library/love/math.lua +++ b/library/love/math.lua @@ -92,8 +92,8 @@ function love.math.getRandomState() end --- ---[Open in Browser](https://love2d.org/wiki/love.math.isConvex) --- ----@overload fun(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number):boolean ----@param vertices table # The vertices of the polygon as a table in the form of {x1, y1, x2, y2, x3, y3, ...}. +---@overload fun(x1: number, y1: number, x2: number, y2: number, ...):boolean +---@param vertices number[] # The vertices of the polygon as a table in the form of {x1, y1, x2, y2, x3, y3, ...}. ---@return boolean convex # Whether the given polygon is convex. function love.math.isConvex(vertices) end @@ -127,8 +127,8 @@ function love.math.linearToGamma(lr, lg, lb) end --- ---[Open in Browser](https://love2d.org/wiki/love.math.newBezierCurve) --- ----@overload fun(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number):love.BezierCurve ----@param vertices table # The vertices of the control polygon as a table in the form of {x1, y1, x2, y2, x3, y3, ...}. +---@overload fun(x1: number, y1: number, x2: number, y2: number, ...):love.BezierCurve +---@param vertices number[] # The vertices of the control polygon as a table in the form of {x1, y1, x2, y2, x3, y3, ...}. ---@return love.BezierCurve curve # A Bézier curve object. function love.math.newBezierCurve(vertices) end @@ -330,7 +330,7 @@ function BezierCurve:removeControlPoint(index) end ---[Open in Browser](https://love2d.org/wiki/BezierCurve:render) --- ---@param depth? number # Number of recursive subdivision steps. ----@return table coordinates # List of x,y-coordinate pairs of points on the curve. +---@return number[] coordinates # List of x,y-coordinate pairs of points on the curve. function BezierCurve:render(depth) end --- @@ -346,7 +346,7 @@ function BezierCurve:render(depth) end ---@param startpoint number # The starting point along the curve. Must be between 0 and 1. ---@param endpoint number # The end of the segment to render. Must be between 0 and 1. ---@param depth? number # Number of recursive subdivision steps. ----@return table coordinates # List of x,y-coordinate pairs of points on the specified part of the curve. +---@return number[] coordinates # List of x,y-coordinate pairs of points on the specified part of the curve. function BezierCurve:renderSegment(startpoint, endpoint, depth) end --- diff --git a/library/love/physics.lua b/library/love/physics.lua index a2eebd2f..e9118142 100644 --- a/library/love/physics.lua +++ b/library/love/physics.lua @@ -491,7 +491,7 @@ function Body:getAngularVelocity() end --- ---[Open in Browser](https://love2d.org/wiki/Body:getContacts) --- ----@return table contacts # A list with all contacts associated with the Body. +---@return love.Contact[] contacts # A list with all contacts associated with the Body. function Body:getContacts() end --- @@ -500,7 +500,7 @@ function Body:getContacts() end --- ---[Open in Browser](https://love2d.org/wiki/Body:getFixtures) --- ----@return table fixtures # A sequence with all fixtures. +---@return love.Fixture[] fixtures # A sequence with all fixtures. function Body:getFixtures() end --- @@ -529,7 +529,7 @@ function Body:getInertia() end --- ---[Open in Browser](https://love2d.org/wiki/Body:getJoints) --- ----@return table joints # A sequence with the Joints attached to the Body. +---@return love.Joint[] joints # A sequence with the Joints attached to the Body. function Body:getJoints() end --- @@ -2989,7 +2989,7 @@ function World:destroy() end --- ---[Open in Browser](https://love2d.org/wiki/World:getBodies) --- ----@return table bodies # A sequence with all bodies. +---@return love.Body[] bodies # A sequence with all bodies. function World:getBodies() end --- @@ -3037,7 +3037,7 @@ function World:getContactFilter() end --- ---[Open in Browser](https://love2d.org/wiki/World:getContacts) --- ----@return table contacts # A sequence with all Contacts. +---@return love.Contact[] contacts # A sequence with all Contacts. function World:getContacts() end --- @@ -3065,7 +3065,7 @@ function World:getJointCount() end --- ---[Open in Browser](https://love2d.org/wiki/World:getJoints) --- ----@return table joints # A sequence with all joints. +---@return love.Joint[] joints # A sequence with all joints. function World:getJoints() end --- diff --git a/library/love/thread.lua b/library/love/thread.lua index 0b903080..523f593b 100644 --- a/library/love/thread.lua +++ b/library/love/thread.lua @@ -118,10 +118,9 @@ function Channel:peek() end ---[Open in Browser](https://love2d.org/wiki/Channel:performAtomic) --- ---@param func function # The function to call, the form of function(channel, arg1, arg2, ...) end. The Channel is passed as the first argument to the function when it is called. ----@param arg1 any # Additional arguments that the given function will receive when it is called. ---@vararg any # Additional arguments that the given function will receive when it is called. ---@return any ret1 # The first return value of the given function (if any.) -function Channel:performAtomic(func, arg1, ...) end +function Channel:performAtomic(func, ...) end --- ---Retrieves the value of a Channel message and removes it from the message queue. diff --git a/library/love/touch.lua b/library/love/touch.lua index bacf8e30..a1501bcd 100644 --- a/library/love/touch.lua +++ b/library/love/touch.lua @@ -36,5 +36,5 @@ function love.touch.getPressure(id) end --- ---[Open in Browser](https://love2d.org/wiki/love.touch.getTouches) --- ----@return table touches # A list of active touch-press id values, which can be used with love.touch.getPosition. +---@return lightuserdata[] touches # A list of active touch-press id values, which can be used with love.touch.getPosition. function love.touch.getTouches() end diff --git a/library/love/window.lua b/library/love/window.lua index fa72a2a4..79d9758a 100644 --- a/library/love/window.lua +++ b/library/love/window.lua @@ -106,7 +106,7 @@ function love.window.getFullscreen() end ---[Open in Browser](https://love2d.org/wiki/love.window.getFullscreenModes) --- ---@param displayindex? number # The index of the display, if multiple monitors are available. ----@return table modes # A table of width/height pairs. (Note that this may not be in order.) +---@return {width: number, height: number} modes # A table of width/height pairs. (Note that this may not be in order.) function love.window.getFullscreenModes(displayindex) end --- diff --git a/update.sh b/update.sh new file mode 100755 index 00000000..564d122b --- /dev/null +++ b/update.sh @@ -0,0 +1,28 @@ +# Update LLS source +[ ! -d "lua-language-server" ] && git clone --recurse-submodules -j8 https://github.com/LuaLS/lua-language-server.git +cd lua-language-server || exit +git pull + +# Build LLS +./make.sh + +# Update love-api +git submodule update --remote 3rd/love-api + +# Build 3rd meta +./bin/lua-language-server ./tools/build-3rd-meta.lua + +# Copy 3rd meta to addon +cd .. || exit +rm -r library +cp -r lua-language-server/meta/3rd/love2d/library/ library + +# Install and run formatter +cargo install stylua --features luajit +export PATH="~/.cargo/bin:$PATH" +stylua library + +# Commit changes +git add library +git commit -m "Updated meta files" +git push \ No newline at end of file