Skip to main content
EmmyLua provides industry-leading intelligent code completion features, supporting not only basic function, variable, table field, and module completion, but also multiple innovative features that enhance your coding productivity.

Core Completion Features

Auto Require

Intelligently lists available Lua modules and automatically adds require statements on selection

Alias & Enum

Smart completion based on parameter types with support for alias and enum fields

Function Lambda

Detects function type parameters and automatically generates lambda expressions

Namespace

Supports namespace completion with smart suggestions for sub-namespaces and class names

Auto Require

When typing module names, EmmyLua intelligently suggests available Lua modules from your workspace. Upon selection (Tab press), it automatically adds the require statement at the appropriate position in your file header.
-- Start typing and select from suggestions
local utils = require("src.utils.string")
Features:
  • Intelligently lists available Lua modules
  • Automatically adds require statement on Tab press
  • Smart insertion at appropriate position in file header
  • Supports both . and / separators

Alias & Enum Completion

Context-aware completion that understands parameter types and suggests appropriate alias and enum values.
---@alias LogLevel "debug" | "info" | "warn" | "error"

---@param level LogLevel
local function log(level, message)
    -- Typing 'level = ' will suggest: "debug", "info", "warn", "error"
end

log("info", "Application started") -- Smart suggestions when typing
Features:
  • Smart completion based on parameter types
  • Support for alias and enum fields
  • Context-aware precise completion
  • Works with union types

Function Lambda Generation

Automatically generates lambda expressions when function type parameters are detected, keeping your code clean and elegant.
---@param callback fun(name: string, age: number): boolean
local function process(callback)
    -- Implementation
end

-- Type 'process(' and accept the completion
process(function(name, age)
    -- Lambda automatically generated with correct parameters
    return age > 18
end)
Features:
  • Detects function type parameters
  • Automatically generates lambda expressions
  • Includes parameter names and types
  • Keeps code clean and elegant

Namespace Completion

Supports namespace completion with smart suggestions for sub-namespaces and class names.
---@class Game.Player
local Player = {}

---@class Game.Enemy
local Enemy = {}

---@type namespace<"Game">
local game -- Typing 'game.' suggests: Player, Enemy, etc.
Usage:
  • Use ---@type namespace<"ClassName"> annotation
  • Smart suggestions for sub-namespaces and class names
  • Supports nested namespace completion

Path Completion System

Smart completion for require parameters, supports both . and / separators.
-- Type require(" and get suggestions
local utils = require("utils.string")
local config = require("config/settings")
Features:
  • Intelligent module path detection
  • Support for . and / separators
  • Workspace-aware suggestions
  • Fuzzy matching support

Advanced Completion Features

Postfix Completion

Type @ or . after variables to trigger expression completion templates.
local items = {1, 2, 3, 4, 5}

-- Type 'items@for' and accept suggestion
for i, v in ipairs(items) do
    -- Generated automatically
end

-- Type 'value@if' for conditional
if value then
    -- Generated automatically
end
Available Templates:
  • @for - Generate for loop
  • @if - Generate if statement
  • @not - Negate expression
  • @return - Generate return statement

Snippet Completion

Built-in code snippets for common patterns and structures.
-- Type 'func' and select snippet
function name(params)
    -- cursor here
end

-- Type 'class' for class template
---@class ClassName
local ClassName = {}

function ClassName:new()
    local instance = {}
    setmetatable(instance, self)
    self.__index = self
    return instance
end
Features:
  • Built-in code snippets
  • Support for common Lua patterns
  • Tab stops for easy navigation
  • Future support for custom template system

Trigger Characters

Completion can be triggered by the following characters:
  • . - Member access
  • : - Method call
  • ( - Function parameters
  • [ - Table index
  • " or ' - String literals (for paths)
  • - Space (for keywords)
  • @ - Postfix templates
  • \ or / - File paths
  • | - Union types

Smart Features

All completion features support fuzzy matching for faster code writing.
-- Typing 'tins' matches 'table.insert'
-- Typing 'strf' matches 'string.format'
The fuzzy matcher considers:
  • Character sequence matching
  • CamelCase abbreviations
  • Common abbreviations
Completion items are intelligently sorted based on:
  • Relevance to current context
  • Usage frequency
  • Scope proximity
  • Type compatibility
  • Recently used items
The completion engine understands your code context:
  • Function signatures
  • Variable types
  • Table structures
  • Module imports
  • Documentation comments

Configuration

Completion behavior can be configured through your .emmyrc.json:
{
  "completion": {
    "enable": true,
    "autoRequire": true,
    "postfix": true
  }
}
All completion features support fuzzy matching and smart sorting for a smoother coding experience.

Build docs developers (and LLMs) love