Page 1 of 1

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

Posted: Sun Jun 09, 2024 12:45 am
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?

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

Posted: Tue Jul 09, 2024 10:34 pm
by ravener
I've been having the same issue, have you found a solution yet?

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

Posted: Fri Jul 12, 2024 12:01 am
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

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

Posted: Sat Jul 13, 2024 7:19 am
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

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

Posted: Sat Jul 13, 2024 7:25 am
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 !

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

Posted: Sat Jul 13, 2024 8:43 am
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 ?

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

Posted: Sun Jul 14, 2024 6:15 pm
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"
    ],

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

Posted: Mon Jul 15, 2024 7:12 am
by gcmartijn
Yes that works with

Code: Select all

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