diff --git a/docs/Config.md b/docs/Config.md index 03a29ff18..49f884dac 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -47,6 +47,10 @@ gui: # One of: 'margin' (default) | 'jump' scrollOffBehavior: margin + # The number of spaces per tab; used for everything that's shown in the main view, but probably mostly relevant for diffs. + # Note that when using a pager, the pager has its own tab width setting, so you need to pass it separately in the pager command. + tabWidth: 4 + # If true, capture mouse events. # When mouse events are captured, it's a little harder to select text: e.g. requiring you to hold the option key when on macOS. mouseEvents: true diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 9fea5ea64..d6a27733e 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -64,6 +64,9 @@ type GuiConfig struct { ScrollOffMargin int `yaml:"scrollOffMargin"` // One of: 'margin' (default) | 'jump' ScrollOffBehavior string `yaml:"scrollOffBehavior"` + // The number of spaces per tab; used for everything that's shown in the main view, but probably mostly relevant for diffs. + // Note that when using a pager, the pager has its own tab width setting, so you need to pass it separately in the pager command. + TabWidth int `yaml:"tabWidth" jsonschema:"minimum=1"` // If true, capture mouse events. // When mouse events are captured, it's a little harder to select text: e.g. requiring you to hold the option key when on macOS. MouseEvents bool `yaml:"mouseEvents"` @@ -693,6 +696,7 @@ func GetDefaultConfig() *UserConfig { ScrollPastBottom: true, ScrollOffMargin: 2, ScrollOffBehavior: "margin", + TabWidth: 4, MouseEvents: true, SkipDiscardChangeWarning: false, SkipStashWarning: false, diff --git a/pkg/gui/views.go b/pkg/gui/views.go index 526696b25..8a4d77119 100644 --- a/pkg/gui/views.go +++ b/pkg/gui/views.go @@ -203,6 +203,7 @@ func (gui *Gui) configureViewProperties() { for _, view := range []*gocui.View{gui.Views.Main, gui.Views.Secondary, gui.Views.Staging, gui.Views.StagingSecondary, gui.Views.PatchBuilding, gui.Views.PatchBuildingSecondary, gui.Views.MergeConflicts} { view.CanScrollPastBottom = gui.c.UserConfig().Gui.ScrollPastBottom + view.TabWidth = gui.c.UserConfig().Gui.TabWidth } gui.Views.CommitDescription.FgColor = theme.GocuiDefaultTextColor diff --git a/schema/config.json b/schema/config.json index a7524eb77..ef8a642cf 100644 --- a/schema/config.json +++ b/schema/config.json @@ -46,6 +46,12 @@ "description": "One of: 'margin' (default) | 'jump'", "default": "margin" }, + "tabWidth": { + "type": "integer", + "minimum": 1, + "description": "The number of spaces per tab; used for everything that's shown in the main view, but probably mostly relevant for diffs.\nNote that when using a pager, the pager has its own tab width setting, so you need to pass it separately in the pager command.", + "default": 4 + }, "mouseEvents": { "type": "boolean", "description": "If true, capture mouse events.\nWhen mouse events are captured, it's a little harder to select text: e.g. requiring you to hold the option key when on macOS.",