You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rgp-lua/development-environment.md
+50-57Lines changed: 50 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,70 +45,63 @@ One effective way to do this is to detect modifier keys. If your script has a di
45
45
46
46
## Using Visual Studio Code
47
47
48
-
1. Install the extensions [Lua](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) (language server) and [Lua Debugger](https://marketplace.visualstudio.com/items?itemName=devCAT.lua-debug) (and optionally [vscode-lua-format](https://marketplace.visualstudio.com/items?itemName=Koihik.vscode-lua-format)).
48
+
There are several different VS Code extensions for Lua debugging, each with different pros and cons. Here is one setup that gives satisfactory results.
49
49
50
-
2. As of 1/25/2023, there's an error in the package manifest for Lua Debugger that prevents VS Code from creating breakpoints in lua files. ([Pull request](https://github.com/devcat-studio/VSCodeLuaDebug/pull/28) created.) In order to fix this:
50
+
1. Install the extensions [Lua](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) (language server) and [Lua MobDebug adapter](https://marketplace.visualstudio.com/items?itemName=AlexeyMelnichuk.lua-mobdebug).
51
51
52
-
1. Go to your local extension installation directory, usually `~/.vscode/extensions`.
52
+
2. For a development folder, it can be convenient to fork and clone the [Finale Lua repo](https://github.com/finale-lua/lua-scripts) and put any new scripts in the `src` folder. This lets you include existing things from the `library` and `mixin` folders. You can also set up a development folder somewhere else, if you prefer.
53
53
54
-
2. Find the folder for the extension, `devcat.lua-debug-1.1.1`
54
+
3. Open your development folder in VS Code.
55
55
56
-
3. Inside the folder, edit `packages.json`, deleting the `enableBreakpointsFor` element under `debuggers` and adding a `breakpoints` element under `contributes`.
57
-
58
-
```diff
59
-
--- package.json.original
60
-
+++ package.json.revised
61
-
@@ -21,21 +21,21 @@
62
-
"devDependencies": {},
63
-
"contributes": {
64
-
+ "breakpoints": [
65
-
+ {
66
-
+ "language": "lua"
67
-
+ }
68
-
+ ],
69
-
"debuggers": [
70
-
{
71
-
"type": "lua",
72
-
"label": "Lua Debugger",
73
-
- "enableBreakpointsFor": {
74
-
- "languageIds": [
75
-
- "lua"
76
-
- ]
77
-
- },
78
-
"program": "./DebugAdapter.exe",
79
-
```
80
-
81
-
4. If VS Code was open, close and restart it. You may then be prompted to reload the window when VS Code notices that the extension has changed on disk.
82
-
83
-
3. For a development folder, it can be convenient to fork and clone the [Finale Lua repo](https://github.com/finale-lua/lua-scripts) and put any new scripts in the `src` folder. This lets you include existing things from the `library` and `mixin` folders. You can also set up a development folder somewhere else, if you prefer.
84
-
85
-
4. Save the file [vscode-debuggee.lua](https://raw.githubusercontent.com/devcat-studio/VSCodeLuaDebug/master/debuggee/vscode-debuggee.lua) to your development folder, next to your script file. If you are developing outside of the repo `src` folder, also save the file [dkjson.lua](http://dkolf.de/src/dkjson-lua.fsl/raw/dkjson.lua?name=6c6486a4a589ed9ae70654a2821e956650299228) to your development folder, next to your script.
86
-
87
-
5. Open your development folder in VS Code.
88
-
89
-
5. Add the following three lines to your lua script. If you are developing outside the repo `src` folder, use `dkjson` in the first line instead of `lunajson.lunajson`. The `redirectPrint` argument tells your script to send any `print` output to the VS Code output window; it can be omitted or set to `false` if you prefer.
6. Type <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd> or click on the "Run and Debug" icon in the side bar, then click on the "create a launch.json file" link. From the "Select debugger" dropdown that appears, select `Lua Debugger`. This will create a default `launch.json` that should include this snippet at the bottom of the file:
98
-
99
-
```json
100
-
{
101
-
"name": "wait",
102
-
"type": "lua",
103
-
"request": "attach",
104
-
"workingDirectory": "${workspaceRoot}",
105
-
"sourceBasePath": "${workspaceRoot}",
106
-
"listenPublicly": false,
107
-
"listenPort": 56789,
108
-
"encoding": "UTF-8"
109
-
}
64
+
65
+
5.Type<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd>orclickonthe"Run and Debug" iconinthesidebartobringupthe"Run and Debug" panel. TheprocessforaddingtheLuaMobDebuglaunchconfigurationstoyour`launch.json` filedependsonwhetherornotyoualreadyhavea`launch.json` inyourworkspace.
66
+
67
+
-Ifyoudon't have a `launch.json` file yet, you'llseealinkto"create a launch.json file"; clickit. IfyouhaveaLuafileopenintheeditor, VSCodewillautomaticallycreatetheappropriate`launch.json` fileforyou. Otherwise, fromthedropdownthatappears, select`Lua MobDebug`. Your`launch.json` shouldincludetheseelementsaspartofthe`configurations` array:
6.Launchthe`Lua MobDebug: Listen` configurationbyselectingitfromthedropdownatthetopofthe"Run and Debug" panelandclickingthearrownexttoit (orhitting<kbd>F5</kbd>). ThistellsVSCodetolistenformessagesfromremoteexecutionofyourscript.
98
+
99
+
7.RunyourscriptfromFinale. AnybreakpointsyouhavesetinVSCodewillbehit, andthenyoucanuseVSCode's debugging capabilities. **Note** that the line `"stopOnEntry": true` in the launch configuration will cause the debugger to stop at the top of your script even if you have no breakpoints set. If you don'tlikethisbehavior, youcanchangethevalueto`false`.
100
+
101
+
8.Theextensioncollectsany`print` statementsandoutputsthemallattheendofthescript. Inordertoworkaroundthisandprintvalueswhileyourscriptisrunning, you'll need to define a local function:
102
+
```lua
103
+
localprint=function(...) print(...); io.flush() end
110
104
```
111
105
112
-
8. Launch the `wait` configuration by selecting it from the dropdown at the top of the "Run and Debug" panel and clicking the arrow next to it (or hitting <kbd>F5</kbd>). This tells VS Code to listen for messages from remote execution of your script.
113
106
114
-
9. Run your script from Finale. Any breakpoints you have set in VS Code will be hit, and then you can use VS Code's debugging capabilities.
107
+
9.Whenthescriptexits, yourdebugsessionwillend; you'll need to launch a new session from VS Code before invoking the script from Finale again.
0 commit comments