Skip to main content

Overview

The completion section controls autocomplete suggestions. These options adjust snippet expansion, require insertion, and the postfix trigger character.

Options

OptionTypeDefaultDescription
completion.enablebooleantrueEnable autocomplete entirely
completion.callSnippetbooleantrueInsert function calls as snippets with parameter placeholders
completion.stagedCallSnippetsbooleantrueUse staged snippets for known GMod APIs (hook.Add, net.Receive, net.Start, etc.)
completion.postfixstring"@"Trigger character for postfix completions. Options: "@", ".", ":"
completion.autoRequirebooleantrueInsert a require() statement when completing a symbol from another module
completion.autoRequireFunctionstring"require"Function name used when auto-inserting a require
completion.autoRequireNamingConventionstring"keep"Convention for the local alias when auto-requiring. Options: "keep", "snake-case", "pascal-case", "camel-case", "keep-class"
completion.autoRequireSeparatorstring"."Separator used in the auto-generated require path
completion.baseFunctionIncludesNamebooleantrueInclude the function name in completions for base class functions

Call snippets

When callSnippet is enabled, selecting a function in autocomplete inserts it with parameter placeholders:
-- Typing: hook.Add(
-- Inserts:
hook.Add("${1:HookName}", "${2:Identifier}", function(${3})
    ${4}
end)

Staged snippets

stagedCallSnippets enables split-stage completion for known GMod callbacks. After you accept a hook name, GLuaLS uses the expected hook signature and fills parameter names. Set false to use a generic placeholder.

Postfix completions

Postfix completions let you write a value and then trigger a structural completion after it:
tab@           -- triggers postfix menu on `tab`
-- Postfix options: pairs, ipairs, #, etc.
Change the trigger character if @ conflicts with your code style.

Auto-require

When you accept a completion from an imported module, autoRequire inserts a require() at the top of the file:
-- Accepting `mylib.doThing` inserts:
local mylib = require("mylib")
Set autoRequireFunction to your project’s custom loader if you use one:
.gluarc.json
{
  "completion": {
    "autoRequireFunction": "include"
  }
}

VSCode extension settings

You can also configure these settings in VS Code settings with the gluals.* prefix:
VSCode Setting.gluarc.json KeyTypeDefaultDescription
gluals.completion.enablecompletion.enablebooleantrueEnable autocompletion
gluals.completion.callSnippetcompletion.callSnippetbooleantrueShow call snippets
gluals.completion.stagedCallSnippetscompletion.stagedCallSnippetsbooleantrueStage API call snippets
gluals.completion.postfixcompletion.postfixstring"@"Postfix trigger character
gluals.completion.autoRequirecompletion.autoRequirebooleantrueAuto-insert require statements
gluals.completion.baseFunctionIncludesNamecompletion.baseFunctionIncludesNamebooleantrueInclude name in base function

Example

.gluarc.json
{
  "completion": {
    "enable": true,
    "callSnippet": true,
    "stagedCallSnippets": true,
    "postfix": "@",
    "autoRequire": false
  }
}