Skip to main content

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:

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 .lua file inside Content/Script
  • Work on client, server, or shared logic as defined in your package.json

Happy Coding!

โœจ