-
Notifications
You must be signed in to change notification settings - Fork 1
VSCode setup
VSCode can be donwloaded from official page.
Development of lua-modules requires some additional extentions to be installed in VSCode:
- Lua 3.6.1 by sumneko.lua (Lua Language Server coded by Lua)
- Lua 0.0.9 by keyring (Lua language support for Visual Studio Code)
- Lua 0.2.19 by Tencent (LuaHelper, Intellisense, Linting, Debugging, Code formatting, High-performance, and more.)
- Lua lint 0.0.5 by satoren (Static error checker for Lua)
- Lua Debug 1.10.1 by actboy168 (VSCode debugger extension for Lua)
- Busted Test Explorer 0.2.1 by Vivien HENRIET (Discover and run your lua busted tests from vscode)
First of all you need to download modules source code:
git clone [email protected]:vxcontrol/soldr-modules.git
cd soldr-modules
git submodule init
git submodule update
cd luapower/
./mgit clone [email protected]:vxcontrol/soldr-luapower-repos.git
./mgit clone-all
To simplify next configuration steps add a global environment variable:
echo "\n\nLUAPOWER_PLATFORM=$([[ $(uname) == "Darwin" ]] && echo "osx64" || echo "linux64")\n" >> ~/.bash_profile
source ~/.bash-profile
Open source code repository in VSCode and set some user settings (Shift+Cmd+P/Shift+Ctrl+P → Preferences:Open User Settings (JSON)):
"lua.debug.settings.luaVersion": "jit",
"lua.debug.settings.path": "${workspaceFolder}/tests_framework/lua/?.lua;${workspaceFolder}/tests_framework/lua/?/init.lua;${workspaceFolder}/luapower/?.lua;${workspaceFolder}/luapower/?/init.lua;${workspaceFolder}/utils/?.lua;${workspaceFolder}/utils/?/init.lua",
"lua.debug.settings.cpath": "${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/lib?.dylib;${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/clib/?.so;${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/lib?.dll;${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/clib/?.dll",
"Lua.telemetry.enable": false,
"Lua.diagnostics.globals": [ "lfs", "describe", "it", "setup", "teardown", ],
"Lua.runtime.path": [
"${workspaceFolder}/?.lua",
"${workspaceFolder}/?/init.lua",
"${workspaceFolder}/utils/?.lua",
"${workspaceFolder}/utils/?/init.lua",
"${workspaceFolder}/tests_framework/lua/?.lua",
"${workspaceFolder}/tests_framework/lua/?/init.lua",
"${workspaceFolder}/luapower/?.lua",
"${workspaceFolder}/luapower/?/init.lua"
],
"Lua.diagnostics.libraryFiles": "Disable",
"Lua.diagnostics.ignoredFiles": "Disable",
"Lua.workspace.ignoreDir": [ ".vscode", "tests_framework" ],
"busted-test-explorer.testfilepattern": "tests/*_spec.lua",
"busted-test-explorer.executable": "${workspaceFolder}/tests_framework/lua/bin/busted.${env:LUAPOWER_PLATFORM}.cmd",
"busted-test-explorer.cwd": "${workspaceFolder}",
"busted-test-explorer.env": {
"LOG_LEVEL": "error",
"LUA_PATH": "${workspaceFolder}/tests_framework/lua/?.lua;${workspaceFolder}/tests_framework/lua/?/init.lua;${workspaceFolder}/luapower/?.lua;${workspaceFolder}/luapower/?/init.lua;${workspaceFolder}/utils/?.lua;${workspaceFolder}/utils/?/init.lua",
"LUA_CPATH": "${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/lib?.dylib;${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/clib/?.so;${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/lib?.dll;${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/clib/?.dll",
"LUA_BIN": "${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/luajit-bin",
},
Now running tests from "Testing" side menu as well as from "*_spec.lua" files should work.
In VSCode you need to add following launch configuration:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Editor Contents",
"program": "${workspaceFolder}/${relativeFile}",
"arg": [
"-e", "require 'busted.runner'({ standalone = false })",
],
"arg0": "-e dofile('${workspaceFolder}/utils/mock/thread.lua')",
"env": {
"LOG_LEVEL": "error",
"LUA_DEBUG_PATH": "${userHome}/.vscode/extensions/actboy168.lua-debug-1.60.1-darwin-x64",
},
"request": "launch",
"cwd": "${workspaceFolder}",
"luaexe": "${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/luajit-bin",
"path": "${workspaceFolder}/tests_framework/lua/?.lua;${workspaceFolder}/tests_framework/lua/?/init.lua;${workspaceFolder}/luapower/?.lua;${workspaceFolder}/luapower/?/init.lua;${workspaceFolder}/utils/?.lua;${workspaceFolder}/utils/?/init.lua",
"cpath": "${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/lib?.dylib;${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/clib/?.so;${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/lib?.dll;${workspaceFolder}/luapower/bin/${env:LUAPOWER_PLATFORM}/clib/?.dll",
"stopOnEntry": false,
"stopOnThreadEntry": false,
"type": "lua"
}
]
}
Environment variable "LUA_DEBUG_PATH" should point to a directory with Lua Debug plugin.
Now "Run" (Ctrl/Cmd+F5) and "Run and Debug" (F5) should be available in VSCode.
Note: in case if breakpoints are set in several threads then you can observe that both threads can be stopped on these breakpoints, unfortunately you can continue debugging only in one thread, all other will be released with normal execution (or can again be paused on other breakpoints).