Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make initial editing mode configurable #3366

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ You may also specify a file to use for configuration with the `-c` or
| `auto-info` | Whether to display infoboxes | `true` |
| `true-color` | Set to `true` to override automatic detection of terminal truecolor 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. | `[]` |
| `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` |

### `[editor.statusline]` Section
Expand Down
4 changes: 4 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ pub struct Config {
pub whitespace: WhitespaceConfig,
/// Vertical indent width guides.
pub indent_guides: IndentGuidesConfig,
/// 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,
}
Expand Down Expand Up @@ -498,6 +500,7 @@ impl Default for Config {
rulers: Vec::new(),
whitespace: WhitespaceConfig::default(),
indent_guides: IndentGuidesConfig::default(),
initial_mode: Mode::Normal,
color_modes: false,
}
}
Expand Down Expand Up @@ -906,6 +909,7 @@ impl Editor {

/// Generate an id for a new document and register it.
fn new_document(&mut self, mut doc: Document) -> DocumentId {
doc.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 =
Expand Down