Typechecking and Autocomplete
Upon building, godot-luau-script will generate a single type definition file
for use by Luau’s analyzer.
Autocomplete and analysis in the Godot editor is not supported. As such, the most viable setup is to use Visual Studio Code and the luau-lsp extension.
Setup
After installing VSCode and luau-lsp, you will need to do the following setup:
- Set the preference
luau-lsp.require.modetorelativeToFileto makerequirerelative to the current script. - Set the preference
luau-lsp.types.robloxtofalseto disable Roblox types being loaded by default. - Set the preference
luau-lsp.types.definitionFilesto an array containing the path todefinitions/luauScriptTypes.gen.d.lua. - Set the FFlags
LuauRecursionLimitandLuauTarjanChildLimitto something higher than the defaults (e.g. 5000 and 20000 respectively). This can be done through theluau-lsp.fflags.overridepreference.- This is necessary because the generated definition file is too large and complex for Luau to parse by default.
After doing this (and reloading the workspace), you should get type checking and
autocomplete for all Godot and godot-luau-script types.