Skip to content

Snakybo/vscode-wow-api

 
 

Repository files navigation

WoW API

Adds IntelliSense features for World of Warcraft API to VS Code. This is a plugin extension for Sumneko's Lua Language Server with annotations.

Features

  • Enum and Constants table
  • LE_ Lua Enums

Shows completion for GlobalStrings at >3 uppercase letters to declutter fuzzy search.

Workspace detection

To avoid loading for Lua projects not related to World of Warcraft, all settings will be specific to the workspace instead of the global user settings; and this extension will only activate when either:

  • the extension was previously loaded in the workspace.
    • details: a settings.json with Lua.workspace.library containing a path with the substring wow-api exists in the workspace.
  • a .toc file exists.
    • details: a .toc file with the ## Interface: directive exists in the workspace.
  • the Activate WoW API extension command is used.

AddOn namespace

LuaLS doesn't know about the AddOn namespace, so this needs to be annotated with @class in each file. This way the language server knows about the shared table and also allows you to mutate it, which would not be possible with a single @class and then @type in other files.

  • file1.lua
---@class ns
local ns = select(2, ...)

ns.foo = "hello"
  • file2.lua
---@class ns
local ns = select(2, ...)

ns.bar = "world"

Contributing

The extension reflects the state of the wiki, so if you create/update the wiki pages, it will be updated in the extension on the next release. Otherwise feel free to create an issue with the false errors.

For example UnitLevel would be documented like so.

{{wowapi}}
Returns the level of the unit.
 level = UnitLevel(unit)

==Arguments==
:;unit:{{apitype|string}} : [[UnitId]]

==Returns==
:;level:{{apitype|number}}

Alternatively, the script will look for a commented block for API pages not documented in Blizzard_APIDocumentationGenerated.

<!-- luals
---@param unit UnitId
---@return number level
function UnitLevel(unit) end
-->

Developing

Refer to SETUP.md if you want to run the Lua scripts which generate the documentation.

Acknowledgements

People who have contributed to the WoW API documentation or the VS Code extension, or have written tools to make this possible.

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 83.3%
  • Lua 16.7%