Skip to main content

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:
GLuaLS infers the parameters from the GMod hook definition.

Custom prefixes

If your framework uses a custom table instead of GM or PLUGIN, configure GLuaLS to recognize it:
Use the settings menu instead of editing the JSON file directly. This helps you avoid config mistakes.
.gluarc.json

Hook autocomplete

When you call hook.Add("|", ...), hook.Run("|", ...), or hook.Call("|", ...), GLuaLS autocompletes known hook names, including GMod built-ins and your custom hooks.

See also