Skip to content

Commit

Permalink
feat(signs): able staged signs by default
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Jun 13, 2024
1 parent 0b04035 commit b8cf5e8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
22 changes: 22 additions & 0 deletions doc/gitsigns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,28 @@ signs *gitsigns-config-signs*

See |gitsigns-highlight-groups|.

signs_staged *gitsigns-config-signs_staged*
Type: `table[extended]`
Default: >
{
add = { text = '┃' },
change = { text = '┃' },
delete = { text = '▁' },
topdelete = { text = '▔' },
changedelete = { text = '~' },
}
<
Configuration for signs of staged hunks.

See |gitsigns-config-signs|.

signs_staged_enable *gitsigns-config-signs_staged_enable*
Type: `boolean`, Default: `true`

Show signs for staged hunks.

When enabled the signs defined in |git-config-signs_staged|` are used.

worktrees *gitsigns-config-worktrees*
Type: `table`, Default: `nil`

Expand Down
10 changes: 5 additions & 5 deletions lua/gitsigns/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
--- @field diff_opts Gitsigns.DiffOpts
--- @field base? string
--- @field signs table<Gitsigns.SignType,Gitsigns.SignConfig>
--- @field _signs_staged table<Gitsigns.SignType,Gitsigns.SignConfig>
--- @field _signs_staged_enable boolean
--- @field signs_staged table<Gitsigns.SignType,Gitsigns.SignConfig>
--- @field signs_staged_enable boolean
--- @field count_chars table<string|integer,string>
--- @field signcolumn boolean
--- @field numhl boolean
Expand Down Expand Up @@ -244,7 +244,7 @@ M.schema = {
]],
},

_signs_staged = {
signs_staged = {
type = 'table',
deep_extend = true,
default = {
Expand Down Expand Up @@ -293,9 +293,9 @@ M.schema = {
]],
},

_signs_staged_enable = {
signs_staged_enable = {
type = 'boolean',
default = false,
default = true,
description = [[
Show signs for staged hunks.
Expand Down
6 changes: 3 additions & 3 deletions lua/gitsigns/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ M.update = throttle_by_id(function(bufnr)
return
end

if config._signs_staged_enable and not file_mode and not git_obj.revision then
if config.signs_staged_enable and not file_mode and not git_obj.revision then
if not bcache.compare_text_head or config._refresh_staged_on_update then
bcache.compare_text_head = git_obj:get_show_text('HEAD')
if not M.schedule(bufnr, true) then
Expand Down Expand Up @@ -581,8 +581,8 @@ function M.setup()
})

signs_normal = Signs.new(config.signs)
if config._signs_staged_enable then
signs_staged = Signs.new(config._signs_staged, 'staged')
if config.signs_staged_enable then
signs_staged = Signs.new(config.signs_staged, 'staged')
end

M.update_debounced = debounce_trailing(config.update_debounce, async.create(1, M.update))
Expand Down
2 changes: 1 addition & 1 deletion lua/gitsigns/signs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function M.new(cfg, name)

local self = setmetatable({}, { __index = M })
self.config = cfg
self.hls = name == 'staged' and config._signs_staged or config.signs
self.hls = name == 'staged' and config.signs_staged or config.signs
self.group = 'gitsigns_signs_' .. (name or '')
self.ns = api.nvim_create_namespace(self.group)
return self
Expand Down

0 comments on commit b8cf5e8

Please sign in to comment.