Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sllama"
version = "0.1.11"
version = "0.1.12"
edition = "2024"

[dependencies]
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.12 - 2025-06-14

_Add support for rustyline completion type (circular and list)_

## 0.1.11 - 2025-06-14

_Switch to Ollama API instead of run commands_
Expand Down
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ You can tell where you have previously responded by --- AI Response --- (added a
"""

[rustyline]
# Switch rustyline input mode between `Emacs` and `Vi`.
# Switch rustyline input mode between `emacs` and `vi`.
mode = "emacs"

# Switch completion type between `circular` and `list`.
completion_mode = "circular"
```

### Configuring Ollama
Expand Down
39 changes: 34 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,26 @@ impl Default for EditMode {
}
}

#[derive(Debug, Clone, Copy, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum CompletionType {
Circular,
List,
}

impl Default for CompletionType {
fn default() -> Self {
CompletionType::Circular
}
}

#[derive(Debug, Deserialize, Default)]
pub struct RustylineConfig {
#[serde(default)]
pub edit_mode: EditMode,

#[serde(default)]
pub completion_type: CompletionType,
}

#[derive(Deserialize)]
Expand Down Expand Up @@ -91,13 +107,22 @@ impl Config {
}

pub fn create_rustyline_config(&self) -> rustyline::Config {
let config = rustyline::Config::builder();
let mut config_builder = rustyline::Config::builder();

// Apply edit mode setting
match self.rustyline.edit_mode {
EditMode::Emacs => config.edit_mode(rustyline::EditMode::Emacs).build(),
EditMode::Vi => config.edit_mode(rustyline::EditMode::Vi).build(),
}
config_builder = match self.rustyline.edit_mode {
EditMode::Emacs => config_builder.edit_mode(rustyline::EditMode::Emacs),
EditMode::Vi => config_builder.edit_mode(rustyline::EditMode::Vi),
};

config_builder = match self.rustyline.completion_type {
CompletionType::Circular => {
config_builder.completion_type(rustyline::CompletionType::Circular)
}
CompletionType::List => config_builder.completion_type(rustyline::CompletionType::List),
};

config_builder.build()
}

pub fn create_editor(&self) -> rustyline::Result<Editor<CommandHelper, DefaultHistory>> {
Expand Down Expand Up @@ -164,5 +189,9 @@ mod tests {

// Check rustyline default values
matches!(config.rustyline.edit_mode, EditMode::Emacs);
matches!(
config.rustyline.completion_type,
crate::config::CompletionType::Circular
);
}
}