@@ -1,6 +1,6 @@
11use crate::{
22 clipboard::{get_clipboard_provider, ClipboardProvider},
3− document::SCRATCH_BUFFER_NAME,
3+ document::{Mode, SCRATCH_BUFFER_NAME},
44 graphics::{CursorKind, Rect},
55 theme::{self, Theme},
66 tree::{self, Tree},
@@ -9,7 +9,7 @@ use crate::{
99
1010use futures_util::future;
1111use std::{
12− collections::BTreeMap,
12+ collections::{BTreeMap, HashMap},
1313 io::stdin,
1414 path::{Path, PathBuf},
1515 pin::Pin,
@@ -22,7 +22,7 @@ use anyhow::Error;
2222
2323pub use helix_core::diagnostic::Severity;
2424pub use helix_core::register::Registers;
25−use helix_core::syntax;
25+use helix_core::{hashmap, syntax};
2626use helix_core::{Position, Selection};
2727
2828use serde::Deserialize;
@@ -103,6 +103,30 @@ pub struct Config {
103103 /// Whether to display infoboxes. Defaults to true.
104104 pub auto_info: bool,
105105 pub file_picker: FilePickerConfig,
106+ /// Shape for cursor in each mode
107+ pub cursor_shape: CursorShapeConfig,
108+}
109+
110+#[derive(Debug, Clone, PartialEq, Deserialize)]
111+#[serde(transparent)]
112+pub struct CursorShapeConfig(HashMap<Mode, CursorKind>);
113+
114+impl std::ops::Deref for CursorShapeConfig {
115+ type Target = HashMap<Mode, CursorKind>;
116+
117+ fn deref(&self) -> &Self::Target {
118+ &self.0
119+ }
120+}
121+
122+impl Default for CursorShapeConfig {
123+ fn default() -> Self {
124+ Self(hashmap!(
125+ Mode::Insert => CursorKind::Bar,
126+ Mode::Normal => CursorKind::Block,
127+ Mode::Select => CursorKind::Underline,
128+ ))
129+ }
106130}
107131
108132#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
@@ -110,7 +134,6 @@ pub struct Config {
110134pub enum LineNumber {
111135 /// Show absolute line number
112136 Absolute,
113−
114137 /// Show relative line number to the primary cursor
115138 Relative,
116139}
@@ -135,6 +158,7 @@ impl Default for Config {
135158 completion_trigger_len: 2,
136159 auto_info: true,
137160 file_picker: FilePickerConfig::default(),
161+ cursor_shape: CursorShapeConfig::default(),
138162 }
139163 }
140164}
@@ -594,9 +618,15 @@ impl Editor {
594618 let inner = view.inner_area();
595619 pos.col += inner.x as usize;
596620 pos.row += inner.y as usize;
597− (Some(pos), CursorKind::Hidden)
621+ let cursorkind = self
622+ .config
623+ .cursor_shape
624+ .get(&doc.mode())
625+ .copied()
626+ .unwrap_or_default();
627+ (Some(pos), cursorkind)
598628 } else {
599− (None, CursorKind::Hidden)
629+ (None, CursorKind::default())
600630 }
601631 }
602632