[SOLVED] Lua Language Server type annotations for rxi/classic classes

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
keharriso
Party member
Posts: 109
Joined: Fri Nov 16, 2012 9:34 pm

[SOLVED] Lua Language Server type annotations for rxi/classic classes

Post by keharriso »

Hello, everyone! I've been having a lot of success with the tiny rxi/classic class library. I understand the Lua Language Server has class and type annotations, but I can't seem to make them work with the classic classes. Has anyone had success using a class library with type annotations?
Last edited by keharriso on Fri Jul 12, 2024 12:01 am, edited 1 time in total.
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
ravener
Prole
Posts: 1
Joined: Fri Dec 30, 2022 10:26 am

Re: Lua Language Server type annotations for rxi/classic classes

Post by ravener »

I've been having the same issue, have you found a solution yet?
User avatar
keharriso
Party member
Posts: 109
Joined: Fri Nov 16, 2012 9:34 pm

Re: Lua Language Server type annotations for rxi/classic classes

Post by keharriso »

Solution found!

Example:

Code: Select all

---@class Map
---@overload fun(cols: integer, rows: integer): Map
local Map = Object:extend()

function Map:new(cols, rows)
    -- initialize map
end
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
gcmartijn
Party member
Posts: 144
Joined: Sat Dec 28, 2019 6:35 pm

Re: [SOLVED] Lua Language Server type annotations for rxi/classic classes

Post by gcmartijn »

I did never heard of Lua Language Server (LLS), very interesting.

At the moment I'm using Ldoc , to generate documentation for my code
https://github.com/lunarmodules/ldoc

I see that they use different annotations for example this is Ldoc

Code: Select all

---
-- @tparam triggerData triggerData
-- @tparam actionData actionData
-- @tparam table actionList
-- @tparam number actionListIndex
-- @tparam number actionId
-- @tparam function afterProcessActionListCallback
function ActionCamera:execute(
    triggerData,
    actionData,
    actionList,
    actionListIndex,
    actionId,
    afterProcessActionListCallback)
I'm wondering if LLS can generate written code into html like Ldoc?
For example like this https://stevedonovan.github.io/winapi/api.html
gcmartijn
Party member
Posts: 144
Joined: Sat Dec 28, 2019 6:35 pm

Re: [SOLVED] Lua Language Server type annotations for rxi/classic classes

Post by gcmartijn »

Answer my own question: https://luals.github.io/wiki/export-docs/ it is possible to export to json and markdown.
I know that there are many tools to convert markdown into html, so I'm going give it a try ;) thanks for sharing this !
gcmartijn
Party member
Posts: 144
Joined: Sat Dec 28, 2019 6:35 pm

Re: [SOLVED] Lua Language Server type annotations for rxi/classic classes

Post by gcmartijn »

keharriso wrote: Sun Jun 09, 2024 12:45 am Hello, everyone! I've been having a lot of success with the tiny rxi/classic class library. I understand the Lua Language Server has class and type annotations, but I can't seem to make them work with the classic classes. Has anyone had success using a class library with type annotations?
How did you include love ?
Attachments
Screenshot 2024-07-13 at 10.42.09.png
Screenshot 2024-07-13 at 10.42.09.png (116.9 KiB) Viewed 6463 times
User avatar
keharriso
Party member
Posts: 109
Joined: Fri Nov 16, 2012 9:34 pm

Re: [SOLVED] Lua Language Server type annotations for rxi/classic classes

Post by keharriso »

gcmartijn wrote: Sat Jul 13, 2024 8:43 am How did you include love ?
I think if you are using the LLS plugin by sumneko, you need to add this to your settings.json:

Code: Select all

    "Lua.workspace.library": [
        "${3rd}/love2d/library"
    ],
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
gcmartijn
Party member
Posts: 144
Joined: Sat Dec 28, 2019 6:35 pm

Re: [SOLVED] Lua Language Server type annotations for rxi/classic classes

Post by gcmartijn »

Yes that works with

Code: Select all

"Lua.workspace.checkThirdParty": "Apply",
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests