diff options
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | src/config/mod.rs | 2 | ||||
| -rw-r--r-- | src/config/role.rs | 6 | ||||
| -rw-r--r-- | src/config/session.rs | 2 | ||||
| -rw-r--r-- | src/main.rs | 4 | ||||
| -rw-r--r-- | src/render/markdown.rs | 18 | ||||
| -rw-r--r-- | src/render/repl.rs | 2 | ||||
| -rw-r--r-- | src/repl/prompt.rs | 2 |
8 files changed, 22 insertions, 20 deletions
@@ -166,12 +166,14 @@ roles_file /home/alice/.config/aichat/roles.yaml messages_file /home/alice/.config/aichat/messages.md sessions_dir /home/alice/.config/aichat/sessions model openai:gpt-3.5-turbo -temperature 0.7 +temperature - save true highlight true light_theme false +wrap no +wrap_code false dry_run false -vi_keybindings true +keybindings emacs ``` ### `.edit` - multiline editing diff --git a/src/config/mod.rs b/src/config/mod.rs index 695dad5..fbdd5b5 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -58,7 +58,7 @@ pub struct Config { pub light_theme: bool, /// Specify the text-wrapping mode (no*, auto, <max-width>) pub wrap: Option<String>, - /// Whethter wrap code block + /// Whether wrap code block pub wrap_code: bool, /// Automatically copy the last output to the clipboard pub auto_copy: bool, diff --git a/src/config/role.rs b/src/config/role.rs index 87aca5e..16a6400 100644 --- a/src/config/role.rs +++ b/src/config/role.rs @@ -22,7 +22,7 @@ impl Role { Ok(output) } - pub fn embeded(&self) -> bool { + pub fn embedded(&self) -> bool { self.prompt.contains(INPUT_PLACEHOLDER) } @@ -42,7 +42,7 @@ impl Role { } pub fn echo_messages(&self, content: &str) -> String { - if self.embeded() { + if self.embedded() { merge_prompt_content(&self.prompt, content) } else { format!("{}\n{content}", self.prompt) @@ -50,7 +50,7 @@ impl Role { } pub fn build_messages(&self, content: &str) -> Vec<Message> { - if self.embeded() { + if self.embedded() { let content = merge_prompt_content(&self.prompt, content); vec![Message { role: MessageRole::User, diff --git a/src/config/session.rs b/src/config/session.rs index b2d00bb..75b863f 100644 --- a/src/config/session.rs +++ b/src/config/session.rs @@ -44,7 +44,7 @@ impl Session { let content = read_to_string(path) .with_context(|| format!("Failed to load session {} at {}", name, path.display()))?; let mut session: Self = - serde_yaml::from_str(&content).with_context(|| format!("Invalid sesion {}", name))?; + serde_yaml::from_str(&content).with_context(|| format!("Invalid session {}", name))?; session.name = name.to_string(); session.path = Some(path.display().to_string()); diff --git a/src/main.rs b/src/main.rs index a7850b5..a23a81f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -101,8 +101,8 @@ fn start_directive( input: &str, no_stream: bool, ) -> Result<()> { - if let Some(sesion) = &config.read().session { - sesion.guard_save()?; + if let Some(session) = &config.read().session { + session.guard_save()?; } if !stdout().is_terminal() { config.write().highlight = false; diff --git a/src/render/markdown.rs b/src/render/markdown.rs index e790fa9..9fc3545 100644 --- a/src/render/markdown.rs +++ b/src/render/markdown.rs @@ -14,7 +14,7 @@ const MD_THEME_LIGHT: &[u8] = include_bytes!("../../assets/monokai-extended-ligh const SYNTAXES: &[u8] = include_bytes!("../../assets/syntaxes.bin"); lazy_static! { - static ref LANGE_MAPS: HashMap<String, String> = { + static ref LANG_MAPS: HashMap<String, String> = { let mut m = HashMap::new(); m.insert("csharp".into(), "C#".into()); m.insert("php".into(), "PHP Source".into()); @@ -97,18 +97,18 @@ impl MarkdownRender { pub fn render_line(&self, line: &str) -> String { let (_, code_syntax, is_code) = self.check_line(line); if is_code { - self.highlint_code_line(line, &code_syntax) + self.highlight_code_line(line, &code_syntax) } else { - self.highligh_line(line, &self.md_syntax, false) + self.highlight_line(line, &self.md_syntax, false) } } fn render_line_mut(&mut self, line: &str) -> String { let (line_type, code_syntax, is_code) = self.check_line(line); let output = if is_code { - self.highlint_code_line(line, &code_syntax) + self.highlight_code_line(line, &code_syntax) } else { - self.highligh_line(line, &self.md_syntax, false) + self.highlight_line(line, &self.md_syntax, false) }; self.prev_line_type = line_type; self.code_syntax = code_syntax; @@ -157,7 +157,7 @@ impl MarkdownRender { (line_type, code_syntax, is_code) } - fn highligh_line(&self, line: &str, syntax: &SyntaxReference, is_code: bool) -> String { + fn highlight_line(&self, line: &str, syntax: &SyntaxReference, is_code: bool) -> String { let ws: String = line.chars().take_while(|c| c.is_whitespace()).collect(); let trimed_line: &str = &line[ws.len()..]; let mut line_highlighted = None; @@ -171,9 +171,9 @@ impl MarkdownRender { self.wrap_line(line, is_code) } - fn highlint_code_line(&self, line: &str, code_syntax: &Option<SyntaxReference>) -> String { + fn highlight_code_line(&self, line: &str, code_syntax: &Option<SyntaxReference>) -> String { if let Some(syntax) = code_syntax { - self.highligh_line(line, syntax, true) + self.highlight_line(line, syntax, true) } else { let line = match self.code_color { Some(color) => line.with(color).to_string(), @@ -195,7 +195,7 @@ impl MarkdownRender { } fn find_syntax(&self, lang: &str) -> Option<&SyntaxReference> { - if let Some(new_lang) = LANGE_MAPS.get(&lang.to_ascii_lowercase()) { + if let Some(new_lang) = LANG_MAPS.get(&lang.to_ascii_lowercase()) { self.syntax_set.find_syntax_by_name(new_lang) } else { self.syntax_set diff --git a/src/render/repl.rs b/src/render/repl.rs index bbc0d2c..f65ff1d 100644 --- a/src/render/repl.rs +++ b/src/render/repl.rs @@ -53,7 +53,7 @@ fn repl_render_stream_inner( ReplyStreamEvent::Text(text) => { let (col, mut row) = cursor::position()?; - // fix unxpected duplicate lines on kitty, see https://github.com/sigoden/aichat/issues/105 + // fix unexpected duplicate lines on kitty, see https://github.com/sigoden/aichat/issues/105 if col == 0 && row > 0 && display_width(&buffer) == columns as usize { row -= 1; } diff --git a/src/repl/prompt.rs b/src/repl/prompt.rs index 94b7123..afc4bee 100644 --- a/src/repl/prompt.rs +++ b/src/repl/prompt.rs @@ -116,7 +116,7 @@ impl Prompt for ReplPrompt { fn get_prompt_color(&self) -> Color { self.prompt_color } - /// Get the default multilince prompt color + /// Get the default multiline prompt color fn get_prompt_multiline_color(&self) -> nu_ansi_term::Color { self.prompt_multiline_color } |
