Skip to content

Coming from LuaLS ​

wowlua-ls reads the same ---@ annotation syntax as LuaLS, so most annotations written for LuaLS keep working. It isn't LuaLS, though, and doesn't aim to be compatible with it: it has its own config file, checks your code as WoW's Lua rather than a Lua version you choose, ignores a few LuaLS annotations, and has its own diagnostics, with their own names, defaults and rules. This page lists what differs and what to do about each difference.

Turn off LuaLS for your addon ​

If LuaLS keeps running on the same files, you get every hover, completion and diagnostic twice, once from each server. Turn it off for your addon.

VS Code ​

LuaLS usually comes as two extensions: Lua (sumneko.lua), which runs the server, and Ketho's WoW API (ketho.wow-api), which supplies the WoW API annotations. wowlua-ls replaces both: its WoW API stubs are built in, generated in part from the annotations WoW API ships.

In the Extensions view, open each extension's gear menu and choose Disable (Workspace). Disable WoW API first, since it depends on Lua. Both stay enabled in your other workspaces.

By default, WoW API also writes LuaLS settings such as Lua.diagnostics.globals into the workspace's .vscode/settings.json. wowlua-ls doesn't read them; Move your settings says where they go instead.

JetBrains IDEs ​

A plugin that runs LuaLS, or another Lua plugin such as EmmyLua, adds its own completions and inspections next to wowlua-ls's. Disable it under Settings → Plugins → Installed: select the plugin and click Disable. This turns it off in every project. If you added LuaLS to LSP4IJ yourself as a language server, remove it there.

Zed and Neovim ​

Zed's Lua extension starts LuaLS on Lua files; Getting Started shows the setting that turns it off. In Neovim, keep lua_ls from attaching to your addon, as the tip at the end of the Neovim section describes.

Formatting ​

LuaLS has a built-in code formatter, on by default. wowlua-ls doesn't format code, so once LuaLS is off, Format Document and format-on-save stop formatting your Lua files. If you relied on them, set up a separate formatter.

Move your settings to .wowluarc.json ​

