Getting Started
Before contributing, please:- Read through the building guide to set up your development environment
- Familiarize yourself with the architecture of the project
- Check existing issues and pull requests
Development Workflow
Make your changes
Implement your feature or bug fix. Make sure to:
- Follow the coding standards
- Add tests for new functionality
- Update documentation as needed
Testing
EmmyLua Analyzer uses the standard Rust testing harness along with assert macros from googletest-rust.Running Tests
Writing Tests
The project usesgoogletest-rust for assertions. Here are the key concepts:
Basic Test Structure
Use#[gtest] annotation for test functions:
Assert Macros
assert_that!
assert_that!
Checks a condition and panics on error:Prefer
assert_that!(x, eq(y)) over assert_eq! because it generates better error messages with diffs.expect_that!
expect_that!
Checks a condition, marks the test as failed on error, but continues execution:This is useful when testing multiple cases in a single test function.
verify_that!
verify_that!
Checks a condition and returns a
googletest::Result:OrFail Extension
TheOrFail::or_fail extension converts Optional and Result to googletest::Result and adds location information:
check! for this pattern.
Testing Requirements
When contributing:- Add tests for new features: All new functionality should include appropriate tests
- Maintain existing tests: Don’t break existing tests without good reason
- Test edge cases: Consider boundary conditions and error cases
- Use descriptive test names: Test names should clearly indicate what they’re testing
Code Style and Formatting
EmmyLua Analyzer uses automated tools to maintain consistent code style.rustfmt
rustfmt formats all Rust code. Run it before committing:
rustfmt configuration.
pre-commit
pre-commit fixes common issues in all text files, including:
- Trailing whitespace
- Missing newlines at end of files
- Broken symlinks
- Large files accidentally committed
Install pre-commit
Install the pre-commit tool:
Clippy
The project uses Clippy for linting with workspace-level configuration. Review the lints before committing:Cargo.toml for details.
Coding Standards
General Guidelines
- Write idiomatic Rust: Follow Rust best practices and conventions
- Document public APIs: Add doc comments for public functions, types, and modules
- Handle errors properly: Use
Resulttypes and provide meaningful error messages - Avoid unsafe code: Only use
unsafewhen absolutely necessary and document why
Project-Specific Patterns
The workspace lint configuration allows certain patterns common in parser and LSP projects:- Module inception: Acceptable for AST/syntax organization
- Enum variant names: Repetition is allowed for syntax tree clarity
- High complexity: Domain-specific logic may have higher cognitive complexity
- Many arguments: Builder patterns and comprehensive APIs may need many parameters
Cargo.toml workspace lints for the complete list.
Pull Request Process
Before Submitting
PR Description
Your pull request should include:- Clear title: Summarize the change in one line
- Description: Explain what changes you made and why
- Related issues: Link to any related issues
- Testing: Describe how you tested your changes
- Breaking changes: Note any breaking changes and migration steps
Review Process
After submitting your PR:- CI checks: Automated checks will run on your PR
- Code review: Maintainers will review your code
- Feedback: Address any requested changes
- Approval: Once approved, your PR will be merged
Project Structure
EmmyLua Analyzer is organized as a Cargo workspace with multiple crates:| Crate | Description |
|---|---|
| emmylua_parser | Core Lua parser for maximum efficiency and accuracy |
| emmylua_parser_desc | Markdown/RST highlighting in comments |
| emmylua_code_analysis | Semantic analysis engine with type inference |
| emmylua_ls | Language Server Protocol implementation |
| emmylua_doc_cli | Documentation generator |
| emmylua_check | Static analysis tool |
| emmylua_code_style | Code formatting and style |
| emmylua_diagnostic_macro | Diagnostic generation macros |
| schema_to_emmylua | Schema conversion utilities |
Getting Help
If you need assistance:- Issues: Check existing issues or open a new one
- Discussions: Use GitHub Discussions for questions
- Documentation: Review the project documentation
Next Steps
Build from Source
Set up your development environment
Architecture
Understand the codebase structure
