Generate Lua Type Definitions from LAD file
Hello. Thank you for this wonderful crate!
Generating the LAD file for my project was easy. But I'm not sure how to make it work with the Lua LSP. I see that it is an in progress issue tracked in https://github.com/makspll/bevy_mod_scripting/issues/248.
I found that the Lua LSP requires definition files as described here. This should make all the suggestions/auto-complete etc work.
Assuming that the LAD file allows generating them, is there any progress on this front? Would love to test it out and contribute if possible!
Thanks!
Hi! I've worked on this a bit over at: https://github.com/makspll/bevy_mod_scripting/tree/feat/lua-declaration-files.
The largest problem currently is that bevy's reflection does not allow you to know which parts of a type come from a generic monomorphisation: https://github.com/bevyengine/bevy/issues/17117.
It should still be possible to work around that, the latest problem I was trying work out was how to work with types like Handle<T> and map them to lua declaration types nicely without having the full information
Awesome, Will check it out!
I understand that it could be challenging to support generics atm. Personally I have yet to reach out for them in scripts. We can always create wrappers using NamespaceBuilder for few cases if needed.
Since this is specifically for the LSP (and not the scripting API itself), a subset of type support should be good enough. If the current LAD file can almost fully convert the types supported into the Lua definitions, we can have the backend implemented. Later on whenever the generic problem is tackled, we should be able to extend it.
What do you think?
yeah I agree supporting a subset of types and functions would be a great start! That branch already contains the rust-side structs for the declerration files and some reading/writing foundations, so if you're wanting to have a crack at it it's a great place to start!
Cool. I'll take a look and see what I can do.