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

# @fileparam

> Set default parameter types for the entire file.

## Overview

`@fileparam` sets a default type for any parameter with the same name in the current file. Functions without an explicit `@param` for that name use the file-level default.

***

## Syntax

```lua theme={null}
---@fileparam paramName type
```

***

## Usage

```lua theme={null}
---@fileparam ply Player
---@fileparam vehicle Vehicle

-- No @param needed for these functions — they inherit from @fileparam
local function enter(vehicle, ply)
    local driver = vehicle:GetDriver()  -- vehicle is typed as Vehicle ✅
    if IsValid(driver) then
        driver:ChatPrint("Welcome!")
    end
    ply:EnterVehicle(vehicle)           -- ply is typed as Player ✅
end

local function exit(vehicle, ply)
    ply:ExitVehicle()  -- ✅
end
```

***

## Precedence

If GLuaLS cannot infer the parameter type from the function signature or owning type, it checks these sources in order:

1. **Explicit `@param`** annotation on the function itself
2. **`@fileparam`** for the current file
3. **`gmod.fileParamDefaults`** in `.gluarc.json`: workspace-wide defaults

***

## Override with @param

If one function in the file needs a different type for the same parameter name, add `@param` to that function:

```lua theme={null}
---@fileparam vehicle Vehicle

local function enter(vehicle, ply)
    -- vehicle: Vehicle (from @fileparam)
end

---@param vehicle Entity  -- overrides @fileparam for this function only
local function inspectGeneric(vehicle)
    -- vehicle: Entity
end
```

***

## Workspace defaults

Set defaults for all files in the workspace:

<Tip>
  Use the settings menu instead of editing the JSON file directly. This helps you avoid config mistakes.
</Tip>

```json .gluarc.json theme={null}
{
  "gmod": {
    "fileParamDefaults": {
      "ply": "Player",
      "target": "Entity",
      "dmginfo": "CTakeDamageInfo"
    }
  }
}
```

***

## Common patterns

GMod addons reuse parameter names such as `ply`, `attacker`, and `victim`. Use `@fileparam` or workspace defaults to avoid repeated `@param` annotations:

```lua theme={null}
---@fileparam ply Player
---@fileparam attacker Player
---@fileparam victim Entity
```
