Skip to content

Commit 47b84f7

Browse files
committed
config/settings: Add option helpsplit for permanent help split type
For downward compatibility the default split type for the `help` command is set to be `hsplit`.
1 parent ff4c5c8 commit 47b84f7

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

internal/action/actions.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,8 @@ func (h *BufPane) ToggleHelp() bool {
17231723
if h.Buf.Type == buffer.BTHelp {
17241724
h.Quit()
17251725
} else {
1726-
h.openHelp("help", true, false)
1726+
hsplit := config.GlobalSettings["helpsplit"] == "hsplit"
1727+
h.openHelp("help", hsplit, false)
17271728
}
17281729
return true
17291730
}

internal/action/command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,12 @@ func (h *BufPane) openHelp(page string, hsplit bool, forceSplit bool) error {
450450

451451
// HelpCmd tries to open the given help page in a horizontal split
452452
func (h *BufPane) HelpCmd(args []string) {
453+
hsplit := config.GlobalSettings["helpsplit"] == "hsplit"
453454
if len(args) < 1 {
454455
// Open the default help if the user just typed "> help"
455-
h.openHelp("help", true, false)
456+
h.openHelp("help", hsplit, false)
456457
} else {
457458
var topics []string
458-
hsplit := true
459459
forceSplit := false
460460
const errSplit = "hsplit and vsplit are not allowed at the same time"
461461
for _, arg := range args {

internal/config/settings.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var optionValidators = map[string]optionValidator{
2929
"detectlimit": validateNonNegativeValue,
3030
"encoding": validateEncoding,
3131
"fileformat": validateChoice,
32+
"helpsplit": validateChoice,
3233
"matchbracestyle": validateChoice,
3334
"multiopen": validateChoice,
3435
"reload": validateChoice,
@@ -41,6 +42,7 @@ var optionValidators = map[string]optionValidator{
4142
var OptionChoices = map[string][]string{
4243
"clipboard": {"internal", "external", "terminal"},
4344
"fileformat": {"unix", "dos"},
45+
"helpsplit": {"hsplit", "vsplit"},
4446
"matchbracestyle": {"underline", "highlight"},
4547
"multiopen": {"tab", "hsplit", "vsplit"},
4648
"reload": {"prompt", "auto", "disabled"},
@@ -109,6 +111,7 @@ var DefaultGlobalOnlySettings = map[string]interface{}{
109111
"divchars": "|-",
110112
"divreverse": true,
111113
"fakecursor": false,
114+
"helpsplit": "hsplit",
112115
"infobar": true,
113116
"keymenu": false,
114117
"mouse": true,

runtime/help/commands.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ quotes here but these are not necessary when entering the command in micro.
2727
Help topics are stored as `.md` files in the `runtime/help` directory of
2828
the source tree, which is embedded in the final binary.
2929
The `flags` are optional.
30-
* `-hsplit`: Opens the help topic in a horizontal split (default for initial split)
30+
* `-hsplit`: Opens the help topic in a horizontal split
3131
* `-vsplit`: Opens the help topic in a vertical split
3232

33+
The default split type is defined by the global `helpsplit` option.
34+
3335
* `save ['filename']`: saves the current buffer. If the file is provided it
3436
will 'save as' the filename.
3537

runtime/help/options.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ Here are the available options:
172172
default value: `unknown`. This will be automatically overridden depending
173173
on the file you open.
174174

175+
* `helpsplit`: sets the split type to be used by the `help` command.
176+
Possible values:
177+
* `vsplit`: open help in a vertical split pane
178+
* `hsplit`: open help in a horizontal split pane
179+
180+
default value: `hsplit`
181+
175182
* `hlsearch`: highlight all instances of the searched text after a successful
176183
search. This highlighting can be temporarily turned off via the
177184
`UnhighlightSearch` action (triggered by the Esc key by default) or toggled

0 commit comments

Comments
 (0)