Lem is a text editor written in Common Lisp with multiple frontend support (terminal, GUI, browser).
# Build and run
make sdl2 # GUI version
make ncurses # Terminal version
# Development
qlot install # Install dependencies
make test # Run testssrc/ # Core editor
├── lem.lisp # Entry point
├── buffer/ # Text buffer system
├── window/ # Window management
├── mode.lisp # Mode system
├── keymap.lisp # Key bindings
├── defcommand.lisp # Command definition
└── interface.lisp # Frontend abstraction
frontends/ # UI implementations
├── sdl2/ # Desktop GUI
├── ncurses/ # Terminal
└── webview/ # Browser-based
extensions/ # Language modes (50+)
├── lisp-mode/ # Common Lisp with REPL
├── lsp-mode/ # LSP client
└── vi-mode/ # Vim emulation
Four-layer design: Frontends → Interface (lem-if:*) → Core → Extensions
Key abstractions:
- Buffer: Text storage with points, marks, undo history
- Window: Buffer display, organized in tree (splits) or floating
- Mode: Major (one per buffer) + Minor (multiple, toggleable)
- Command: Interactive operation via
define-command
This project uses code-contractor for automated PR review. code-contractor is a GitHub App that validates pull requests against rules defined in contract.yml.
All coding standards are defined in contract.yml at the repository root. Refer to it for:
- Package and file structure rules
- Documentation requirements
- Style conventions (loop syntax, error handling, etc.)
- Functional programming guidelines
| Task | Files |
|---|---|
| Add command | src/defcommand.lisp for macro, src/commands/ for examples |
| Add mode | extensions/ for examples, inherit language-mode |
| Add frontend | src/interface.lisp for protocol, frontends/ for impl |
| Buffer ops | src/buffer/internal/buffer.lisp, src/buffer/internal/edit.lisp |
| Window ops | src/window/window.lisp |
- Use
lem-corepackage symbols, avoidlem::internal access - Frontends implement
lem-if:*generic functions - Modes register via
define-major-mode/define-minor-mode - Commands register via
define-commandwith argument descriptors
User config locations (in order):
$LEM_HOME/init.lisp~/.config/lem/init.lisp~/.lem/init.lisp~/.lemrc
- Architecture details:
docs/ARCHITECTURE.md - Extension development:
docs/extension-development.md - Online docs: https://lem-project.github.io/
- 001-multi-language-canvas: Added Common Lisp (SBCL), tree-sitter-cl FFI bindings + lem/core, tree-sitter-cl, lem-call-graph (existing), lem-tree-sitter
- 001-multi-language-canvas: Added [if applicable, e.g., PostgreSQL, CoreData, files or N/A]
- Common Lisp (SBCL), tree-sitter-cl FFI bindings + lem/core, tree-sitter-cl, lem-call-graph (existing), lem-tree-sitter (001-multi-language-canvas)
- N/A (in-memory graph structures, optional position caching) (001-multi-language-canvas)