Skip to content

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

  1. Create a .vscode/settings.json file 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

  2. If not already preasent, please add the following to the .vscode/settings.json file;

    "luau-lsp.require.directoryAliases": {
    }
  3. Add the following to the luau-lsp.require.directoryAliases object;

    "@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",
  4. 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",
}
}