Getting Started with Lua in Visual Studio Code#
This guide will help you set up Visual Studio Code to write and edit Lua code for your project
π§° Prerequisites#
Before starting, make sure you have:
- Visual Studio Code installed: https://code.visualstudio.com/
- Your project folder open in VS Code (with access to the Content/Script directory)
Step 1: Install Lua Extensions#
To make VS Code Lua-friendly, install a Lua language extension.
β Recommended: Lua Language Server
- Open VS Code.
- Go to the Extensions panel (click the square icon on the sidebar or press Ctrl+Shift+X).
- Search for: Lua
- Install the one called Lua by sumneko or Lua Language Server.
- Reload VS Code if prompted.
This extension provides syntax highlighting, autocomplete, error checking, and IntelliSense
βοΈ Step 2: Configure the Lua Runtime (Optional)#
If the Lua Language Server shows unwanted diagnostics or doesn't recognize your folder structure, you can configure it.
Press Ctrl+Shift+P and choose Preferences: Open Settings (JSON).
Add or update the following settings:
"Lua.workspace.checkThirdParty": false,
"Lua.runtime.version": "Lua 5.4",
"Lua.workspace.library": [
ββ"${workspaceFolder}/Content/Script"
],
"Lua.diagnostics.globals": ["require"]
Adjust the path if your Lua code is located elsewhere
π§ͺ Step 3: Verify Itβs Working#
Open or create a file named main.lua.
Type this example:
print("Hello from VS Code!")
You should see syntax highlighting and auto-complete suggestions
π¨ Optional: Customize Your Environment#
Use themes like One Dark Pro or Monokai for better visuals
Install fonts like Fira Code or JetBrains Mono with ligatures
Enable line numbers, minimap, and breadcrumbs from the settings panel
π You're Ready to Code#
Youβre all set to write Lua code for your platform using Visual Studio Code.
From here, you can:
- Open and edit any
.luafile insideContent/Script - Work on
client,server, orsharedlogic as defined in yourpackage.json
Happy Coding!