Developing with Lua on Mac and VSCode

I’m trying to learn how to write a driver, and I’m following the setup instructions.

I’m on Mac. I am not able to get VSCode to load the API release:

I would really appreciate some help If someone got better luck!

Setup

  • install Lua (brew install lua@5.3)
  • install luarocks (brew install luarocks)
  • setup the LUA_PATH
# in zshrc
eval $(luarocks --lua-dir=/opt/homebrew/opt/lua@5.3 path --append)
# Where the SmartThings API Release is located
LUA_SMART_THINGS_BASE_PATH=/Users/me/Dev/side_projects/SmartThingsEdgeDrivers/lua_libs-api_v5_48X/lua_libs-api_v5
export LUA_PATH="$LUA_SMART_THINGS_BASE_PATH/?.lua;$LUA_SMART_THINGS_BASE_PATH/?/init.lua;./?.lua;./?/init.lua;$LUA_PATH"

This looks like

/Users/me/Dev/side_projects/SmartThingsEdgeDrivers/lua_libs-api_v5_48X/lua_libs-api_v5/?.lua;/Users/me/Dev/side_projects/SmartThingsEdgeDrivers/lua_libs-api_v5_48X/lua_libs-api_v5/?/init.lua;./?.lua;./?/init.lua;/opt/homebrew/Cellar/luarocks/3.9.2/share/lua/5.3/?.lua;/opt/homebrew/share/lua/5.3/?.lua;/opt/homebrew/share/lua/5.3/?/init.lua;/opt/homebrew/lib/lua/5.3/?.lua;/opt/homebrew/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua;/Users/me/.luarocks/share/lua/5.3/?.lua;/Users/me/.luarocks/share/lua/5.3/?/init.lua

In VSCode, install the Lua Language Server plugin.

At this point I get the error message above. I also tried my change setting some path in my IDE settings:

// .vscode/settings.json
{
    "Lua.runtime.path": [
        "${env:LUA_PATH}",
        "/Users/me/Dev/side_projects/SmartThingsEdgeDrivers/lua_libs-api_v5_48X/lua_libs-api_v5/?.lua",
        "/Users/me/Dev/side_projects/SmartThingsEdgeDrivers/lua_libs-api_v5_48X/lua_libs-api_v5/?/init.lua",
        "?/init.lua",
    ],
}

but this didn’t help.

This is what my repository looks like:

2 Likes

Tagging @AlejandroPadilla @nayelyz

1 Like

Hi @gsabran welcome to SmartThings Community

I’m not familiar with VSCode in this case, but you can start developing drivers without this configuration