Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(count_chars): add config option to specify count chars for the t… #943

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/gitsigns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,15 @@ count_chars *gitsigns-config-count_chars*
• to specify unicode characters for the counts instead of 1-9.
• to define characters to be used for counts greater than 9.

top_count_chars *gitsigns-config-top_count_chars*
Type: `table`
Default: >
`{ "1", "2", "3", "4", "5", "6", "7", "8", "9",
["+"] = ">"
}`
<
Same as count_chars, but for top line.

status_formatter *gitsigns-config-status_formatter*
Type: `function`
Default: >
Expand Down
20 changes: 20 additions & 0 deletions lua/gitsigns/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
--- @field _signs_staged table<Gitsigns.SignType,Gitsigns.SignConfig>
--- @field _signs_staged_enable boolean
--- @field count_chars table<string|integer,string>
--- @field top_count_chars table<string|integer,string>
--- @field signcolumn boolean
--- @field numhl boolean
--- @field linehl boolean
Expand Down Expand Up @@ -508,6 +509,25 @@ M.schema = {
]],
},

top_count_chars = {
type = 'table',
default = {
[1] = '1', -- '¹',
[2] = '2', -- '²',
[3] = '3', -- '³',
[4] = '4', -- '⁴',
[5] = '5', -- '⁵',
[6] = '6', -- '⁶',
[7] = '7', -- '⁷',
[8] = '8', -- '⁸',
[9] = '9', -- '⁹',
['+'] = '>', -- '⁺',
},
description = [[
Same as count_chars, but for top line.
]],
},

status_formatter = {
type = 'function',
--- @param status Gitsigns.StatusObj
Expand Down
2 changes: 1 addition & 1 deletion lua/gitsigns/signs/extmarks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function M:add(bufnr, signs)
local text = cs.text
if config.signcolumn and cs.show_count and s.count then
local count = s.count
local cc = config.count_chars
local cc = s.type == 'topdelete' and config.top_count_chars or config.count_chars
local count_char = cc[count] or cc['+'] or ''
text = cs.text .. count_char
end
Expand Down
2 changes: 1 addition & 1 deletion lua/gitsigns/signs/vimfn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function M:add(bufnr, signs)
local cs = self.config[s.type]
if config.signcolumn and cs.show_count and s.count then
local count = s.count
local cc = config.count_chars
local cc = s.type == 'topdelete' and config.top_count_chars or config.count_chars
local count_suffix = cc[count] and tostring(count) or (cc['+'] and 'Plus') or ''
local count_char = cc[count] or cc['+'] or ''
local hls = self.hls[s.type]
Expand Down
Loading