diff options
author | Joe | 2022-03-14 02:47:52 +0000 |
---|---|---|
committer | GitHub | 2022-03-14 02:47:52 +0000 |
commit | c0dbd6dc3f147b46d4352ac78903a7a70741cfd9 (patch) | |
tree | dece1b71c36aa367d13959b0f483d66423150709 /helix-term | |
parent | 85492e587cc27ba9783c8380683660a0f4423ff4 (diff) |
Add horizontal and vertical split scratch buffers (#1763)
Make subcommand name more descriptive
Fix vsplit completer
Run cargo xtask docgen
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 10 | ||||
-rw-r--r-- | helix-term/src/commands/typed.rs | 34 | ||||
-rw-r--r-- | helix-term/src/keymap.rs | 8 |
3 files changed, 52 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index ff3fb925..f8a888e7 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -380,7 +380,9 @@ impl MappableCommand { jump_view_down, "Jump to the split below", rotate_view, "Goto next window", hsplit, "Horizontal bottom split", + hsplit_new, "Horizontal bottom split scratch buffer", vsplit, "Vertical right split", + vsplit_new, "Vertical right split scratch buffer", wclose, "Close window", wonly, "Current window only", select_register, "Select register", @@ -3794,10 +3796,18 @@ fn hsplit(cx: &mut Context) { split(cx, Action::HorizontalSplit); } +fn hsplit_new(cx: &mut Context) { + cx.editor.new_file(Action::HorizontalSplit); +} + fn vsplit(cx: &mut Context) { split(cx, Action::VerticalSplit); } +fn vsplit_new(cx: &mut Context) { + cx.editor.new_file(Action::VerticalSplit); +} + fn wclose(cx: &mut Context) { if cx.editor.tree.views().count() == 1 { if let Err(err) = typed::buffers_remaining_impl(cx.editor) { diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 3301d148..7866ff9d 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -771,6 +771,26 @@ fn hsplit( Ok(()) } +fn vsplit_new( + cx: &mut compositor::Context, + _args: &[Cow<str>], + _event: PromptEvent, +) -> anyhow::Result<()> { + cx.editor.new_file(Action::VerticalSplit); + + Ok(()) +} + +fn hsplit_new( + cx: &mut compositor::Context, + _args: &[Cow<str>], + _event: PromptEvent, +) -> anyhow::Result<()> { + cx.editor.new_file(Action::HorizontalSplit); + + Ok(()) +} + fn debug_eval( cx: &mut compositor::Context, args: &[Cow<str>], @@ -1294,6 +1314,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ completer: Some(completers::filename), }, TypableCommand { + name: "vsplit-new", + aliases: &["vnew"], + doc: "Open a scratch buffer in a vertical split.", + fun: vsplit_new, + completer: None, + }, + TypableCommand { name: "hsplit", aliases: &["hs", "sp"], doc: "Open the file in a horizontal split.", @@ -1301,6 +1328,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ completer: Some(completers::filename), }, TypableCommand { + name: "hsplit-new", + aliases: &["hnew"], + doc: "Open a scratch buffer in a horizontal split.", + fun: hsplit_new, + completer: None, + }, + TypableCommand { name: "tutor", aliases: &[], doc: "Open the tutorial.", diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 1fe1f633..1059feae 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -682,6 +682,10 @@ impl Default for Keymaps { "C-j" | "j" | "down" => jump_view_down, "C-k" | "k" | "up" => jump_view_up, "C-l" | "l" | "right" => jump_view_right, + "n" => { "New split scratch buffer" + "C-s" | "s" => hsplit_new, + "C-v" | "v" => vsplit_new, + }, }, // move under <space>c @@ -732,6 +736,10 @@ impl Default for Keymaps { "C-j" | "j" | "down" => jump_view_down, "C-k" | "k" | "up" => jump_view_up, "C-l" | "l" | "right" => jump_view_right, + "n" => { "New split scratch buffer" + "C-s" | "s" => hsplit_new, + "C-v" | "v" => vsplit_new, + }, }, "y" => yank_joined_to_clipboard, "Y" => yank_main_selection_to_clipboard, |