> ## Documentation Index
> Fetch the complete documentation index at: https://glua.bluejutzu.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Hook Intelligence and Callback Typing

> GLua Language Server completes hook names, detects typos with quick fixes, types callback parameters from wiki signatures, and generates ENTITY stubs.

GLua Language Server provides dedicated support for Garry's Mod's hook system. It completes hook names from the bundled wiki dataset, detects typos, types callback parameters automatically, and generates stub tables for scripted entities, weapons, and panels.

## Hook name completion

When you type `hook.Add("`, the server suggests hook names from the 551 hooks in the bundled wiki dataset. It also includes custom hooks that your workspace fires with `hook.Run`.

```lua theme={null}
hook.Add("PlayerSay", "MyAddon", function(sender, text, teamChat)
    -- sender is typed as Player, text as string, teamChat as boolean
end)
```

## Typo detection

If you enter a hook name that does not exist, the server flags it and offers a quick fix based on edit distance.

```lua theme={null}
hook.Add("PlayerSpawned", "MyAddon", function(ply)
    -- Error: "PlayerSpawned" is not a known hook
    -- Quick fix: Did you mean "PlayerSpawn"?
end)
```

## Typed callback parameters

The server reads hook signatures from the wiki and applies them to your callback parameters automatically. You do not need to annotate them yourself.

```lua theme={null}
hook.Add("PlayerSay", "ChatFilter", function(sender, text, teamChat)
    sender:Kick("Spam") -- sender is typed as Player
    return ""            -- return type is inferred from hook signature
end)
```

## ENT / SWEP / PANEL stubs

When you define a scripted entity, weapon, or panel, the server can generate the full hook table for you.

### Scripted entity stub

Typing `function ENT:` triggers completion of the entity hook table. The server inserts a full stub with the most common hooks.

```lua theme={null}
ENT.Type = "anim"
ENT.Base = "base_anim"

function ENT:Initialize()
    self:SetModel("models/props_c17/oildrum001.mdl")
end

function ENT:Think()
end

function ENT:Use(activator, caller)
    -- activator is typed as Player, caller as Entity
end
```

The same applies to `SWEP` for scripted weapons and `PANEL` for VGUI panels.

## gameevent.Listen

The server also recognises `gameevent.Listen` as a valid hook source. Events registered this way are included in hook name completion and typo detection.

```lua theme={null}
gameevent.Listen("player_connect")
hook.Add("player_connect", "LogJoins", function(data)
    -- data is typed from the gameevent signature
end)
```

<Tip>
  Use the quick fix (Ctrl+.) on an unknown hook name to see the closest match from the wiki. This catches common mistakes like "PlayerDeath" vs "PlayerDeathThink" instantly.
</Tip>


## Related topics

- [GLua Language Server: GMod Lua IDE Support](/index.md)
- [GLua Diagnostic Rules Reference](/reference/rules.md)
- [IntelliSense and Type Tracking for GLua](/features/intellisense.md)
