Skip to main content

Overview

Use @call_arg when your function wraps a Garry’s Mod API. It lets completion, navigation, type checking, and other editor features treat the wrapper like the original function. Most addons do not need this annotation. The official annotations already apply it to built-in functions like include, AddCSLuaFile, file.Find, util.AddNetworkString, net.Start, hook.Add, vgui.Register, and derma.DefineSkin. Only add it when the wrapper has the same behavior as the API it represents.
Wrappers that call the standard GMod network functions are detected automatically. You do not need @call_arg for normal net.Start, net.Receive, read, write, or send wrappers.

Syntax

Put @call_arg directly above the @param it describes.
After this, GLuaLS treats the path argument as a file loaded by include. For overloaded signatures, use @overload_call_arg directly above the @overload it describes:
The first argument is the zero-based parameter index inside that overload.

Supported roles

Guard metadata such as valid_guard, self_guard, and self_call_valid belongs on functions and callbacks, not parameters. Use Guard metadata for functions and callbacks that prove values are valid.

Hooks with callbacks

Use one role for the hook name and one role for the callback function:
GLuaLS uses the hook name to infer callback parameters:
Use emit for functions that call hooks:

Lua loading

Use gmod.load for wrappers around Lua file and module loading:
Calls through these wrappers affect file loading and realm detection like direct include, AddCSLuaFile, IncludeCS, and require calls. GLuaLS follows fixed paths and file.Find loops when it can identify the matching files. Use gmod.file_find when wrapping file.Find itself:
When FindLuaFiles("myaddon/*.lua", "LUA") is used in a loop and the loop body calls annotated load wrappers, GLuaLS can infer which matching files are loaded server-side, sent to the client, or shared.

VGUI panels

Use define, table, and base for a vgui.Register wrapper:
Use define_control instead of define for derma.DefineControl wrappers. Use reference for functions that create or look up panels by name.

Derma skins

Use gmod.derma_skin when wrapping Derma skin functions:
GLuaLS can then find references between DefineSkin("MySkin", ...) and UseSkin("MySkin").

Scripted classes

Use gmod.network_var when wrapping entity NetworkVar helpers:
Use define_element for wrappers around NetworkVarElement, because element accessors always return numbers. For gamemode inheritance wrappers, mark the base-name parameter:
Use gmod.class_base reference for wrappers around DEFINE_BASECLASS.

Priority

An optional third argument breaks ties when one parameter can inherit multiple roles:
Higher priority wins. You normally do not need this unless you are annotating a generic wrapper that can behave like several APIs.

See also