CryLint
A Smart Async Diagnostic Bridge (Semi-LSP) for Crystal in Micro Editor
CryLint (Crystal Linter) is a specialized "Semi-LSP" or Smart Background Linter
built from scratch. It solves the massive compatibility and performance issues
between Micro Editor and full-blown
Crystal LSPs like crystalline.
Unlike traditional LSPs that offer autocompletion and go-to definitions, CryLint focuses strictly on hyper-fast, non-blocking diagnostics and formatting, purposefully tailored for terminal editor - Micro that don't always need heavy IDE features.
Micro Editor's implementation of LSP textDocumentSync often struggles with
incremental updates or heavy RAM-caching LSPs. This previously forced developers
to press Ctrl+S manually to trigger diagnostics, completely breaking the flow
of programming.
The CryLint Solution: We built a smart diagnostic bridge adopting a
Dual-Mode Async Architecture (similar to rust-analyzer's background
checking), communicating via the LSP protocol but acting as a pure, focused
linter.
How It Works (Dual-Mode Async)
CryLint separates linting into two distinct phases to guarantee that your editor never freezes:
- Instant Syntax Checking (In-Memory): Every time you type, CryLint uses
the native
Crystal::Parserto parse your code directly in memory. This happens in microseconds. If you forget a closing bracket or type an extraend, Micro will highlight it instantly. - Background Semantic Checking (Async): If the syntax is valid, CryLint
spawns an asynchronous background thread that executes
crystal build --no-codegen -f json. This checks for deep semantic errors (likeundefined methodor type mismatches). Because it runs in the background, your editor remains buttery smooth. Once the compiler finishes (usually 2-5 seconds for large projects), the semantic red lines are pushed to the editor automatically.
Bottom line: You get instant syntax feedback and accurate semantic feedback
without ever pressing Ctrl+S and without your editor freezing!
Dependencies
- Crystal Compiler (
crystalcommand must be in your PATH). - Ameba Shard (Used as the core engine for static analysis).
Key Features (Triple-Engine Architecture)
- Instant Syntax Engine: Real-time feedback as you type, with zero delay.
- Background Semantic Engine: Checks deep compilation errors asynchronously in the background.
- Custom Diff-Formatting Engine: Mathematically analyzes indentation and spacing accuracy to ensure your code strictly adheres to Crystal's native formatting standards.
Installation
Method 1: Automatic via Bash Script (Easiest)
Run this command in your terminal (ensure Git and the Crystal compiler are installed on your system):
curl -sSL https://codeberg.org/0xgausk/crylint/raw/branch/main/install.sh | bash
Method 2: Manual Clone & Compile
If you prefer to build it yourself from source:
git clone https://codeberg.org/0xgausk/crylint.git
cd crylint
shards install
crystal build --release src/crylint.cr -o crylint
mkdir -p ~/.local/bin
mv crylint ~/.local/bin/crylint
Configuration in Micro Editor
To activate CryLint in Micro, ensure the lsp plugin is enabled, then open
settings.json (usually located at ~/.config/micro/settings.json), and append
the path to crylint in your lsp.server list:
{
"lsp.server": "...,crystal=crylint"
}
(Note: make sure ~/.local/bin is in your system's PATH, or use an absolute
path, for example: crystal=/home/username/.local/bin/crylint)
🛠Debugging & Logging
CryLint features an internal logger. All communication between the editor (via JSON-RPC) and LSP responses, along with any internal errors, are automatically recorded.
Log files are automatically stored in the following priority order:
- If you open a file inside a Crystal project (detected via
shard.ymlor.git), logs are saved to:.crylint_logs/crylint.logat the project root. - If you open a standalone script (e.g., in your home directory without a
shard.yml), logs will safely fallback to:/tmp/crylint_logs/crylint.log.
You can monitor the logs by running:
# Inside a project:
tail -f .crylint_logs/crylint.log
# For standalone scripts:
tail -f /tmp/crylint_logs/crylint.log
This is highly useful for anyone who forks this project and wants to debug compilation delays, error messages, or the behavior of Crystal's native Type Inference.
Specifically designed for a comfortable Crystal programming experience in the Terminal.