Skip to main content

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

---@fileparam paramName type

Usage

---@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:
---@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:
Use the settings menu instead of editing the JSON file directly. This helps you avoid config mistakes.
.gluarc.json
{
  "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:
---@fileparam ply Player
---@fileparam attacker Player
---@fileparam victim Entity