aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJJ2023-11-01 02:56:41 +0000
committerJJ2023-11-01 04:08:59 +0000
commitf441f0571f7d8e140384fe75621fa69cec3265c0 (patch)
tree09aa7e83ee2972868754d3a8d25945a5f7713a4d
parent696fa18edece20f10d8b276728c55ad712be1da9 (diff)
Make initial editing mode configurable
ref: https://github.com/helix-editor/helix/pull/3366 Co-authored-by: Philipp Emanuel Weidmann <pew@worldwidemann.com>
-rw-r--r--book/src/configuration.md1
-rw-r--r--helix-view/src/editor.rs7
2 files changed, 7 insertions, 1 deletions
diff --git a/book/src/configuration.md b/book/src/configuration.md
index b62aab16..23a7a8cf 100644
--- a/book/src/configuration.md
+++ b/book/src/configuration.md
@@ -60,6 +60,7 @@ Its settings will be merged with the configuration directory `config.toml` and t
| `undercurl` | Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative | `false` |
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` |
| `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` |
+| `initial-mode` | The initial mode for newly opened editors. | `"normal"` |
| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
| `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap-at-text-width` is set | `80` |
| `workspace-lsp-roots` | Directories relative to the workspace root that are treated as LSP roots. Should only be set in `.helix/config.toml` | `[]` |
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index b2615c9f..a9014fe7 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -306,6 +306,8 @@ pub struct Config {
pub indent_guides: IndentGuidesConfig,
/// Explorer configuration.
pub explorer: ExplorerConfig,
+ /// The initial mode for newly opened editors. Defaults to `"normal"`.
+ pub initial_mode: Mode,
/// Whether to color modes with different colors. Defaults to `false`.
pub color_modes: bool,
/// Whether to render rainbow highlights. Defaults to `false`.
@@ -874,6 +876,7 @@ impl Default for Config {
bufferline: BufferLine::default(),
indent_guides: IndentGuidesConfig::default(),
explorer: ExplorerConfig::default(),
+ initial_mode: Mode::Normal,
color_modes: false,
rainbow_brackets: false,
soft_wrap: SoftWrap {
@@ -1359,7 +1362,8 @@ impl Editor {
return;
}
- self.enter_normal_mode();
+ // this causes tree.rs to panic upon launch. todo: debug
+ // self.enter_normal_mode();
match action {
Action::Replace => {
@@ -1448,6 +1452,7 @@ impl Editor {
/// Generate an id for a new document and register it.
fn new_document(&mut self, mut doc: Document) -> DocumentId {
+ self.mode = self.config().initial_mode;
let id = self.next_document_id;
// Safety: adding 1 from 1 is fine, probably impossible to reach usize max
self.next_document_id =