wowlua-ls reads only .wowluarc.json files. It doesn't read .luarc.json, or the Lua.* settings in your editor's settings. Renaming .luarc.json doesn't help either: the key names and value formats differ, a key wowlua-ls doesn't know does nothing, and a value of the wrong type (LuaLS's "diagnostics": { "enable": true }, for instance) keeps the whole file from loading. wowlua-ls reports both on the file (see Mistakes in a config), and in VS Code, the extension also validates .wowluarc.json as you type.

Rewrite the settings you need by hand. The common ones map like this:

.luarc.json.wowluarc.json
diagnostics.globalsglobals.read for globals that come from elsewhere, such as another addon; globals.write for globals your addon creates, which it can then also read
diagnostics.globalsRegex* and ? wildcards in globals.read and globals.write: globs, not regular expressions
diagnostics.disablediagnostics.disable, using wowlua-ls's codes (see Diagnostics)
diagnostics.severitydiagnostics.severity, with lowercase values: "error", "warning", "information" (or "info"), "hint". Capitalized values and the ! forms are rejected.
diagnostics.neededFileStatusNo equivalent: a check is either on or off. Turn on a check that's off by default with diagnostics.enable.
diagnostics.enableNo equivalent. diagnostics.enable here is a list of codes to turn on, not an on/off switch.
workspace.librarylibrary: scanned for types, with no diagnostics reported in it. Leave out entries for WoW API annotations, such as Ketho's: the stubs are built in.
workspace.ignoreDirignore
runtime.versionNo equivalent: see WoW's Lua.

Relative paths in ignore and library start from the folder holding the .wowluarc.json, and every path is taken literally: ${workspaceFolder}, ${3rd} and ~ aren't expanded. Patterns aren't .gitignore syntax: Tests/ matches only the Tests folder next to the config file, while **/Tests/** matches a Tests folder at any depth.

Some globals need no entry at all: the SavedVariables and SavedVariablesPerCharacter your .toc file declares, SLASH_*, BINDING_HEADER_* and BINDING_NAME_* globals, and the mixin and script-handler names your XML files bind are all allowed already.

For example, this .luarc.json:

json
{
  "runtime.version": "Lua 5.1",
  "diagnostics.globals": ["OtherAddonAPI", "MyAddonDB", "MyAddon_OnLoad"],
  "diagnostics.disable": ["lowercase-global", "param-type-mismatch"],
  "diagnostics.severity": { "unused-local": "Warning" },
  "workspace.library": ["Libs"],
  "workspace.ignoreDir": ["Tests"]
}

becomes this .wowluarc.json:

json
{
  "globals": {
    "read": ["OtherAddonAPI"],
    "write": ["MyAddon_OnLoad"]
  },
  "diagnostics": {
    "disable": ["type-mismatch"],
    "severity": { "unused-local": "warning" }
  },
  "library": ["Libs/"],
  "ignore": ["Tests/"]
}

MyAddonDB is a SavedVariables global from the addon's .toc, so it's already allowed. param-type-mismatch is written as wowlua-ls's type-mismatch. runtime.version and lowercase-global have no counterpart and are dropped. See the Configuration guide for every other setting.

WoW's Lua, not a version you choose ​

There's no runtime.version to set: every file is checked as WoW's Lua 5.1, against the game's globals.

  • Syntax from later Lua versions is a syntax error: labels (::continue::), integer division (//), and the bitwise operators (&, |, ~, <<, >>). Use WoW's bit library (bit.band, bit.bor, …) instead of the operators. goto isn't a keyword in Lua 5.1, so goto continue is read as two names and reported as undefined-global.
  • Standard library parts WoW doesn't have are reported: require, io, os, debug, load and utf8 as undefined-global, and table.unpack as undefined-field. WoW has unpack, loadstring, time, date and debugstack instead.

Annotations ​

What carries over ​

wowlua-ls supports @param, @return, @class, @field, @type, @alias (with ---| member lines; a ---|> line is a member like the others), @enum, @generic, @overload, @cast (including + and - forms such as ---@cast x -?), @as, @deprecated, @nodiscard, @see, @private, @protected, @meta and @diagnostic. String literal types can use either quote style. On @type, @alias, @cast and @class lines, the rest of the line after a complete type is a comment; right after a @class name with no parents, start it with -- or # (see Documentation comments). The annotation reference lists everything wowlua-ls supports, including its WoW-specific annotations.

Accepted, with no effect ​

These LuaLS annotations don't produce a diagnostic, but wowlua-ls doesn't act on them:

AnnotationWhat to do instead
@operatorGive the class's metatable the metamethod (__add, __sub, __concat, …). wowlua-ls types an operator's result from the metamethod's @return.
@vararg TWrite @param ... T. @vararg leaves ... untyped, so the arguments passed there aren't checked.
@class (exact) and @class (partial)Nothing: the modifier is read and ignored.
@package, @public, @async, @module, @source, @version, @nodocNothing.

@meta files and copies of the WoW API ​

A @meta file still gets the annotation checks: an undefined type name, a malformed annotation or a @field outside a class is reported there as anywhere else. And in a @meta file, an annotated method of a built-in class replaces the built-in signature, which is how you correct a built-in stub.

That second rule matters if your addon keeps its own copy of the WoW API annotations, such as a folder copied from Ketho's extension so LuaLS could find it. The copy's methods replace the built-in ones, so wherever the copy is older or less complete, correct calls are reported as wrong. Delete the copy, or add it to ignore.

Diagnostics ​

Many codes have the same names as LuaLS's (undefined-global, undefined-field, need-check-nil, unused-local, …), so most ---@diagnostic comments keep working. The diagnostics reference lists every code. Where the two differ:

  • Aliases only in comments. In ---@diagnostic comments, LuaLS's param-type-mismatch, return-type-mismatch and invisible stand for type-mismatch, return-mismatch, and access-private with access-protected. .wowluarc.json doesn't take these aliases: use wowlua-ls's codes there.
  • LuaLS-only codes. Codes with no wowlua-ls counterpart, such as lowercase-global, cast-local-type, spell-check and codestyle-check, are accepted in ---@diagnostic comments but suppress nothing. In .wowluarc.json, a code wowlua-ls doesn't have does nothing, and is reported as a warning on the file.
  • Globals. create-global reports every global your code creates, whatever its case; nothing corresponds to lowercase-global. Declare the variable local, or list a global your addon means to export in globals.write.
  • Defaults. Several checks are off by default, including need-check-nil, which LuaLS runs on open files. Diagnostics disabled by default lists them; turn them on with diagnostics.enable.
  • New warnings. wowlua-ls knows the WoW API, the frames your XML declares and the flavors your .toc files target, so expect warnings LuaLS never gave: a field a frame type doesn't have, an API missing from a flavor you target (wrong-flavor-api), a comparison on a secret value. wowlua_ls check lists every diagnostic in the addon at once.