trainz-language-server is a Language Server Protocol (LSP) implementation for the GS (Game Script) and AcsText
languages used in Trainz, written in Rust.
| development | release |
|---|---|
This language server provides rich editing support for Game Script (.gs) and AcsText (.txt) files, including:
- Syntax Highlighting: Enhanced semantic tokens for GS and AcsText.
- Diagnostics: Real-time error reporting and diagnostics.
- Code Completion: Context-aware completions for GS.
- Hover Information: Detailed information on symbols and variables.
- Go to Definition: Navigate through GS source code easily.
- Formatting: Automated code formatting for GS.
- Folding Ranges: Support for code folding in GS and AcsText.
- Symbol Indexing: Quick symbol lookup and navigation.
- AcsText Validation: Validation for AcsText files using the
acs_text-validatorscrate.
- Language: Rust (Edition 2024)
- Runtime:
tokio(Async runtime) - LSP Framework:
tower-lsp-server - Parser:
pest(Parser generator) - Serialization:
serde/serde_json/bson - CLI:
clap
- Rust Toolchain: Install Rust.
- Cargo: Usually installed with Rust.
To build the project in release mode:
cargo build --releaseThe compiled binary will be located at target/release/trainz-language-server.
To run the LSP server:
./target/release/language-server-v, --verbose: Increase logging verbosity (use multiple-vfor higher verbosity).-q, --quiet: Decrease logging verbosity.-p, --validation-path <PATH>: Path to the directory containing acs_text validators. Can also be set via theTRAINZ_LANGUAGE_SERVER_ACS_TEXT_VALIDATION_PATHenvironment variable.-s, --search-paths <PATHS>: Semicolon-separated list of paths to search for Trainz scripts. Can also be set via theTRAINZ_LANGUAGE_SERVER_SCRIPT_SEARCH_PATHSenvironment variable.-h, --help: Print help.-V, --version: Print version information.
The project includes extensions for various editors in the extensions/ directory:
- Visual Studio Code: Located in
extensions/vscode. Requires setting thetrainz-language-server.serverPathto the builttrainz-language-serverbinary. - IntelliJ IDEA: Located in
extensions/trainz-idea.
The workspace is organized into several crates:
crates/ast: Abstract Syntax Tree definitions.crates/common: Common types and utilities.crates/parser: GS and AcsText grammar parsing usingpest.crates/trainz-language-server: LSP server implementation.crates/diagnostics: Diagnostics and error reporting.crates/formatter: Code formatting logic.crates/formatter-cli: CLI tool for the formatter.crates/semantic-tokens: Semantic highlighting support.crates/symboliser: Symbol indexing and lookup.crates/completions: Code completion logic.crates/folding: Folding range support.crates/hover: Hover information support.crates/definition: Goto definition support.crates/signature-help: Signature help support.crates/acs_text-validators: Validation for AcsText files.crates/util: General utilities.
The scripts/ directory contains helper scripts for development and release management:
- scripts/create-commit.sh: Helper for creating conventional commit messages
- scripts/commit-agent.sh: Automated commit script with quality checks
- scripts/update-crate-version.js: Update a specific crate's version and its workspace dependency version
- scripts/update-extension-version.js: Update a specific extension's version
- scripts/update-root-versions.js: Update the root project version in package.json and Cargo.toml
See scripts/README.md for detailed usage instructions.
- Build:
cargo build - Test:
cargo test - Check:
cargo check - Format:
cargo fmt - Lint:
cargo clippy
Refer to AGENTS.md for more details on contributing and project guidelines.
This project is part of the trainz-language-server effort.