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: CONTRIBUTING.md
+91-2Lines changed: 91 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,6 +136,14 @@ It is recommended to use it over the built-in Lua plugins.
136
136
Please note that EmmyLua is not available for other editors based on Visual Studio Code,
137
137
such as [VSCodium](https://vscodium.com) or [Eclipse Theia](https://theia-ide.org) but can be built from source if needed.
138
138
139
+
Another alternative on VSCode is to use [sumneko's Lua language server](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) along with [actboy168's debugger](https://marketplace.visualstudio.com/items?itemName=actboy168.lua-debug). These can potentially offer more features than EmmyLua, such as conditional breakpoints.
140
+
141
+
## Runtime environment
142
+
143
+
It is recommended that you configure your IDE to include `src/_SimpleGraphic.def.lua` somehow. Path of Building runs inside a special Lua environment via SimpleGraphic which implements a small API. These are not defined inside the project, which means that the aforementioned meta/hint file is required for the IDE to know which functions exist. As the file is not included in code, it must be explicitly mentioned as a library in whichever language server you are using, or otherwise it will not be read.
144
+
145
+
This file is normally not executed, but does contain basic implementations for parts of the API, which allows many parts of PoB to work without running inside SimpleGraphic. If you wish to test individual changes, it might be possible to do so through a script using Luajit directly. To do so, see HeadlessWrapper.lua for an example. It should be noted that some parts of the API (such as subscripts) are not implemented, which means some parts of PoB are unusable.
146
+
139
147
### Visual Studio Code
140
148
141
149
1. Create a new <kbd>Debug Configuration</kbd> of type <kbd>EmmyLua New Debug</kbd>
@@ -168,20 +176,54 @@ such as [VSCodium](https://vscodium.com) or [Eclipse Theia](https://theia-ide.or
168
176
1. In VSCode click <kbd>Start Debugging</kbd> (the green icon) or press <kbd>F5</kbd>
169
177
1. The debugger should connect
170
178
179
+
You might also want to use actboy168 debugger. This is possible by using for example the following launch.json configuration:
180
+
181
+
```json
182
+
{
183
+
"version": "0.2.0",
184
+
"configurations": [
185
+
{
186
+
"name": "🍄attach",
187
+
"type": "lua",
188
+
"request": "attach",
189
+
"stopOnEntry": false,
190
+
"address": "127.0.0.1:12306",
191
+
"luaVersion": "luajit",
192
+
},
193
+
194
+
]
195
+
}
196
+
```
197
+
198
+
Then, similarly to the EmmyLua example:
199
+
200
+
1. Find the sub-folder that looks like `actboy168.lua-debug-x.y.z-win32-x64` in `%USERPROFILE%/.vscode/extensions`. Navigate to it and find the `debugger.lua` script under the script folder. Copy this to `runtime/lua`.
201
+
2. Copy-paste the following code snippet into `launch:OnInit()`:
-- debugger:event("wait") -- Uncomment this line if you want PoB to wait until the debugger is attached.
205
+
```
206
+
171
207
172
208
#### Excluding directories from EmmyLua
173
209
174
210
Depending on the amount of system ram you have available and the amount that gets assigned to the jvm running the emmylua language server you might run into issues when trying to debug Path of building.
175
-
Files in `/Data``/Export` and `/TreeData` can be massive and cause the EmmyLua language server to use a significant amount of memory. Sometimes causing the language server to crash. To avoid this and speed up initialization consider adding an `.emmyrc.json`file to the `.vscode` folder in the root of the Path of building folder with the following content:
211
+
Files in `/Data``/Export` and `/TreeData` can be massive and cause the EmmyLua language server to use a significant amount of memory. Sometimes causing the language server to crash. To avoid this and speed up initialization consider adding an `.emmyrc.json`to the root of the Path of building folder with the following content:
// this is not technically correct as LoadModule behaviour can
219
+
// differ from require, but it is useful for now
220
+
"requireLikeFunction": ["LoadModule"],
182
221
},
183
222
"workspace": {
184
223
"ignoreGlobs": [
224
+
"**/*_spec.lua",
225
+
"spec/**/*.lua",
226
+
"runtime/lua/sha1/lua53_ops.lua",
185
227
"**/src/Data/**/*.lua",
186
228
"**/src/TreeData/**/*.lua",
187
229
"**/src/Modules/ModParser.lua"
@@ -190,6 +232,46 @@ Files in `/Data` `/Export` and `/TreeData` can be massive and cause the EmmyLua
190
232
}
191
233
```
192
234
235
+
This file can be customised according to what you want. It is a good idea to ignore test files as these tend to add things to the global namespace, which will look confusing, and they are designed to be run by Busted. `lua53_ops.lua` produces errors and doesn't actually get imported when using LuaJIT. It can be useful to keep the data and mod parser files, but generally this will increase the time the LSP takes to index the project on startup.
236
+
237
+
### Excluding directories from Sumneko's language server
238
+
239
+
If you prefer to not use EmmyLua, the following configuration works well for Sumneko's VS Code extension:
240
+
241
+
```json
242
+
{
243
+
"Lua.workspace.ignoreDir": [
244
+
".vscode",
245
+
// these files add things to global that aren't there in normal
246
+
// operation
247
+
"spec/*",
248
+
"src/Export/*",
249
+
"src/HeadlessWrapper.lua",
250
+
251
+
// this has lua 5.3 code which produces errors, but doesn't actually run
252
+
"src/runtime/lua/sha1/*",
253
+
254
+
// avoid overriding the below library setting
255
+
"src/_SimpleGraphic.def.lua",
256
+
],
257
+
"Lua.diagnostics.disable": ["inject-field"],
258
+
// disables diagnostics even when you open one of the above
259
+
"Lua.diagnostics.ignoredFiles": "Disable",
260
+
"Lua.runtime.version": "LuaJIT",
261
+
"Lua.workspace.preloadFileSize": 1000,
262
+
// this is not technically correct as LoadModule behaviour can
263
+
// differ from require, but it is useful for now
264
+
"Lua.runtime.special": {
265
+
"LoadModule": "require"
266
+
},
267
+
"Lua.workspace.library": [
268
+
"src/_SimpleGraphic.def.lua"
269
+
],
270
+
}
271
+
```
272
+
273
+
The extension will automatically skip large files from being preloaded (controlled by `Lua.workspace.preloadFileSize`), so they don't have to be excluded. The configuration file can be found by pressing Ctrl-Shift-P and selecting `Preferences: Open Workspace Settings (JSON)`. If you wish to check test files, you can remove the "ignoredFiles" option and install the busted, LuaFileSystem, and luassert LuaLS addons through `Lua: Open Addon Manager`.
274
+
193
275
### PyCharm Community / IntelliJ Idea Community
194
276
195
277
1. Create a new "Debug Configuration" of type "Emmy Debugger(NEW)".
@@ -223,6 +305,13 @@ More tests can be added to this folder to test specific functionality, or new te
223
305
224
306
Please try to include tests for your new features in your pull request. Additionally, if your pr breaks a test that should be passing please update it accordingly.
225
307
308
+
It can also be a good idea to install `busted` locally as it tends to be faster to execute:
309
+
310
+
1. Install Luajit (due to PoB accessing the jit library, it non-Luajit versions might not work)
311
+
2. Install [Luarocks](https://luarocks.org/) (for example, through Scoop or your Linux package manager)
312
+
3. Run `luarocks install busted`
313
+
4. Run `busted --lua=luajit` to run the tests. You can also use e.g. `-p TestUtils_spec.lua` to run a specific file.
314
+
226
315
### Debugging tests
227
316
When running tests with a docker container it is possible to use EmmyLua for debugging. Paste in the following right under `function launch:OnInit()` in `./src/Launch.lua`:
0 commit comments