LuaRT icon indicating copy to clipboard operation
LuaRT copied to clipboard

Tracker: LuaLS annotations for LuaRT modules

Open mochaaP opened this issue 2 years ago • 13 comments

I'm planning on adding LuaLS integration to LuaRT. This issue is a progress tracker for it.

Progress

  • [ ] sys
  • [ ] net
  • [ ] compression
  • [ ] ui
  • [ ] canvas
  • [ ] string
  • [ ] sqlite
  • [ ] console
  • [ ] json
  • [ ] crypto
  • [ ] webview
  • [ ] base
  • [ ] audio

Further ideas:

  • first class lite-xl support?
  • bundle LuaLS?

mochaaP avatar Aug 05 '23 10:08 mochaaP

Lua Language Server support for LuaRT will be a great move. If you have questions or need help just ask 😉

samyeyo avatar Aug 05 '23 10:08 samyeyo

@samyeyo Would it be okay if I put the type annotations to types/ or lib/types?

mochaaP avatar Aug 05 '23 10:08 mochaaP

Yes lib/types should be more appropriated

samyeyo avatar Aug 05 '23 10:08 samyeyo

Hi @samyeyo, do you have time to assistance on the lrtobjects? I'm a bit confused about the API design

mochaaP avatar Aug 13 '23 16:08 mochaaP

Yes, sure, how can I help you ?

samyeyo avatar Aug 13 '23 16:08 samyeyo

If I understood that correctly, it could be a userdata type abstracted as a @class, but I'm not sure how can I define the getter & setter functions, instancing and inheritance

https://github.com/LuaLS/lua-language-server/wiki/Annotations

mochaaP avatar Aug 13 '23 16:08 mochaaP

as it's the base of many other interfaces, this need to be completely typed in the annotations

if there are any features missing in the language server, leave a feedback here and I will open an issue upstream.

mochaaP avatar Aug 13 '23 16:08 mochaaP

In fact there are two types of objects :

  • C objects defined in C, linked to a userdata
  • Lua objects, defined in a Lua script, not linked to a userdata

A Lua defined object can single inherit both kind of objects A C defined object don't have inheritance (it can be simulated as for ui Widgets)

samyeyo avatar Aug 13 '23 16:08 samyeyo

A getter function starts with get_ and setters with set_

An instance has a table named __type in it's metatable, that contains a field __name set to a string, the name of the object/class

samyeyo avatar Aug 13 '23 16:08 samyeyo