Overview
GMod addons use hooks to respond to game events. GLuaLS understandshook.Add, hook.Remove, hook.Run, hook.Call, and GM: definitions. It provides completions, type inference, and validation for each one.
Hook name validation
Unrecognized hook names inhook.Add and hook.Remove trigger a diagnostic:
Parameter type inference
When GLuaLS knows the hook name, it types the callback parameters:Callback snippet completion
When you typehook.Add("HookName", and trigger completion on the callback argument, GLuaLS inserts a typed function snippet:
GM: hook definitions
Files in a gamemode context, such asgamemodes/*/gamemode/, define GM as the gamemode table. GLuaLS recognizes function GM:HookName() as a hook override:
GM: definition gives a custom hook a clear signature and definition target.
hook.Run and hook.Call completions
When typing the first argument tohook.Run or hook.Call, GLuaLS autocompletes from known hook names:
Custom hooks
GLuaLS also tracks hooks created by your code or your library:GM: method when you want stable parameter types and hover documentation across the project.
Hook wrappers
Framework wrappers around hook registration and execution can provide the same features. GLuaLS reads wrapper behavior from the Garry’s Mod annotations instead of requiring a specific function name. See@call_arg when you need to describe your own wrapper.
VS Code integration
Hook intelligence works when you usehook.Add, hook.Run, or define GM: methods. Configure validation behavior in the settings panel. See Garry’s Mod settings for the full reference.
Configuration
Control hook validation and mappings through thegmod section in .gluarc.json, especially gmod.hookMappings and the global diagnostics settings.