Visual Studio Code (VS Code) is one of the most popular code editors for FiveM development. This comprehensive guide will help you set up VS Code with all the essential extensions, configurations, and tools needed for efficient FiveM scripting.
VS Code offers several advantages for FiveM developers:
While FxDK provides an integrated development environment, VS Code offers more flexibility and is preferred by many developers for its extensibility and familiar interface.
Before setting up VS Code, ensure you have:
Download VS Code from https://code.visualstudio.com/ # Run the installer and follow the setup
wizard # Make sure to check “Add to PATH” during installation
Ubuntu/Debian
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg —dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c ‘echo “deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main” > /etc/apt/sources.list.d/vscode.list’
sudo apt update
sudo apt install code
Download VS Code from https://code.visualstudio.com/ # Or use Homebrew: brew install —cask
visual-studio-code
Open a terminal and verify VS Code is installed:
code —version1.85.0 c185983a683d14c396952dd432459097bc7f757f x64Install these extensions to enhance your FiveM development experience:
Extension: sumneko.lua (Lua Language Server)
This extension provides:
Install via VS Code Command Palette (Ctrl+Shift+P / Cmd+Shift+P) # Type: Extensions: Install
Extensions # Search: “Lua” and install “Lua” by sumneko
Extension: overextended.fivem-lua (FiveM Lua IntelliSense)
Provides autocomplete for FiveM natives, events, and functions:
# Install: “FiveM Lua IntelliSense” by OverextendedExtension: Built-in (enabled by default)
VS Code includes excellent JavaScript and TypeScript support. For enhanced FiveM development:
Install: “ES7+ React/Redux/React-Native snippets” (optional) # Install: “Prettier - Code
formatter” (recommended)
If you’re developing in C#, install:
# Install: “C# Dev Kit” by Microsoft # Install: “C#” by MicrosoftSee C# Basics for more information on C# development.
resources directory or a specific resource folderCreate a .vscode/settings.json file in your workspace root:
{
"files.associations": {
"fxmanifest.lua": "lua",
"fxmanifest.json": "json"
},
"files.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/__pycache__": true
},
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/build": true
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"[lua]": {
"editor.defaultFormatter": "sumneko.lua",
"editor.tabSize": 4,
"editor.insertSpaces": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"files.encoding": "utf8",
"files.eol": "\n"
}Create .vscode/settings.json with Lua-specific settings:
{
"Lua.workspace.library": ["${3rd}/love2d/library", "${workspace}/**"],
"Lua.runtime.version": "Lua 5.4",
"Lua.diagnostics.globals": [
"GetCurrentResourceName",
"RegisterNetEvent",
"AddEventHandler",
"TriggerServerEvent",
"TriggerClientEvent",
"TriggerEvent",
"AddStateBagChangeHandler",
"SetStateBagValue",
"GetEntityCoords",
"GetPlayerPed",
"CreateThread",
"Wait",
"Citizen",
"exports",
"GetResourceMetadata"
],
"Lua.completion.enable": true,
"Lua.completion.keywordSnippet": "Both",
"Lua.hover.enable": true,
"Lua.signatureHelp.enable": true
}To get autocomplete for FiveM natives, you’ll need to configure the FiveM Lua IntelliSense extension:
overextended.fivem-lua extension.vscode/settings.json:{
"fivem-lua.api": {
"natives": true,
"events": true,
"exports": true
}
}VS Code can recognize FiveM resource structure. Create a .vscode/settings.json:
{
"files.associations": {
"fxmanifest.lua": "lua",
"fxmanifest.json": "json",
"*.lua": "lua",
"*.js": "javascript",
"*.ts": "typescript"
},
"files.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/dist": true,
"**/build": true,
"**/.fxdk": true
}
}Create .vscode/launch.json for debugging FiveM resources:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to FiveM Server",
"type": "lua",
"request": "attach",
"port": 9223,
"sourceMaps": true
},
{
"name": "Debug Lua Script",
"type": "lua",
"request": "launch",
"program": "${file}",
"cwd": "${workspaceFolder}"
}
]
}For remote debugging (connecting to a server on another machine):
launch.json with the correct host and portCreate .vscode/lua.code-snippets for FiveM-specific snippets:
{
"FiveM Server Event": {
"prefix": "fmserver",
"body": [
"RegisterNetEvent('${1:event:name}')",
"AddEventHandler('${1:event:name}', function(${2:source})",
" ${3:-- Server-side code}",
"end)"
],
"description": "FiveM server event handler"
},
"FiveM Client Event": {
"prefix": "fmclient",
"body": [
"RegisterNetEvent('${1:event:name}')",
"AddEventHandler('${1:event:name}', function(${2:args})",
" ${3:-- Client-side code}",
"end)"
],
"description": "FiveM client event handler"
},
"FiveM Thread": {
"prefix": "fmthread",
"body": [
"CreateThread(function()",
" while true do",
" ${1:-- Thread code}",
" Wait(${2:0})",
" end",
"end)"
],
"description": "FiveM thread"
},
"FiveM Export": {
"prefix": "fmexport",
"body": [
"exports('${1:exportName}', function(${2:args})",
" ${3:-- Export code}",
" return ${4:result}",
"end)"
],
"description": "FiveM export function"
},
"fxmanifest.lua": {
"prefix": "fxmanifest",
"body": [
"fx_version 'cerulean'",
"game 'gta5'",
"",
"author '${1:Your Name}'",
"description '${2:Resource description}'",
"version '${3:1.0.0}'",
"",
"server_scripts {",
" '${4:server/*.lua}'",
"}",
"",
"client_scripts {",
" '${5:client/*.lua}'",
"}",
"",
"shared_scripts {",
" '${6:config.lua}'",
"}"
],
"description": "FiveM fxmanifest.lua template"
}
}Organize your resource files logically:
my-resource/
├── fxmanifest.lua
├── config.lua
├── server/
│ ├── main.lua
│ └── database.lua
├── client/
│ ├── main.lua
│ └── ui.lua
├── html/
│ ├── index.html
│ ├── style.css
│ └── script.js
└── locales/
├── en.lua
└── es.luaUse Git for version control. Create a .gitignore:
# VS Code
.vscode/
*.code-workspace
# Dependencies
node_modules/
package-lock.json
# Build outputs
dist/
build/
# OS files
.DS_Store
Thumbs.db
# FiveM
__resource.luaConfigure Prettier for consistent formatting:
.prettierrc:
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 100
}VS Code can work alongside FxDK:
If autocomplete isn’t working:
Ctrl+Shift+P → “Lua: Restart Language Server”.vscode/settings.json configuration.vscode folder and reconfigureIf debugging fails to connect:
If VS Code is slow:
files.excludefiles.watcherExclude settingsFor managing multiple resources:
Create .vscode/tasks.json for automation:
{
"version": "2.0.0",
"tasks": [
{
"label": "Restart Resource",
"type": "shell",
"command": "echo 'restart ${input:resourceName}'",
"problemMatcher": []
},
{
"label": "Build NUI",
"type": "shell",
"command": "npm run build",
"options": {
"cwd": "${workspaceFolder}/html"
},
"problemMatcher": []
}
]
}Customize keybindings in .vscode/keybindings.json:
[
{
"key": "ctrl+shift+r",
"command": "workbench.action.tasks.runTask",
"args": "Restart Resource"
}
]Now that you have VS Code configured:
You’ve now set up VS Code for FiveM development with:
✅ VS Code installed and configured
✅ Essential extensions for Lua, JavaScript, and FiveM
✅ Workspace settings optimized for FiveM resources
✅ Debugging configuration
✅ Custom code snippets
✅ Best practices for file organization
VS Code is now ready for efficient FiveM development. Start creating your resources and take advantage of IntelliSense, debugging, and the rich extension ecosystem!