Overview
@hook marks a method as a GMod hook handler. GLuaLS can then validate hook names, infer parameters from hook definitions, and autocomplete hook names in hook.Add and hook.Run.
Syntax
- Without an argument: GLuaLS uses the method name as the hook name
- With an argument: GLuaLS uses the given hook name instead of the method name
Basic usage
GM: overrides
GLuaLS treats methods on the gamemode table (GM) as hook overrides. You do not need @hook for them in most cases:
Custom prefixes
If your framework uses a custom table instead ofGM or PLUGIN, configure GLuaLS to recognize it:
.gluarc.json
Hook autocomplete
When you callhook.Add("|", ...), hook.Run("|", ...), or hook.Call("|", ...), GLuaLS autocompletes known hook names, including GMod built-ins and your custom hooks.
See also
- Hook intelligence: how GLuaLS analyzes hooks