MCPcopy Index your code
hub / github.com/EmmyLuaLs/emmylua-analyzer-rust

github.com/EmmyLuaLs/emmylua-analyzer-rust @0.23.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.23.2 ↗ · + Follow
7,201 symbols 28,107 edges 683 files 307 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

EmmyLua Analyzer Rust

A high-performance Lua language server, linter, and documentation generator — built with Rust.

GitHub stars License Release Crates.io

Quick Start · Features · Documentation · Development


Why EmmyLua Analyzer Rust?

  • Fast — Incremental analysis powered by Rust; handles large codebases with ease
  • Complete — Supports Lua 5.1 – 5.5 and LuaJIT, with EmmyLua & Luacats annotations
  • Universal — Standard LSP protocol works with VS Code, Neovim, IntelliJ, and any LSP-compatible editor
  • All-in-one — Language server, code formatter, static analyzer, and doc generator in a single toolchain

Quick Start

Install

# Via Cargo
cargo install emmylua_ls          # Language server
cargo install emmylua_check       # Static analyzer / linter
cargo install emmylua_doc_cli     # Documentation generator

Or download pre-built binaries from the Releases page.

Editor Setup

Before connecting your editor:

  1. Install emmylua_ls and make sure it is available in PATH, or use an absolute binary path in your LSP client.
  2. Add a project config file such as .emmyrc.json or .luarc.json.
  3. Restart the language server after changing global editor or workspace configuration.

See the Configuration Guide for all supported options.

VS Code

Recommended setup:

  1. Install the EmmyLua Extension.
  2. Open a Lua workspace.
  3. Add .emmyrc.json at the project root if you need custom runtime, diagnostics, or library paths.

This is the easiest way to get completion, diagnostics, hover, formatting, semantic tokens, and project indexing with minimal manual setup.

Neovim

Neovim 0.11+ example:

vim.lsp.config("emmylua_ls", {
    cmd = { "emmylua_ls" },
    filetypes = { "lua" },
    root_markers = { ".emmyrc.json", ".luarc.json", ".git" },
})

vim.lsp.enable("emmylua_ls")

If you manage servers manually, replace cmd with the full path to your binary.

IntelliJ IDE

Install the EmmyLua2 Plugin from the JetBrains Marketplace.

For most projects, no extra setup is required beyond opening the workspace. Add .emmyrc.json if you need custom workspace roots, library paths, or stricter diagnostics.

Other editors

Any editor with LSP support can use emmylua_ls over stdio, which is the default and recommended mode.

Typical client command:

{
    "command": "emmylua_ls",
    "args": []
}

Use TCP only when you explicitly want a remote or debug-friendly setup:

emmylua_ls -c tcp --ip 127.0.0.1 --port 5007

Useful client root markers:

  • .emmyrc.json
  • .luarc.json
  • .emmyrc.lua
  • .git

Features

Language Support

Version Status
Lua 5.1 ✅ Full support
Lua 5.2 ✅ Full support
Lua 5.3 ✅ Integer types, UTF-8
Lua 5.4 ✅ Attributes, generational GC
Lua 5.5 ✅ New global syntax
LuaJIT ✅ FFI, bit operations

LSP Capabilities

Area Capabilities
Navigation Go to Definition, Go to Implementation, Find References, Call Hierarchy, Document Highlights
Symbols Document Symbols, Workspace Symbols, Selection Range
Editing Completion, Rename, Code Actions, Document Formatting, Range Formatting, On-type Formatting
Insight Hover, Signature Help, Diagnostics, Semantic Tokens, Inlay Hints, Code Lens, Document Color
Structure Folding Range, Document Links

In practice, this gives you a full day-to-day Lua editing workflow: symbol navigation, annotation-aware type feedback, project-wide references, incremental diagnostics, and formatting support in editors that expose standard LSP features.

Code Quality

  • Static analysis with 40+ diagnostic rules
  • Code formatting and style enforcement
  • EmmyLua / Luacats annotation support

Usage

Language Server

# Default stdio mode
emmylua_ls

