Rust core · Ruby commands · Terminal
Rust keeps your text safe. Ruby makes the editor yours.
A text editor with a programmable Ruby layer for defining commands, customizing keybindings, and extending or replacing built-in functionality.
01
Architecture
Ruby never holds the text. A command reads a bounded view from the Rust core and returns a change; the core checks it and publishes it, or rejects it whole.
- Rust core
- Keeps the text as immutable snapshots and owns every revision. Ruby reads a snapshot, never the live buffer.
- Ruby runtime
- Embedded CRuby 3.4. A command can make as many edits as it needs; they land together as one change, or not at all.
- Terminal
- The first frontend. It redraws only what changed.
02
Commands are Ruby files
A command is a Ruby callable registered by name. A keymap binds it to keys for one interaction profile. This file wraps the current line in brackets and binds it to Control-b.
module Rur::UserCommands
def self.surround_current_line(context)
line = context.current_line
context.replace(line.merge('replacement' => "[#{line.fetch('text')}]"))
end
end
configuration = Rur.configuration
configuration.command('surround-current-line',
Rur::UserCommands.method(:surround_current_line), {
'description' => 'Surround the current logical line with brackets',
'kind' => 'compound', 'requires' => 'view',
'effects' => ['text', 'selection']
})
configuration.keymap('user-editing', {
'profile' => 'nonmodal', 'states' => 'editing',
'class' => 'user', 'priority' => 10
})
configuration.bind('user-editing', ['control-b'], 'surround-current-line')
- Reload in place. Edit the file and run
reload-configuration. If it has an error, the last working version stays. - Inspectable.
describe-keyshows which binding wins and where it was declared.
03
What it does
Everything below is a command, so you can move it to another key, see where it comes from, or replace it with your own Ruby.
- Editing
- Edit without modes, or switch to Normal and Insert if your hands already know Vim. Both are just keymaps, so you can build a third.
- Files and buffers
- Open, switch and save local files. Mark buffers in the buffer list and save or close them in one go.
- Search
- Search and replace with plain text or regular expressions, across one buffer or a whole project.
- Version control
- Inspect Git status and history, stage files or hunks, commit, and work with branches and conflicts.
- Structured documents
- Outlines, tables, tasks, agendas, source blocks and export.
- Language support
- Ruby, Rust, Go, TypeScript, JavaScript, HTML and CSS. Syntax works without a language server; a configured server adds completion, diagnostics, navigation and formatting.
- Programming
- Write commands in Ruby, find them with Alt-x and bind them to keys.
describe-keyanddescribe-commandshow what runs and where it was declared. - Packages
- Install packages from catalogs, choose their permissions, and enable, update or roll them back.
04
Build it
Build from source with Rust 1.98, CRuby 3.4 with its headers and shared library, a C compiler, libclang and Make. No gems are needed.
$ git clone https://forge.adrianpk.com/rur/rur.git
$ cd rur
$ make run
Opens the editor with the example from above loaded. Try Control-b. Control-q exits.