How mechamobau/edithor works
Project Type and Purpose
• Edithor is a terminal‐based text editor (open-source tool), written in Rust.
• It provides Vim-inspired modal editing, LSP integration, plugin support, and high performance.
File Structure
• src/main.rs: program entrypoint, argument parsing, initialization
• src/editor.rs: core editor logic (buffer management, key mappings, rendering loop)
• Cargo.toml / Cargo.lock: dependency declarations (e.g., crossterm, tower-lsp)
• Repo metadata (README, CONTRIBUTING, LICENSE, etc.)
README for Additional Insights
• Key features: Vim keybindings, LSP for syntax highlighting, plugin architecture, configurability
• Usage model: CLI (“edithor <filename>”), modes (insert, normal), commands
Main Components
a. CLI / Launcher
– Parses command-line args, locates config file, and passes entry file to the Editor Core.
b. Configuration Loader
– Reads user config (keybindings, theme, plugin list) on startup.
c. Editor Core (Editor Module)
– Buffer Manager: holds text, tracks cursor, undo/redo.
– Keybinding / Command Handler: maps keystrokes to actions (insert, delete, save).
d. File I/O
– Reads/writes the document from disk, signals Editor Core on saves/loads.
e. LSP Client Integration
– Runs an LSP client over stdin/stdout or TCP, forwards buffer contents to the language server, receives syntax highlights, diagnostics.
f. Plugin Manager
– Loads and communicates with plugins (via dynamic libraries or external processes), extends commands or language supports.
g. External Services
– Language Servers (e.g., rust-analyzer) over LSP protocol.
Relationships & Data Flows
– User Input → Keybinding Handler → Editor Core
– Editor Core → Buffer Manager & Command Executor → Rendering Engine → Terminal
– Editor Core ↔ LSP Client → Language Server
– Editor Core ↔ File I/O → Disk
– Startup: CLI → Configuration Loader → Plugin Manager → Editor Core
Architectural Patterns & Principles
– Separation of Concerns: distinct modules for input, state, rendering, external comms
– Plugin Architecture: clearly defined extension points
– Event-driven Loop: editor loop processes input events and redraws
– Client-Server for LSP: standard protocol over IPC
Final Checklist
– All major modules from src/ (main.rs, editor.rs).
– Config loader and plugin manager.
– File I/O and disk interactions.
– LSP Client ↔ Language Server.
– Callouts for key crates or protocols (Rust, LSP).