Type Support
This guide will walk you though setting up working LSP type support for the Discord-Luau package.
Context
The Luau language has support for Alias declarations, however, Luau-LSP requires you to do some additional setup to enable these alias declarations to function.
Since the Discord-Luau package uses Luau language aliases, you’ll need to set up some additional configuration to get functional type support.
Git Submodules
-
Create a
.vscode/settings.jsonfile in your project root, IF there’s not one already available. Lune should of already created this file as we need to do some additional setup for the Lune runtime anyway -
If not already preasent, please add the following to the
.vscode/settings.jsonfile;"luau-lsp.require.directoryAliases": {} -
Add the following to the
luau-lsp.require.directoryAliasesobject;"@Builders": "DiscordLuau/Package/Classes/Builders","@Network": "DiscordLuau/Package/Classes/Network","@Objects": "DiscordLuau/Package/Classes/Objects","@Data": "DiscordLuau/Package/Data","@Enums": "DiscordLuau/Package/Enums","@Std": "DiscordLuau/Package/Std","@Utils": "DiscordLuau/Package/Utils","@Vendor": "DiscordLuau/Package/Vendor", -
Restart Luau-LSP, check to see if the library can now resolve the require aliases.
Example .vscode/settings.json file
{ "luau-lsp.require.mode": "relativeToFile", "luau-lsp.require.directoryAliases": { "@lune/": "~/.lune/.typedefs/0.8.2/",
"@Builders": "DiscordLuau/Package/Classes/Builders", "@Network": "DiscordLuau/Package/Classes/Network", "@Objects": "DiscordLuau/Package/Classes/Objects", "@Data": "DiscordLuau/Package/Data", "@Enums": "DiscordLuau/Package/Enums", "@Std": "DiscordLuau/Package/Std", "@Utils": "DiscordLuau/Package/Utils", "@Vendor": "DiscordLuau/Package/Vendor", } }