Skip to main content

Overview

Rode stores your editor preferences in a Lua configuration file located at ~/.config/rode/preferences.lua. This file controls core editor behavior like indentation, tab handling, and theme selection.

Configuration File

Preferences are configured using a simple Lua table format. The configuration file is automatically created with default values when you first launch Rode.
-- Rode Editor Preferences
-- Edit these values to customize your editor

return {
    tab_size = 4,
    use_spaces = true,
    theme_name = "default",
}

Available Preferences

tab_size

tab_size
number
default:"4"
The number of spaces to use for indentation. This value is clamped between 1 and 16.Source: src/config/preferences.rs:66-68
The parser enforces a minimum of 1 and maximum of 16:
"tab_size" => {
    if let Ok(size) = value.parse::<usize>() {
        prefs.tab_size = size.max(1).min(16);
    }
}

use_spaces

use_spaces
boolean
default:"true"
When true, the editor inserts spaces when you press Tab. When false, the editor inserts tab characters (\t).Source: src/config/preferences.rs:70-72The indent unit is calculated based on this setting:
pub fn indent_unit(&self) -> String {
    if self.use_spaces {
        " ".repeat(self.tab_size)
    } else {
        "\t".to_string()
    }
}

theme_name

theme_name
string
default:"default"
The name of the theme to use. Can be any built-in theme name or "Custom (theme.lua)" to load a custom theme from ~/.config/rode/theme.lua.Source: src/config/preferences.rs:73-75Available built-in themes:
  • "Catppuccin Mocha" (default)
  • "Gruvbox Dark"
  • "GitHub Dark"
  • "Nord"
  • "TokyoNight"
  • "Ayu Dark"
  • "Custom (theme.lua)"
See Themes for more details on customizing colors.

File Location

The preferences file is located at:
~/.config/rode/preferences.lua
The configuration directory is determined by the HOME environment variable:
pub fn get_config_dir() -> PathBuf {
    let home = std::env::var("HOME").unwrap_or_else(|_| ".".to_string());
    PathBuf::from(home).join(".config").join("rode")
}
Source: src/config/theme_manager.rs:165-168

Loading Behavior

Rode automatically loads preferences on startup. If the configuration file doesn’t exist, default values are used:
pub fn load_preferences() -> EditorPreferences {
    let path = get_preferences_path();
    if let Ok(content) = fs::read_to_string(&path) {
        parse_preferences(&content)
    } else {
        EditorPreferences::default()
    }
}
Source: src/config/preferences.rs:41-48 and src/config/preferences.rs:13-21

Parser Details

The Lua configuration parser is simple and robust:
  • Empty lines and lines starting with -- are treated as comments
  • Lines containing return { or } are ignored
  • Key-value pairs are parsed as key = value
  • Values are automatically trimmed of quotes, commas, and whitespace
fn parse_preferences(content: &str) -> EditorPreferences {
    let mut prefs = EditorPreferences::default();
    for line in content.lines() {
        let line = line.trim();
        if line.is_empty() || line.starts_with("--") || line == "return {" || line == "}" {
            continue;
        }
        if let Some((key, value)) = line.split_once('=') {
            let key = key.trim();
            let value = value
                .trim()
                .trim_end_matches(',')
                .trim_matches('"')
                .trim_matches('\'');
            match key {
                "tab_size" => {
                    if let Ok(size) = value.parse::<usize>() {
                        prefs.tab_size = size.max(1).min(16);
                    }
                }
                "use_spaces" => {
                    prefs.use_spaces = value == "true";
                }
                "theme_name" => {
                    prefs.theme_name = value.to_string();
                }
                _ => {}
            }
        }
    }
    prefs
}
Source: src/config/preferences.rs:50-81

Examples

Minimal Configuration

return {
    tab_size = 2,
    use_spaces = true,
    theme_name = "Nord",
}

Tab-based Indentation

return {
    tab_size = 4,
    use_spaces = false,
    theme_name = "GitHub Dark",
}

Custom Theme

return {
    tab_size = 4,
    use_spaces = true,
    theme_name = "Custom (theme.lua)",
}

Wide Indentation

return {
    tab_size = 8,
    use_spaces = true,
    theme_name = "Catppuccin Mocha",
}

Themes

Customize editor colors and syntax highlighting

Keybindings

Learn about keyboard shortcuts