Lua Language Server #
Installing Lua Language Server #
- On the icons bar on the left, click on the bottom icon with four little squares to open the Extensions panel.
- Search for
Luaby typing it in the search bar and clicking the name in the list. Once opened, in theExtension: Luatab click the blue Install button.
- After the installation succeeds, the extension should now have the blue Disable and Uninstall buttons visible.
-
Click back to the Explorer panel by clicking on the icon with two pages, on top of the left bar.
-
Open the
hello-world.luafile, and click anywhere inside it. The files withinDefault Scriptsfolder will be analysed by the newly installed extension and marked orange to indicate problems.
- Scroll down to find the
dfhackmodule mention in the code. Notice how the name is underlined with an orange squiggly line to indicate an error. Hover over it with your cursor, and notice the message about an undefined global. They are there because right now the extension doesn’t understand the custom DFHack modules, and will require additional definitions to be added to do so.
Adding DFHack definitions #
- To make the extension recognize DFHack modules, you will install additional definitions. Download the DFHack Lua Definitions repository by clicking the green Code button, and then click on Download ZIP.
- Unpack the zip, and move the
libraryfolder and theconfig.jsonfile to your preferred location.
- Add the
Lua.workspace.librarysetting to thedfhack.code-workspacefile as per installation instructions in the repository - don’t forget to add the comma after the}bracket above it. Save the file.
- VSCodium should now understand some of the DFHack Lua references, and a lot of the folders should no longer be marked with orange. Note that the definitions repository is a work in progress and doesn’t yet include all of the definitions. In example below, the extension now understands
dfhack, but doesn’t understanddfhack.color().