vscode Lua integration
we should probably provide whatever integration is needed to enable vscode's lua extension (vscode-lua) to be aware of DFHack's lua libraries, as this would facilitate the use of vscode to edit dfhack lua scripts
for more info about vscode-lua, see this link
Also if i could be totally shameless - related issue #420. Theoretically any we could have lua breakpoints! (not sure if vscode-lua supports the same attach a debugger to socket system)
You may want to use sumneko's lua vscode extension instead of vscode-lua. Vscode-Lua hasn't been updated in 4 years and I think the only analysis it does is provided by luacheck, which is a good tool but doesnt seem to cover any type checking.
sumneko's on the other hand is under active development and provides dynamic type checking that can be further augmented by using annotations. I have used type annotations on some of my python projects in a similar way and it is an extremely nice feature
Extension: https://github.com/sumneko/lua-language-server
Type checking example: https://github.com/sumneko/lua-language-server/wiki/Type-Checking
sumneko's extension looks pretty slick. I'm looking into it now. I'm trying to figure out how to get it to recognize the symbols injected into the environment from dfhack.lua.
I asked a question here: sumneko/lua-language-server#1766
See Akiira's comment that just adding df and dfhack as globals goes a long way: https://github.com/sumneko/lua-language-server/issues/1766#issuecomment-1352627728
we could also produce a library definition file and maybe get the entire C API available for autocompletion...
Working through some prototyping over in https://github.com/vallode/dfhack-lua-definitions. The gist, as I see it, is:
- Automatic generation of type definitions for all structures is possible
- Module-level functions will need to be maintained manually
I think my generating the definitions from XML parsing via ruby isn't ideal, but it's probably the only way available in my toolbelt right now. Ideally we'd hook into the actual XML generation and generate the lua definitions in the same way we do the structures. My 2 cents, I'll know more when I work through this a bit more :)
@vallode have you been able to make anything sharable for dfhack-vscode integration? something we could check into our tree or add to our docs?