Skip to main content
This guide walks you through building EmmyLua Analyzer from source, including setting up your development environment and building specific components.

Prerequisites

Before building EmmyLua Analyzer, ensure you have the Rust toolchain installed on your system.

Installing Rust

If you don’t have Rust installed, use rustup to install the latest stable version:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After installation, verify your Rust installation:
rustc --version
cargo --version

Building the Project

1

Clone the repository

Clone the EmmyLua Analyzer repository from GitHub:
git clone https://github.com/EmmyLuaLs/emmylua-analyzer-rust.git
cd emmylua-analyzer-rust
2

Build all crates

Build all workspace crates in release mode for optimal performance:
cargo build --release
This will compile all crates in the workspace and place the binaries in target/release/.
3

Verify the build

After building, you can find the executables in the target/release/ directory:
ls -lh target/release/emmylua_*

Building Specific Components

You can build individual components instead of the entire workspace:

Language Server

Build just the language server executable:
cargo build --release -p emmylua_ls
The binary will be available at target/release/emmylua_ls.

Documentation Generator

Build the documentation CLI tool:
cargo build --release -p emmylua_doc_cli

Static Analyzer

Build the static analysis tool:
cargo build --release -p emmylua_check

Parser Library

Build just the parser library:
cargo build --release -p emmylua_parser

Development Build

For faster compilation during development, you can omit the --release flag:
cargo build
Development builds are significantly faster but produce unoptimized binaries. Use them for testing and debugging.

Running Tests

1

Run all tests

Execute the full test suite across all crates:
cargo test
2

Run tests for a specific crate

Test individual components:
# Test the parser
cargo test -p emmylua_parser

# Test code analysis
cargo test -p emmylua_code_analysis

# Test the language server
cargo test -p emmylua_ls
3

Run tests with coverage

For comprehensive test coverage:
cargo test --all-features --no-fail-fast

Development Setup

Code Formatting

EmmyLua Analyzer uses rustfmt for code formatting. Format all code before committing:
cargo fmt --all

Pre-commit Hooks

The project uses pre-commit to ensure code quality:
1

Install pre-commit

Install the pre-commit tool:
# Using pip
pip install pre-commit

# Or using your package manager
brew install pre-commit  # macOS
2

Run pre-commit checks

Manually run all pre-commit hooks:
pre-commit run --all
3

Install git hooks (optional)

Set up automatic pre-commit checks:
pre-commit install
This will run checks automatically before each commit.

Linting

The project uses Clippy for linting. Run the linter:
cargo clippy --all-targets --all-features

Troubleshooting

Build Failures

If you encounter build errors:
  1. Update Rust toolchain: Ensure you’re using a recent stable version
    rustup update stable
    
  2. Clean build artifacts: Remove cached builds and start fresh
    cargo clean
    cargo build --release
    
  3. Check dependencies: Verify all system dependencies are installed

Test Failures

If tests fail:
  1. Run with verbose output:
    cargo test -- --nocapture
    
  2. Run a specific test:
    cargo test test_name -- --exact
    

Next Steps

Contributing Guide

Learn how to contribute to the project

Architecture Overview

Understand the codebase structure

Build docs developers (and LLMs) love