# TCP mode for remote debugging
emmylua_ls -c tcp --port 5007 --log-level debug --log-path ./logs
Parameter Description
-c, --communication stdio (default) or tcp
--port TCP port (default: 5007)
--log-level debug / info / warn / error
--log-path Log output directory

Static Analyzer

emmylua_check .                           # Analyze current directory
emmylua_check ./src --verbose --format json  # Detailed JSON output

Documentation Generator

emmylua_doc_cli ./src --output ./docs

Documentation


Development

Build from Source

git clone https://github.com/EmmyLuaLs/emmylua-analyzer-rust.git
cd emmylua-analyzer-rust

cargo build --release              # Build everything
cargo build --release -p emmylua_ls   # Build only the language server

Test

cargo test                      # Run all tests
cargo test -p emmylua_parser    # Run parser tests only

Contributing

We welcome contributions! See CONTRIBUTING.md for details.


License

MIT


Thanks to all contributors and the Lua community.

Back to top

Extension points exported contracts — how you extend this code

RegisterCapabilities (Interface)
(no doc) [28 implementers]
crates/emmylua_ls/src/handlers/mod.rs
LuaAstNode (Interface)
(no doc) [114 implementers]
crates/emmylua_parser/src/syntax/traits/mod.rs
Checker (Interface)
(no doc) [42 implementers]
crates/emmylua_code_analysis/src/diagnostic/checker/mod.rs
LuaDescParser (Interface)
Parses markup in comments. [2 implementers]
crates/emmylua_parser_desc/src/lib.rs
OutputWriter (Interface)
(no doc) [3 implementers]
crates/emmylua_check/src/output/mod.rs
CompletionProvider (Interface)
(no doc) [14 implementers]
crates/emmylua_ls/src/handlers/completion/providers/mod.rs
LuaAstToken (Interface)
(no doc) [18 implementers]
crates/emmylua_parser/src/syntax/traits/mod.rs
LuaIndex (Interface)
(no doc) [15 implementers]
crates/emmylua_code_analysis/src/db_index/traits.rs

Core symbols most depended-on inside this repo

push
called by 768
crates/emmylua_ls/src/handlers/fold_range/builder.rs
bump
called by 734
crates/emmylua_parser/src/text/reader.rs
iter
called by 723
crates/emmylua_code_analysis/src/db_index/type/basic_union.rs
len
called by 654
crates/emmylua_code_analysis/src/db_index/type/types/complex.rs
def
called by 449
crates/emmylua_code_analysis/src/test_lib/mod.rs
syntax
called by 423
crates/emmylua_parser/src/syntax/node/mod.rs
push
called by 419
crates/emmylua_code_analysis/src/diagnostic/checker/code_style/preferred_local_alias.rs
insert
called by 365
crates/emmylua_code_analysis/src/diagnostic/checker/code_style/preferred_local_alias.rs

Shape

Function 4,142
Method 2,181
Class 641
Enum 217
Interface 20

Languages

Rust100%

Modules by API surface

crates/emmylua_code_analysis/src/compilation/test/flow.rs139 symbols
crates/emmylua_formatter/src/formatter/expr.rs135 symbols
crates/emmylua_formatter/src/test/comment_tests.rs117 symbols
crates/emmylua_formatter/src/test/statement_tests.rs109 symbols
crates/emmylua_formatter/src/test/expression_tests.rs91 symbols
crates/emmylua_code_analysis/src/db_index/type/types/complex.rs83 symbols
crates/emmylua_ls/src/handlers/initialized/std_i18n.rs77 symbols
crates/emmylua_parser/src/syntax/node/doc/tag.rs75 symbols
crates/emmylua_code_analysis/src/diagnostic/test/param_type_check_test.rs66 symbols
crates/emmylua_parser/src/grammar/doc/test.rs64 symbols
crates/emmylua_code_analysis/src/compilation/test/generic_test.rs61 symbols
crates/emmylua_formatter/src/formatter/render/doc_comments.rs54 symbols

For agents

$ claude mcp add emmylua-analyzer-rust \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact