Skip to content

Commit 78d3151

Browse files
p-e-womentic
andcommitted
Make initial editing mode configurable
ref: helix-editor/helix#3366 Co-authored-by: JJ <[email protected]>
1 parent 4346e4d commit 78d3151

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

book/src/configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Its settings will be merged with the configuration directory `config.toml` and t
6969
| `popup-border` | Draw border around `popup`, `menu`, `all`, or `none` | `none` |
7070
| `indent-heuristic` | How the indentation for a newly inserted line is computed: `simple` just copies the indentation level from the previous line, `tree-sitter` computes the indentation based on the syntax tree and `hybrid` combines both approaches. If the chosen heuristic is not available, a different one will be used as a fallback (the fallback order being `hybrid` -> `tree-sitter` -> `simple`). | `hybrid`
7171
| `jump-label-alphabet` | The characters that are used to generate two character jump labels. Characters at the start of the alphabet are used first. | `"abcdefghijklmnopqrstuvwxyz"`
72+
| `initial-mode` | The initial mode for newly opened editors. | `"normal"` |
7273

7374
### `[editor.statusline]` Section
7475

helix-view/src/editor.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ pub struct Config {
351351
pub jump_label_alphabet: Vec<char>,
352352
/// Explorer configuration.
353353
pub explorer: ExplorerConfig,
354+
/// The initial mode for newly opened editors. Defaults to `"normal"`.
355+
pub initial_mode: Mode,
354356
}
355357

356358
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)]
@@ -929,6 +931,7 @@ impl Default for Config {
929931
indent_heuristic: IndentationHeuristic::default(),
930932
jump_label_alphabet: ('a'..='z').collect(),
931933
explorer: ExplorerConfig::default(),
934+
initial_mode: Mode::Normal,
932935
}
933936
}
934937
}
@@ -1504,7 +1507,8 @@ impl Editor {
15041507
return;
15051508
}
15061509

1507-
self.enter_normal_mode();
1510+
// this causes tree.rs to panic upon launch. todo: debug
1511+
// self.enter_normal_mode();
15081512

15091513
match action {
15101514
Action::Replace => {
@@ -1593,6 +1597,7 @@ impl Editor {
15931597

15941598
/// Generate an id for a new document and register it.
15951599
fn new_document(&mut self, mut doc: Document) -> DocumentId {
1600+
self.mode = self.config().initial_mode;
15961601
let id = self.next_document_id;
15971602
// Safety: adding 1 from 1 is fine, probably impossible to reach usize max
15981603
self.next_document_id =

0 commit comments

Comments
 (0)