> ## 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.

# GLua Annotation Reference

> Reference for all annotation tags supported by GLua Language Server, using the same ---@tag dialect as the Lua Language Server for compatibility.

GLua Language Server uses the same annotation dialect as the Lua Language Server. If you already annotate Lua projects with `---@param`, `---@class`, and similar tags, those annotations work here without changes. This page lists every supported tag and the type syntax you can use with it.

## Annotation tags

| Tag              | Syntax                                          | Purpose                                                                                      |
| ---------------- | ----------------------------------------------- | -------------------------------------------------------------------------------------------- |
| `---@param`      | `---@param name type` or `---@param name? type` | Documents a function parameter. Add `?` after the name to mark it optional.                  |
| `---@return`     | `---@return type`                               | Documents the return type of a function.                                                     |
| `---@type`       | `---@type type`                                 | Overrides the inferred type of the following expression or variable.                         |
| `---@class`      | `---@class ClassName`                           | Declares a new class or table shape.                                                         |
| `---@field`      | `---@field name type`                           | Declares a field on a class declared with `---@class`.                                       |
| `---@deprecated` | `---@deprecated`                                | Marks a function or field as deprecated. The server will surface a diagnostic at call sites. |

## Type syntax

You can compose types with unions, optionals, arrays, and generic tables.

| Pattern            | Example                 | Meaning                                       |
| ------------------ | ----------------------- | --------------------------------------------- |
| Union              | `Entity \| nil`         | Either an `Entity` or `nil`.                  |
| Optional parameter | `count?`                | The parameter may be omitted.                 |
| Array              | `Entity[]`              | An array (table) of `Entity` values.          |
| Generic table      | `table<string, Player>` | A table with string keys and `Player` values. |

## Full example

```lua theme={null}
---@class VehicleConfig
---@field model string
---@field maxSpeed number
---@field isAdminOnly boolean

---Create a vehicle config entry.
---@param model string The model path.
---@param maxSpeed number Top speed in source units.
---@param isAdminOnly? boolean Defaults to false.
---@return VehicleConfig
local function makeVehicleConfig(model, maxSpeed, isAdminOnly)
  ---@type VehicleConfig
  local config = {
    model = model,
    maxSpeed = maxSpeed,
    isAdminOnly = isAdminOnly or false,
  }
  return config
end

---@deprecated Use makeVehicleConfig instead.
local function oldVehicleConfig() end
```

<Note>
  When you write an explicit `---@param` or `---@type`, it always wins over automatic inference. Use this to correct the server when your code shape is too dynamic for it to follow.
</Note>


## Related topics

- [GLua Diagnostic Rules Reference](/reference/rules.md)
- [GLua Language Server Performance](/reference/performance.md)
- [GLua Language Server Commands](/reference/commands.md)
- [IntelliSense and Type Tracking for GLua](/features/intellisense.md)
