Visual Studio Code

VS Code

for mac

https://code.visualstudio.com/docs/setup/mac

  • Open the Command Palette (Cmd+Shift+P) and type ‘shell
  • command’ to find the Shell Command: Install ‘code’ command in PATH command.

URLs

extensions

the following extensions helps your coding with Solar2D simulator.

  • Solar2D Autocomplete

  • Solar2d Companion for Visual Studio Code

  • Solar2D hex to normalized color

    color = #fff          -- becomes color = { 1.00, 1.00, 1.00 }
    color = #f8af          -- becomes color = { 1.00, 0.53, 0.67, 1.00 }
    color = #ff80a040      -- becomes color = { 1.00, 0.50, 0.63, 0.25
  • Local Lua Debugger

  • Run Terminal Command

  • Lua Language Server

    https://github.com/elMuso/solar2d-definitions

Local Lua Debugger

For debugging with Local Lua Deubgger, launch.json should be placed in your workspace folder. For instance,

Assuming Kwik projects are located in ~/Kwik folder and this is your workplace folder of Visual Studio Code. launch.json will be created under .vscode/ folder

  • ~/Kwik/.vscode/launch.json

    Corona Simulator.app is specified and ${file} is in the last argurment

    this is for Mac

      "version": "0.2.0",
      "configurations": [
        {
          "name": "Debug",
          "type": "lua-local",
          "request": "launch",
            "program": {
              "command": "/Applications/Corona/Corona Simulator.app/Contents/MacOS/Corona Simulator",
            },
            "args": [
              "-no-console"
              "YES"
              "-debug"
              "1"
              "-project"
              "${file}"
            ]
        }
      ]
    }

    for Windwos

    {
    "version": "0.2.0",
    "configurations": [{
        "name": "Debug",
        "type": "lua-local",
        "request": "launch",
          "program": {
            "command": "C:\\Program Files (x86)\\Corona Labs\\Corona\\Corona Simulator.exe",
          },
          "args": [
            "/no-console",
            "/debug",
            "${file}"
          ]
      }]
    }
  • SingleBook project contains Photsohop/book/*.psd and lua files under Solar2D/src folder

    • ~/Kwik/SingleBook/Solar2D/src/main.lua
  • open main.lua in Visual Studio Code and press F5 (Run > Start Debugging)

    main.lua needs lldebugger.start()

    if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
      local lldebugger = loadfile(os.getenv("LOCAL_LUA_DEBUGGER_FILEPATH"))()
      lldebugger.start()
    end

Run Terminal Command

this is a utility to run terminal commands. You can select a folder and right click opens a dialog to select a terminal command

You can add a terminal command to settings.json

for Mac

{
  "command":"\"/Applications/Corona/Corona Simulator.app/Contents/MacOS/Corona Simulator\" ./ -no-console YES",
 "name":"Solar2D"
},

Misc

Terminal Color

User or Worskpace settings > workbench.colorCustomizations, then edit in settings.json

  • https://glitchbone.github.io/vscode-base16-term/#/google-light

    "workbench.colorCustomizations": {
      "terminal.foreground": "#00FF00",
      "terminal.background": "#000080",
      "terminal.ansiBlack": "#4f4f4f",
      "terminal.ansiBlue": "#96cbfe",
      "terminal.ansiCyan": "#c6c5fe",
      "terminal.ansiGreen": "#a8ff60",
      "terminal.ansiMagenta": "#ff73fd",
      "terminal.ansiRed": "#ff6c60",
      "terminal.ansiWhite": "#eeeeee",
      "terminal.ansiYellow": "#ffffb6",
      "terminal.ansiBrightBlack": "#7c7c7c",
      "terminal.ansiBrightBlue": "#b5dcff",
      "terminal.ansiBrightCyan": "#dfdffe",
      "terminal.ansiBrightGreen": "#ceffac",
      "terminal.ansiBrightMagenta": "#ff9cfe",
      "terminal.ansiBrightRed": "#ffb6b0",
      "terminal.ansiBrightWhite": "#ffffff",
      "terminal.ansiBrightYellow": "#ffffcc",
      "terminal.selectionBackground": "#363983",
      "terminalCursor.foreground": "#ffa560"
    }