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.globals | globals.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.disable | diagnostics.disable, using wowlua-ls's codes (see Diagnostics) |
diagnostics.severity | diagnostics.severity, with lowercase values: "error", "warning", "information" (or "info"), "hint". Capitalized values and the ! forms are rejected. |
diagnostics.neededFileStatus | No equivalent: a check is either on or off. Turn on a check that's off by default with diagnostics.enable. |
diagnostics.enable | No equivalent. diagnostics.enable here is a list of codes to turn on, not an on/off switch. |
workspace.library | library: 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.ignoreDir | ignore |
runtime.version | No 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:
{
"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:
{
"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
syntaxerror: labels (::continue::), integer division (//), and the bitwise operators (&,|,~,<<,>>). Use WoW'sbitlibrary (bit.band,bit.bor, …) instead of the operators.gotoisn't a keyword in Lua 5.1, sogoto continueis read as two names and reported asundefined-global. - Standard library parts WoW doesn't have are reported:
require,io,os,debug,loadandutf8asundefined-global, andtable.unpackasundefined-field. WoW hasunpack,loadstring,time,dateanddebugstackinstead.
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:
| Annotation | What to do instead |
|---|---|
@operator | Give the class's metatable the metamethod (__add, __sub, __concat, …). wowlua-ls types an operator's result from the metamethod's @return. |
@vararg T | Write @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, @nodoc | Nothing. |
@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
---@diagnosticcomments, LuaLS'sparam-type-mismatch,return-type-mismatchandinvisiblestand fortype-mismatch,return-mismatch, andaccess-privatewithaccess-protected..wowluarc.jsondoesn'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-checkandcodestyle-check, are accepted in---@diagnosticcomments 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-globalreports every global your code creates, whatever its case; nothing corresponds tolowercase-global. Declare the variablelocal, or list a global your addon means to export inglobals.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 withdiagnostics.enable. - New warnings. wowlua-ls knows the WoW API, the frames your XML declares and the flavors your
.tocfiles 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 checklists every diagnostic in the addon at once.
