Toggle search
Search
Toggle menu
Toggle personal menu
Editing
Modding/Using Visual Studio Code
(section)
From Desynced Wiki
Read
Edit
Edit source
View history
Page
Discussion
More actions
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Additional Customization === ==== Syntax highlighting for UI layout strings ==== To make Visual Studio Code show syntax highlighting of Desynced UI layout strings you can install this tiny extension which will apply XML formatting for text inside multi-line Lua strings. This works because Desynced UI layout definitions are similar to XML documents. To install the extension after downloading it, switch to the Extensions tab (by clicking the icon or by pressing <code>CTRL + SHIFT + X</code>) and select the "Install from VSIX..." option inside the ⋯ menu in the top-right of the Extensions panel. Download: https://github.com/StageGames/vscode-xml-in-lua/releases/download/1.0.0/stagegames.xml-in-lua-1.0.0.vsix ==== Highlight Status Bar While Debugging ==== To make it easier to know if your debugger is attached, you can make VS Code colorize the status bar in an orange tone. To do so, press <code>CTRL + SHIFT + P</code>, write ">workspace settings json", press enter and add the following rules to the settings file: <syntaxhighlight lang="json"> "workbench.colorCustomizations": { "statusBar.background": "#007ACC", "statusBar.debuggingBackground": "#CA5100", },</syntaxhighlight> ==== Code Hot-Reload Hotkey ==== You can configure a custom hotkey to make the game hot-reload any code changes from within VS Code. To do so, press To do so, press <code>CTRL + SHIFT + P</code>, write ">keyboard shortcuts json" and select "Preferences: Open Keyboard Shortcuts (JSON)" and add the following entries to it: <syntaxhighlight lang="json">[ { "key": "ctrl+f7", "command": "workbench.debug.action.focusRepl", "when": "!inDebugRepl" }, { "key": "ctrl+f7", "command": "workbench.action.debug.start", "when": "debuggersAvailable && debugState == 'inactive'" }, { "key": "ctrl+f7", "command": "runCommands", "when": "inDebugRepl", "args": { "commands": [ { "command": "workbench.action.files.saveAll" }, { "command": "workbench.debug.viewlet.action.reapplyBreakpointsAction"}, { "command": "cursorBottom" }, { "command": "cursorTopSelect" }, { "command": "type", "args": { "text": "Debug.Reload()" } }, { "command": "repl.action.acceptInput" }, { "command": "workbench.action.focusActiveEditorGroup"} ] } }, ]</syntaxhighlight> With that in place, at any time you can hold CTRL then press F7 twice to make the game reload any changes made to Lua. ==== Integrate with TortoiseSVN ==== If you use TortoiseSVN to manage software versioning of your Lua code you can add a few hotkeys to easily access common SVN functions. To do so, press <code>CTRL + SHIFT + P</code>, write ">keyboard shortcuts json" and select "Preferences: Open Keyboard Shortcuts (JSON)" and add the following entries to it: <syntaxhighlight lang="json">[ { "key": "ctrl+numpad1", "command": "workbench.action.terminal.sendSequence", "args": { "text": "&\"C:\\Program Files\\TortoiseSVN\\bin\\TortoiseProc.exe\" \"/command:diff\" \"/path:${file}\"\n" } }, { "key": "ctrl+numpad2", "command": "workbench.action.terminal.sendSequence", "args": { "text": "&\"C:\\Program Files\\TortoiseSVN\\bin\\TortoiseProc.exe\" \"/command:log\" \"/path:${file}\"\n" } }, { "key": "ctrl+numpad3", "command": "workbench.action.terminal.sendSequence", "args": { "text": "&\"C:\\Program Files\\TortoiseSVN\\bin\\TortoiseProc.exe\" \"/command:blame\" \"/path:${file}\"\n" } }, ]</syntaxhighlight> With these in place, the following hotkeys become available to VS Code while having a .lua file open: * <code>CTRL + NUMPAD 1</code>: Open diff of the current file against the source repository * <code>CTRL + NUMPAD 2</code>: Open the revision log of the current file * <code>CTRL + NUMPAD 3</code>: Open the blame tool for the currently edited file ==== Better Diagnostics ==== To avoid the Lua extension in Visual Studio code reporting too many or too few problems, the settings can be further refined. In VS Code, press <code>CTRL + SHIFT + P</code>, write ">workspace settings json", press enter and append the following into the settings file: <syntaxhighlight lang="json">{ "Lua.diagnostics.disable": [ "unbalanced-assignments", "cast-local-type", "need-check-nil", "duplicate-set-field", "undefined-field", "assign-type-mismatch", ], "Lua.diagnostics.severity": { "redundant-return": "Error", "unused-function": "Error", "empty-block": "Error", "trailing-space": "Error", "unreachable-code": "Error", "redundant-parameter": "Error", "missing-parameter": "Error", "unused-vararg": "Error", }, "Lua.type.weakNilCheck": true, "Lua.type.weakUnionCheck": true, "files.associations": { "*.json": "jsonc", }, "search.exclude": { "desynced-lls-library.lua": true, ".vscode": true, }, }</syntaxhighlight>
Summary:
Please note that all contributions to Desynced Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Desynced Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)