mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-06 03:53:59 +02:00
Add config setting to suppress showing file icons (#3216)
- **PR Description** Add a config option `gui.showFileIcons` (default: true) which can be set to false to suppress showing file icons.
This commit is contained in:
commit
a67ad44781
@ -79,6 +79,7 @@ gui:
|
|||||||
showCommandLog: true
|
showCommandLog: true
|
||||||
showIcons: false # deprecated: use nerdFontsVersion instead
|
showIcons: false # deprecated: use nerdFontsVersion instead
|
||||||
nerdFontsVersion: "" # nerd fonts version to use ("2" or "3"); empty means don't show nerd font icons
|
nerdFontsVersion: "" # nerd fonts version to use ("2" or "3"); empty means don't show nerd font icons
|
||||||
|
showFileIcons: true # for hiding file icons in the file views
|
||||||
commandLogSize: 8
|
commandLogSize: 8
|
||||||
splitDiff: 'auto' # one of 'auto' | 'always'
|
splitDiff: 'auto' # one of 'auto' | 'always'
|
||||||
skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor
|
skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor
|
||||||
|
@ -121,6 +121,8 @@ type GuiConfig struct {
|
|||||||
// One of: '2' | '3' | empty string (default)
|
// One of: '2' | '3' | empty string (default)
|
||||||
// If empty, do not show icons.
|
// If empty, do not show icons.
|
||||||
NerdFontsVersion string `yaml:"nerdFontsVersion" jsonschema:"enum=2,enum=3,enum="`
|
NerdFontsVersion string `yaml:"nerdFontsVersion" jsonschema:"enum=2,enum=3,enum="`
|
||||||
|
// If true (default), file icons are shown in the file views. Only relevant if NerdFontsVersion is not empty.
|
||||||
|
ShowFileIcons bool `yaml:"showFileIcons"`
|
||||||
// If true, show commit hashes alongside branch names in the branches view.
|
// If true, show commit hashes alongside branch names in the branches view.
|
||||||
ShowBranchCommitHash bool `yaml:"showBranchCommitHash"`
|
ShowBranchCommitHash bool `yaml:"showBranchCommitHash"`
|
||||||
// Height of the command log view
|
// Height of the command log view
|
||||||
@ -635,6 +637,7 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
ShowRandomTip: true,
|
ShowRandomTip: true,
|
||||||
ShowIcons: false,
|
ShowIcons: false,
|
||||||
NerdFontsVersion: "",
|
NerdFontsVersion: "",
|
||||||
|
ShowFileIcons: true,
|
||||||
ShowBranchCommitHash: false,
|
ShowBranchCommitHash: false,
|
||||||
CommandLogSize: 8,
|
CommandLogSize: 8,
|
||||||
SplitDiff: "auto",
|
SplitDiff: "auto",
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
@ -33,7 +34,8 @@ func NewCommitFilesContext(c *ContextCommon) *CommitFilesContext {
|
|||||||
return [][]string{{style.FgRed.Sprint("(none)")}}
|
return [][]string{{style.FgRed.Sprint("(none)")}}
|
||||||
}
|
}
|
||||||
|
|
||||||
lines := presentation.RenderCommitFileTree(viewModel, c.Git().Patch.PatchBuilder)
|
showFileIcons := icons.IsIconEnabled() && c.UserConfig.Gui.ShowFileIcons
|
||||||
|
lines := presentation.RenderCommitFileTree(viewModel, c.Git().Patch.PatchBuilder, showFileIcons)
|
||||||
return lo.Map(lines, func(line string, _ int) []string {
|
return lo.Map(lines, func(line string, _ int) []string {
|
||||||
return []string{line}
|
return []string{line}
|
||||||
})
|
})
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
@ -24,7 +25,8 @@ func NewWorkingTreeContext(c *ContextCommon) *WorkingTreeContext {
|
|||||||
)
|
)
|
||||||
|
|
||||||
getDisplayStrings := func(_ int, _ int) [][]string {
|
getDisplayStrings := func(_ int, _ int) [][]string {
|
||||||
lines := presentation.RenderFileTree(viewModel, c.Model().Submodules)
|
showFileIcons := icons.IsIconEnabled() && c.UserConfig.Gui.ShowFileIcons
|
||||||
|
lines := presentation.RenderFileTree(viewModel, c.Model().Submodules, showFileIcons)
|
||||||
return lo.Map(lines, func(line string, _ int) []string {
|
return lo.Map(lines, func(line string, _ int) []string {
|
||||||
return []string{line}
|
return []string{line}
|
||||||
})
|
})
|
||||||
|
@ -21,24 +21,26 @@ const (
|
|||||||
func RenderFileTree(
|
func RenderFileTree(
|
||||||
tree filetree.IFileTree,
|
tree filetree.IFileTree,
|
||||||
submoduleConfigs []*models.SubmoduleConfig,
|
submoduleConfigs []*models.SubmoduleConfig,
|
||||||
|
showFileIcons bool,
|
||||||
) []string {
|
) []string {
|
||||||
collapsedPaths := tree.CollapsedPaths()
|
collapsedPaths := tree.CollapsedPaths()
|
||||||
return renderAux(tree.GetRoot().Raw(), collapsedPaths, -1, -1, func(node *filetree.Node[models.File], treeDepth int, visualDepth int, isCollapsed bool) string {
|
return renderAux(tree.GetRoot().Raw(), collapsedPaths, -1, -1, func(node *filetree.Node[models.File], treeDepth int, visualDepth int, isCollapsed bool) string {
|
||||||
fileNode := filetree.NewFileNode(node)
|
fileNode := filetree.NewFileNode(node)
|
||||||
|
|
||||||
return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, submoduleConfigs, node)
|
return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, showFileIcons, submoduleConfigs, node)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RenderCommitFileTree(
|
func RenderCommitFileTree(
|
||||||
tree *filetree.CommitFileTreeViewModel,
|
tree *filetree.CommitFileTreeViewModel,
|
||||||
patchBuilder *patch.PatchBuilder,
|
patchBuilder *patch.PatchBuilder,
|
||||||
|
showFileIcons bool,
|
||||||
) []string {
|
) []string {
|
||||||
collapsedPaths := tree.CollapsedPaths()
|
collapsedPaths := tree.CollapsedPaths()
|
||||||
return renderAux(tree.GetRoot().Raw(), collapsedPaths, -1, -1, func(node *filetree.Node[models.CommitFile], treeDepth int, visualDepth int, isCollapsed bool) string {
|
return renderAux(tree.GetRoot().Raw(), collapsedPaths, -1, -1, func(node *filetree.Node[models.CommitFile], treeDepth int, visualDepth int, isCollapsed bool) string {
|
||||||
status := commitFilePatchStatus(node, tree, patchBuilder)
|
status := commitFilePatchStatus(node, tree, patchBuilder)
|
||||||
|
|
||||||
return getCommitFileLine(isCollapsed, treeDepth, visualDepth, node, status)
|
return getCommitFileLine(isCollapsed, treeDepth, visualDepth, node, status, showFileIcons)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +111,7 @@ func getFileLine(
|
|||||||
hasStagedChanges bool,
|
hasStagedChanges bool,
|
||||||
treeDepth int,
|
treeDepth int,
|
||||||
visualDepth int,
|
visualDepth int,
|
||||||
|
showFileIcons bool,
|
||||||
submoduleConfigs []*models.SubmoduleConfig,
|
submoduleConfigs []*models.SubmoduleConfig,
|
||||||
node *filetree.Node[models.File],
|
node *filetree.Node[models.File],
|
||||||
) string {
|
) string {
|
||||||
@ -150,7 +153,7 @@ func getFileLine(
|
|||||||
isLinkedWorktree := file != nil && file.IsWorktree
|
isLinkedWorktree := file != nil && file.IsWorktree
|
||||||
isDirectory := file == nil
|
isDirectory := file == nil
|
||||||
|
|
||||||
if icons.IsIconEnabled() {
|
if showFileIcons {
|
||||||
icon := icons.IconForFile(name, isSubmodule, isLinkedWorktree, isDirectory)
|
icon := icons.IconForFile(name, isSubmodule, isLinkedWorktree, isDirectory)
|
||||||
paint := color.C256(icon.Color, false)
|
paint := color.C256(icon.Color, false)
|
||||||
output += paint.Sprint(icon.Icon) + nameColor.Sprint(" ")
|
output += paint.Sprint(icon.Icon) + nameColor.Sprint(" ")
|
||||||
@ -189,6 +192,7 @@ func getCommitFileLine(
|
|||||||
visualDepth int,
|
visualDepth int,
|
||||||
node *filetree.Node[models.CommitFile],
|
node *filetree.Node[models.CommitFile],
|
||||||
status patch.PatchStatus,
|
status patch.PatchStatus,
|
||||||
|
showFileIcons bool,
|
||||||
) string {
|
) string {
|
||||||
indentation := strings.Repeat(" ", visualDepth)
|
indentation := strings.Repeat(" ", visualDepth)
|
||||||
name := commitFileNameAtDepth(node, treeDepth)
|
name := commitFileNameAtDepth(node, treeDepth)
|
||||||
@ -236,7 +240,7 @@ func getCommitFileLine(
|
|||||||
isSubmodule := false
|
isSubmodule := false
|
||||||
isLinkedWorktree := false
|
isLinkedWorktree := false
|
||||||
|
|
||||||
if icons.IsIconEnabled() {
|
if showFileIcons {
|
||||||
icon := icons.IconForFile(name, isSubmodule, isLinkedWorktree, isDirectory)
|
icon := icons.IconForFile(name, isSubmodule, isLinkedWorktree, isDirectory)
|
||||||
paint := color.C256(icon.Color, false)
|
paint := color.C256(icon.Color, false)
|
||||||
output += paint.Sprint(icon.Icon) + " "
|
output += paint.Sprint(icon.Icon) + " "
|
||||||
|
@ -74,7 +74,7 @@ M file1
|
|||||||
for _, path := range s.collapsedPaths {
|
for _, path := range s.collapsedPaths {
|
||||||
viewModel.ToggleCollapsed(path)
|
viewModel.ToggleCollapsed(path)
|
||||||
}
|
}
|
||||||
result := RenderFileTree(viewModel, nil)
|
result := RenderFileTree(viewModel, nil, false)
|
||||||
assert.EqualValues(t, s.expected, result)
|
assert.EqualValues(t, s.expected, result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ M file1
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
patchBuilder.Start("from", "to", false, false)
|
patchBuilder.Start("from", "to", false, false)
|
||||||
result := RenderCommitFileTree(viewModel, patchBuilder)
|
result := RenderCommitFileTree(viewModel, patchBuilder, false)
|
||||||
assert.EqualValues(t, s.expected, result)
|
assert.EqualValues(t, s.expected, result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -304,6 +304,11 @@
|
|||||||
],
|
],
|
||||||
"description": "Nerd fonts version to use.\nOne of: '2' | '3' | empty string (default)\nIf empty, do not show icons."
|
"description": "Nerd fonts version to use.\nOne of: '2' | '3' | empty string (default)\nIf empty, do not show icons."
|
||||||
},
|
},
|
||||||
|
"showFileIcons": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "If true (default), file icons are shown in the file views. Only relevant if NerdFontsVersion is not empty.",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
"showBranchCommitHash": {
|
"showBranchCommitHash": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "If true, show commit hashes alongside branch names in the branches view."
|
"description": "If true, show commit hashes alongside branch names in the branches view."
|
||||||
|
Loading…
Reference in New Issue
Block a user