Skip to content

Commit a811e98

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

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

book/src/editor.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
| `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"`
5959
| `end-of-line-diagnostics` | Minimum severity of diagnostics to render at the end of the line. Set to `disable` to disable entirely. Refer to the setting about `inline-diagnostics` for more details | "disable"
6060
| `clipboard-provider` | Which API to use for clipboard interaction. One of `pasteboard` (MacOS), `wayland`, `x-clip`, `x-sel`, `win-32-yank`, `termux`, `tmux`, `windows`, `termcode`, `none`, or a custom command set. | Platform and environment specific. |
61+
| `initial-mode` | The initial mode for newly opened editors. | `"normal"` |
6162

6263
### `[editor.clipboard-provider]` Section
6364

helix-view/src/editor.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ pub struct Config {
360360
pub end_of_line_diagnostics: DiagnosticFilter,
361361
// Set to override the default clipboard provider
362362
pub clipboard_provider: ClipboardProvider,
363+
/// The initial mode for newly opened editors. Defaults to `"normal"`.
364+
pub initial_mode: Mode,
363365
}
364366

365367
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)]
@@ -1001,6 +1003,7 @@ impl Default for Config {
10011003
inline_diagnostics: InlineDiagnosticsConfig::default(),
10021004
end_of_line_diagnostics: DiagnosticFilter::Disable,
10031005
clipboard_provider: ClipboardProvider::default(),
1006+
initial_mode: Mode::Normal,
10041007
}
10051008
}
10061009
}
@@ -1589,10 +1592,6 @@ impl Editor {
15891592
return;
15901593
}
15911594

1592-
if !matches!(action, Action::Load) {
1593-
self.enter_normal_mode();
1594-
}
1595-
15961595
let focust_lost = match action {
15971596
Action::Replace => {
15981597
let (view, doc) = current_ref!(self);
@@ -1692,6 +1691,7 @@ impl Editor {
16921691

16931692
/// Generate an id for a new document and register it.
16941693
fn new_document(&mut self, mut doc: Document) -> DocumentId {
1694+
self.mode = self.config().initial_mode;
16951695
let id = self.next_document_id;
16961696
// Safety: adding 1 from 1 is fine, probably impossible to reach usize max
16971697
self.next_document_id =

0 commit comments

Comments
 (0)