Skip to main content

Overview

GLuaLS supports VGUI, GMod’s panel GUI system. It understands vgui.Create() calls and the panel inheritance hierarchy, and it provides IDE features for VGUI development.

Panel type inference

When you call vgui.Create("Type"), GLuaLS types the returned value as the matching panel class:
local frame = vgui.Create("DFrame")   -- typed as DFrame
frame:SetTitle("My Window")            -- DFrame method ✅

local btn = frame:Add("DButton")       -- typed as DButton
btn:SetText("Click me")                -- DButton method ✅
btn.DoClick = function(self)
    -- self is typed as DButton ✅
end

Code lens

When gmod.vgui.codeLensEnabled is true, GLuaLS shows code lens annotations above panel creations and definitions. Enable in .gluarc.json:
Use the settings menu instead of editing the JSON file directly. This helps you avoid config mistakes.
.gluarc.json
{
  "gmod": {
    "vgui": {
      "codeLensEnabled": true
    }
  }
}

Inlay hints for :Add()

When using panel:Add("Type"), GLuaLS shows the panel type in an inlay hint:
local btn = frame:Add("DButton")  -- DButton

Custom panels

GLuaLS understands the standard VGUI inheritance pattern used to define custom panels:
local PANEL = {}

function PANEL:Init()
    self.label = self:Add("DLabel")
end

function PANEL:Paint(w, h)
    draw.RoundedBox(4, 0, 0, w, h, color_black)
end

vgui.Register("MyPanel", PANEL, "DPanel")
-- Now MyPanel is recognized as a panel type
-- that inherits from DPanel
After vgui.Register(name, PANEL, base), GLuaLS recognizes "MyPanel" in later vgui.Create("MyPanel") calls. The panel type includes all methods from the PANEL table plus inherited DPanel methods.

Scripted Entity Explorer

The Scripted Class Explorer lists VGUI panels for navigation. Click a panel class in the explorer to open its definition.

VSCode integration

VGUI features work after the extension starts. The Class Explorer sidebar shows registered panel types under the Classes section. Configure VGUI support in the settings panel. See GMod settings for the full reference.

Configuration

SettingDefaultDescription
gmod.vgui.codeLensEnabledtrueShow code lens on panel creations/definitions
gmod.vgui.inlayHintEnabledfalseShow inlay hints for panel:Add() type inference