๐Ÿš€ EmmyLua Language Server Features Guide

August 12, 2025 ยท View on GitHub

๐Ÿš€ EmmyLua Language Server Features Guide

ไธญๆ–‡ๆ–‡ๆกฃ

Comprehensive guide to the powerful features of EmmyLua Analyzer Rust

![Back to Main](https://img.shields.io/badge/โ† Back%20to%20Main-blue?style=for-the-badge)


๐Ÿ“‹ Table of Contents


๐ŸŽฏ Smart Completion

EmmyLua provides industry-leading intelligent code completion features, supporting not only basic function, variable, table field, and module completion, but also multiple innovative features.

๐Ÿ”ง Core Completion Features

๐Ÿš€ Auto Require

  • ๐ŸŽฏ Intelligently lists available Lua modules
  • โšก Automatically adds require statement on Tab press
  • ๐Ÿ“ Smart insertion at appropriate position in file header

๐Ÿท๏ธ Alias & Enum

  • ๐Ÿ” Smart completion based on parameter types
  • ๐Ÿ“ Support for alias and enum fields
  • ๐ŸŽฏ Context-aware precise completion

โšก Function Lambda

  • ๐Ÿ”ง Detects function type parameters
  • ๐Ÿ“‹ Automatically generates lambda expressions
  • ๐ŸŽจ Keeps code clean and elegant

๐Ÿ—๏ธ Namespace

  • ๐Ÿ—‚๏ธ Supports namespace completion
  • ๐Ÿ” Smart suggestions for sub-namespaces and class names
  • ๐Ÿ“– Use ---@type namespace<"ClassName">

๐Ÿ›ฃ๏ธ Path Completion System

FeatureDescriptionExample
๐Ÿ“ Module PathSmart completion for require parameters, supports . and / separatorsrequire("utils.string")
๐Ÿ’พ File SystemDetects path strings, provides file system completion"./config/settings.lua"

๐ŸŽช Advanced Completion Features

  • ๐Ÿ”ง Postfix: Type @ or . after variables to trigger expression completion
  • ๐Ÿ“ Snippet: Built-in code snippets, future support for custom template system

๐Ÿ’ก Tip: All completion features support fuzzy matching and smart sorting for a smoother coding experience.


๐Ÿ’ก Code Hints

Intelligent mouse hover hint system that provides rich contextual information and code insights.

โœจ Basic Hint Features

  • ๐Ÿ” Variable Information: Type, scope, definition location
  • โšก Function Signatures: Parameter types, return values, documentation comments
  • ๐Ÿ“Š Table Fields: Field types, access permissions, inheritance relationships
  • ๐Ÿ“ฆ Module Information: Export content, dependencies, version information

๐Ÿš€ Advanced Features

๐Ÿ”ข Constant Calculation

When variables are constant types, hover hints will display:

  • โœ… Constant Values: Directly show the actual value of variables
  • ๐Ÿงฎ Expression Calculation: Automatically calculate constant expression results
  • ๐Ÿ“Š Type Inference: Show precise types after calculation
local PI = 3.14159  -- Hover displays: const PI: number = 3.14159
local AREA = PI * 2 -- Hover displays: const AREA: number = 6.28318

๐Ÿ’ก Pro Tip: Constant calculation supports complex mathematical expressions and string operations, helping you better understand code logic.


๐Ÿ” Code Diagnostics

Powerful static analysis system based on EmmyLua annotations, helping you discover potential issues during coding and maintain code quality.

โš™๏ธ Diagnostic Control

๐Ÿ“ Comment Control

File-level Disable

---@diagnostic disable: undefined-global
-- Disable undefined-global check in entire file

Single-line Disable

---@diagnostic disable-next-line: undefined-global
-- Disable check only for next line

โš™๏ธ Configuration File Control

Fine-tune diagnostic behavior through configuration files:

{
  "diagnostics": {
    "disable": ["undefined-global", "unused"],
    "enable": [],
    "severity": {
      "undefined-global": "error",
      "unused": "warning"
    }
  }
}

๐Ÿ“Š Code Navigation

Powerful code navigation system that allows you to quickly locate and browse code in large projects.

๐Ÿ—‚๏ธ Document Symbols

๐Ÿ“‹ Structured View

Access through multiple ways in VS Code:

  • ๐Ÿ“Š OUTLINE Panel: Structured view in left sidebar
  • โŒจ๏ธ Shortcut: Ctrl+Shift+O to quickly open symbol list
  • ๐Ÿ” Real-time Filtering: Type keywords to quickly locate symbols
  • โŒจ๏ธ Shortcut: Ctrl+T
  • ๐Ÿ” Symbol Prefix: Type @ + symbol name
  • โšก Fuzzy Matching: Supports partial matching and abbreviations

๐Ÿš€ Smart Features

  • ๐Ÿ“Š Result Sorting: By relevance and usage frequency
  • ๐ŸŽฏ Type Filtering: Distinguish functions, variables, classes, etc.
  • ๐Ÿ“ Location Preview: Show definition location and context

๐Ÿ”— Code Navigation

๐ŸŽฏ Go to Definition

MethodOperationDescription
โŒจ๏ธ CommandGo to DefinitionStandard LSP navigation
๐Ÿ‘๏ธ PreviewPeek DefinitionPopup preview definition
๐Ÿ–ฑ๏ธ ClickCtrl + Left ClickQuick navigation

๐Ÿ”Ž Find References

๐Ÿ“ Standard Reference Finding

  • ๐Ÿ” Find All References: Find All References
  • ๐Ÿ–ฑ๏ธ Quick Find: Ctrl + Left Click

๐Ÿš€ Enhanced Reference Features

graph LR
    A[String References] --> B[Exact Matching]
    C[Fuzzy References] --> D[Smart Inference]
    E[Configuration Control] --> F[Optional Enable]
  • ๐Ÿ“ String References: Find usage locations of string literals
  • ๐ŸŽฏ Fuzzy References: Smart matching for undefined variables
  • โš™๏ธ Configuration Control: Control enable status through configuration files

๐Ÿ’ก Tip: Reference finding supports cross-file analysis and can accurately identify dependencies between modules.


๐Ÿ”„ Refactoring

Safe and efficient code refactoring tools to help you optimize code structure without breaking code logic.

๐Ÿท๏ธ Rename Refactoring

โŒจ๏ธ Quick Operations

  • Rename Shortcut: F2
  • Smart Detection: Automatically identify all related references
  • Cross-file Support: Support multi-file synchronous renaming

๐Ÿ›ก๏ธ Safety Mechanisms

FeatureDescription
๐Ÿ” Scope AnalysisPrecisely identify variable scope to avoid miss-renaming
๐Ÿ“ Cross-file DetectionDetect renaming impact on module imports/exports
โš ๏ธ Conflict DetectionProactively discover naming conflicts and provide suggestions
๐Ÿ“‹ Preview FeaturePreview all affected locations before renaming

๐ŸŽจ Code Formatting

Professional code formatting system based on EmmyLuaCodeStyle.

โœจ Formatting Features

๐Ÿ“„ Document Formatting

  • โŒจ๏ธ Format Document: Format entire file
  • ๐Ÿ”ง Auto Fix: Fix common formatting issues
  • โšก Incremental Formatting: Only format modified parts

๐ŸŽฏ Selection Formatting

  • โŒจ๏ธ Format Selection: Format selected region
  • ๐ŸŽจ Style Consistency: Maintain consistent code style
  • ๐Ÿ“ Smart Indentation: Automatically adjust indentation levels

๐Ÿ“‚ Code Folding

๐Ÿ—๏ธ Standard Folding

  • ๐Ÿ”ง Function Folding: function ... end
  • ๐Ÿ”€ Control Flow Folding: if, for, while, etc.
  • ๐Ÿ“Š Table Folding: Large table structure folding

๐ŸŽฏ Custom Folding

--region Custom Folding Region
-- Code to be folded here
local config = {
    -- Configuration items...
}
--endregion

๐Ÿ’ก Configuration Tip: For detailed formatting configuration options, please refer to EmmyLuaCodeStyle Documentation.


Intelligently identify and handle various links in code to improve development efficiency.

๐ŸŽจ Color Preview

๐ŸŒˆ Color Recognition

EmmyLua intelligently analyzes color values in strings and provides visual preview

๐Ÿ” Supported Formats

  • ๐ŸŽฏ Hexadecimal: #FF0000, #RGBA
  • ๐Ÿ“Š 6-digit Format: "FF0000"
  • ๐ŸŒŸ 8-digit Format: "FF0000FF"
  • โšก Auto Detection: Smart recognition of color strings

โœจ Visual Features

  • ๐ŸŸฅ Color Blocks: Display colors directly in code
  • ๐Ÿ–ฑ๏ธ Click to Edit: Click color block to open color picker
  • ๐Ÿ“‹ Real-time Preview: Update in real-time when modifying colors
  • ๐ŸŽจ Format Conversion: Support multiple color format conversions

๐Ÿ”— Smart Path Recognition

-- File paths automatically recognized as clickable links
local config_path = "./config/settings.lua"
local image_file = "./assets/images/logo.png"
FeatureDescriptionExample
๐Ÿ“‚ File OpeningClick path to directly open file"./utils/helper.lua"

โœจ Visual Enhancements

Multi-level visual enhancement features to make code clearer and more readable.

๐ŸŽจ Semantic Highlighting

๐ŸŒˆ Smart Syntax Coloring

Advanced syntax highlighting system based on LSP semanticHighlighting standard

๐ŸŽฏ Highlighting Features

๐Ÿ” Token Analysis

  • ๐Ÿ“ Variable Types: Distinguish local, global, parameter variables
  • โšก Function Recognition: Highlight function definitions and calls
  • ๐Ÿ“Š Keywords: Smart recognition of Lua keywords
  • ๐Ÿท๏ธ Comment Blocks: Special handling of documentation comments

๐ŸŽจ Visual Distinction

  • ๐Ÿ”ถ Type Identification: Different types use different colors
  • ๐Ÿ“ˆ Scope: Distinguish scope through color depth
  • โš ๏ธ Error Marking: Error code highlighted in red
  • ๐Ÿ’ก Suggestion Marking: Optimization suggestions in yellow

๐Ÿ–Š๏ธ EmmyLua Enhanced Rendering

๐ŸŽฏ Private Protocol Enhancement

Advanced code rendering features implemented through proprietary protocols:

local mutable_var = 10    -- Mutable variable: underlined
local const_value = 42    -- Constant: normal display

โœจ Enhancement Features

  • ๐Ÿ“ Mutable Variable Underline: Automatically underline mutable local variables
  • ๐ŸŽจ Type Coloring: Smart coloring based on type system
  • โšก Real-time Updates: Real-time rendering updates when code is modified

๐Ÿ’ก Inlay Hints

๐Ÿ“Š Smart Hint System

Display useful type and status information in code without mouse hovering

๐Ÿ”ง Hint Types

Hint TypeDescriptionExample
๐Ÿท๏ธ Parameter TypesShow function parameter type informationfunction(name: string)
๐Ÿ“Š Variable TypesShow inferred variable typeslocal count: number
๐Ÿ”„ Override MarkersMark overridden parent class methodsoverride function()
โšก Async CallsMark await async callsawait coroutine()

โš™๏ธ Configuration Control

{
  "inlayHints": {
    "enable": true,
    "paramHint": true,
    "indexHint": true,
    "localHint": false,
    "overrideHint": true
  }
}

๐ŸŽฏ Document Highlighting

๐Ÿ” Smart Highlighting Features

While editors provide basic highlighting, EmmyLua provides more precise highlighting support:

๐Ÿ“ Reference Highlighting

  • ๐ŸŽฏ Variable References: Highlight all uses of the same variable
  • ๐Ÿ”— Scope: Show effective scope of variables
  • โšก Real-time Tracking: Real-time updates when cursor moves

๐Ÿท๏ธ Keyword Groups

  • ๐Ÿ”— Paired Highlighting: if-then-end paired display
  • ๐Ÿ”„ Loop Blocks: for-do-end structure highlighting
  • ๐Ÿ“Š Conditional Blocks: if-elseif-else-end complete highlighting

๐ŸŒ Cross-Editor Support

Provide the same highlighting experience as VS Code for other editors, ensuring consistent development experience.


โฌ† Back to Top