User:Ash/SRB2 Lua on VSCode

From SRB2 Wiki
Jump to navigation Jump to search

REPORT BUGS HERE: https://git.do.srb2.org/LJSonic/vscode-lua-srb2


This is a simple guide to get SRB2 Lua working on VSCode.

Thanks to LJ for making these tools available to us! THIS EXTENSION IS NOT COMPLETE, SO SOME DEFINITIONS MAY BE MISSING. (But it works well IMO)


This guide requires VSCode to be installed on your computer.

WARNING: MAY REQUIRE OTHER LUA LANGUAGE EXTENSIONS TO BE DISABLED.

Follow the guide step by step for best results.


First, download this file and decompress it:

VSCode-SRB2Lua-3.7.4.zip (should support Windows, Mac and maybe Linux depending on your distro)

Put the SRB2Defs Lua file in a place you won't have to move very often (for best results!).


Then, in VSCode, open your command palette (on PC: CTRL + Shift + P. on Mac: Command + Shift + P).

Type "install from VSIX":

A picture of VSCode with the command palette open, highlighting "Install from VSIX".


Follow the prompt to install the SRB2Lua VSIX file.

When it's installed, go to your extensions and locate the SRB2 Lua extension. Then, click the gear icon to open its settings.

This picture shows the SRB2 Lua extension with some arrows pointing to the extensions icon on the left, and the gear icon on the right.


Once in settings, scroll down until you see "Lua > Workspace: Library".

From there, hit the "Add Item" button and point it to your SRB2Defs Lua file.

Any other Lua files you'd like the extension to reference are OPTIONAL.

Pictured is my setup, with the SRB2 defs file and 2 files I wanted the extension to load for me:

This picture shows the Library section of the SRB2 Lua extension's settings. The only file required for this to work is the SRB2defs lua file.


You may want to scroll to find "Lua > Workspace: Max Preload" and "Lua > Workspace: Preload File Size".

From there, increase their values so the library file doesn't get rejected by the extension. My settings are provided as a reference, but you can use any number that works (but the default is too small, I think):

A picture of the SRB2 Lua VSCode extension's settings for max file sizes: Max Preload at 10000, and Preload File Size at 5000.


You can optionally add SRB2 Lua specific symbols like continue and slash comments // under "Lua > Runtime: Nonstandard Symbol":

A picture of the SRB2 Lua VSCode extension's nonstandard symbols settings, with "continue" and slash comments added.


And that's it! You should be able to see it working in your Lua files:

A picture of the SRB2 Lua VSCode extension with the text "add" typed into the editor, with multiple SRB2-specific options that match the string "add" popping up with Intellisense.


Troubleshooting

If it does not work, try the following steps:

- Some web browsers seem to download SRB2Defs.lua with the wrong extension under some circumstances. Ensure it is not called SRB2Defs.lua.txt or some other extension instead.