Skip to content

Commit cf48f4d

Browse files
committed
Fix jsonschema pagerconfig
1 parent 34b0f49 commit cf48f4d

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

pkg/commands/git_commands/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (self *ConfigCommands) GetPager(width int) string {
5353
"columnWidth": strconv.Itoa(width/2 - 6),
5454
}
5555

56-
pagerTemplate := self.UserConfig.Git.Paging.Pager
56+
pagerTemplate := string(self.UserConfig.Git.Paging.Pager)
5757
return utils.ResolvePlaceholderString(pagerTemplate, templateValues)
5858
}
5959

pkg/config/user_config.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package config
22

33
import (
44
"time"
5+
6+
"github.com/karimkhaleel/jsonschema"
57
)
68

79
type UserConfig struct {
@@ -203,20 +205,30 @@ type GitConfig struct {
203205
Log LogConfig `yaml:"log"`
204206
}
205207

208+
type PagerType string
209+
206210
type PagingConfig struct {
207211
// Value of the --color arg in the git diff command. Some pagers want this to be set to 'always' and some want it set to 'never'
208212
ColorArg string `yaml:"colorArg" jsonschema:"enum=always,enum=never"`
209213
// e.g.
210214
// diff-so-fancy
211215
// delta --dark --paging=never
212216
// ydiff -p cat -s --wrap --width={{columnWidth}}
213-
Pager string `yaml:"pager" jsonschema:"example=delta --dark --paging=never,example=diff-so-fancy,example=ydiff -p cat -s --wrap --width={{columnWidth}},minLength=1"`
217+
Pager PagerType `yaml:"pager" jsonschema:"minLength=1"`
214218
// If true, Lazygit will use whatever pager is specified in `$GIT_PAGER`, `$PAGER`, or your *git config*. If the pager ends with something like ` | less` we will strip that part out, because less doesn't play nice with our rendering approach. If the custom pager uses less under the hood, that will also break rendering (hence the `--paging=never` flag for the `delta` pager).
215219
UseConfig bool `yaml:"useConfig"`
216220
// e.g. 'difft --color=always'
217221
ExternalDiffCommand string `yaml:"externalDiffCommand"`
218222
}
219223

224+
func (PagerType) JSONSchemaExtend(schema *jsonschema.Schema) {
225+
schema.Examples = []any{
226+
"delta --dark --paging=never",
227+
"diff-so-fancy",
228+
"ydiff -p cat -s --wrap --width={{columnWidth}}",
229+
}
230+
}
231+
220232
type CommitConfig struct {
221233
// If true, pass '--signoff' flag when committing
222234
SignOff bool `yaml:"signOff"`

schema/config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,11 @@
502502
"type": "string",
503503
"minLength": 1,
504504
"description": "e.g.\ndiff-so-fancy\ndelta --dark --paging=never\nydiff -p cat -s --wrap --width={{columnWidth}}",
505+
"default": "",
505506
"examples": [
506-
"diff-so-fancy"
507+
"delta --dark --paging=never",
508+
"diff-so-fancy",
509+
"ydiff -p cat -s --wrap --width={{columnWidth}}"
507510
]
508511
},
509512
"useConfig": {

0 commit comments

Comments
 (0)