How felix-andreas/roughly works
Project type and purpose
• From the README and file tree, we see “Roughly” is an open-source CLI tool and R language server written in Rust, with a complementary VS Code extension (TypeScript) and a documentation site (Astro + Tailwind). Its core functions are formatting, linting, diagnostics, completions, indexing, and LSP-based editor integration.
File structure
• Top level:
• Cargo.toml / src/…: Rust code for CLI subcommands (fmt, check, server) and two LSP server implementations (server_async_lsp.rs, server_tower_lsp.rs).
• client/: VS Code extension in TypeScript—extension.ts, package.json, images.
• docs/: Static documentation site built with Astro/Tailwind—source in docs/src, content in docs/content.
• scripts/: Build‐helper scripts (e.g., get_node_types.py).
• tests/: Snapshot and integration tests for formatting and indexing.
• Patterns:
• CLI entrypoint (main.rs) delegates to submodules (format.rs, diagnostics.rs, completions.rs, etc.).
• LSP servers implement the Language Server Protocol over JSON-RPC.
• VS Code extension spawns the CLI/LSP binary and connects via stdio.
README for additional insights
• Key features: formatter, linter, diagnostics, completions, indexing.
• Installation & usage: CLI commands and VS Code extension settings.
• Architecture hints: bundled CLI in extension, ability to pass custom args, nightly Rust requirement.
a. Main components
• Roughly CLI binary (Rust)
– Formatter module
– Linter/Diagnostics module
– Indexer & Completion module
– Config loader
• LSP Server (Rust)
– Async LSP (tower-lsp)
– JSON-RPC transport
• VS Code Extension (TypeScript)
– Language client (vscode-languageclient)
– Commands & settings
• Documentation Site (Astro + Tailwind) – optional for runtime
• Tests & CI (snapshot tests, justfile, flake.nix)
b. Relationships & interactions
• VS Code Extension ←→ LSP Server via stdin/stdout (JSON-RPC)
• CLI “fmt”/“check” subcommands invoke Rust modules directly
• LSP Server calls same Rust modules under the hood for formatting, diagnostics, completions
• Tests import modules or run CLI commands and compare snapshots
• Documentation site reads configuration/content but does not interact at runtime
c. Architectural patterns & principles
• Modular Rust code: single binary with subcommand pattern (structopt/clap)
• LSP design: separation between protocol layer and core logic
• Extension-client pattern: thin client that delegates work to a robust backend
• Reproducible builds via Nix (flake.nix) and justfile
d. Key technologies
• Rust + clap/structopt, tower-lsp, serde_json
• TypeScript + VS Code extension API, bun/npm
• Astro, Tailwind CSS for docs
• Nix, just, Python build scripts
Final advice
• Don’t omit the dual role of the binary (standalone CLI vs. LSP server)
• Extension settings and bundling step (bun run package)
• Detail how tests hook into the formatter module for snapshot testing