How to run Lua script from within VS Code

luascriptingvisual-studio-codevscode-extensions

Have been using Notepad++ for awhile now, and adding scripts via Lua extensions. Now, I would like to get my feet wet using VS Code and was wondering what sort of extensibility I could leverage in that environment? Possible to run the same Lua scripts, for instance? Or are there other avenues I should consider? Thanks for any insights!

Best Answer

Please install the vs-code extensions "LuaDebug" and "extensionPath" provided by actboy168.

Add a file named .vscode/launch.json with the content:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lua",
            "request": "launch",
            "name": "Launch",
            "program": "${workspaceFolder}/src/main.lua"
        }
    ]
}

if your source to be executed is src/main.lua.

Then hit F5 or "Run"->"Start Debugging", select the lauch configuration and happy debugging.

An example is also shipped by the author of the plug-in (actboy128), which can be found here: https://github.com/actboy168/luamake

Please do not try to build it, simply load it in VS Code and debug it!