Lua Language Server

Lua Language Server #

Installing Lua Language Server #

  1. On the icons bar on the left, click on the bottom icon with four little squares to open the Extensions panel.
  1. Search for Lua by typing it in the search bar and clicking the name in the list. Once opened, in the Extension: Lua tab click the blue Install button.
  1. After the installation succeeds, the extension should now have the blue Disable and Uninstall buttons visible.
  1. Click back to the Explorer panel by clicking on the icon with two pages, on top of the left bar.

  2. Open the hello-world.lua file, and click anywhere inside it. The files within Default Scripts folder will be analysed by the newly installed extension and marked orange to indicate problems.

  1. Scroll down to find the dfhack module 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 #

  1. 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.
  1. Unpack the zip, and move the library folder and the config.json file to your preferred location.
  1. Add the Lua.workspace.library setting to the dfhack.code-workspace file as per installation instructions in the repository - don’t forget to add the comma after the } bracket above it. Save the file.
  1. 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 understand dfhack.color().