Skip to content

Commit

Permalink
Set default sign priorities for gitsigns.
Browse files Browse the repository at this point in the history
  • Loading branch information
dstein64 committed Nov 16, 2023
1 parent a12daee commit 10eb56b
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions lua/scrollview/contrib/gitsigns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@
-- {config} is an optional table with the following attributes:
-- - add_highlight (string): Defaults to a value from gitsigns config
-- when available, otherwise 'DiffAdd'.
-- - add_priority (number): See ':help scrollview.register_sign_spec()'
-- for the default value when not specified.
-- - add_priority (number): Defaults to 90.
-- - add_symbol (string): Defaults to a value from gitsigns config when
-- available, otherwise box drawing heavy vertical.
-- - change_highlight (string): Defaults to a value from gitsigns config
-- when available, otherwise 'DiffChange'.
-- - change_priority (number): See ':help scrollview.register_sign_spec()'
-- for the default value when not specified.
-- - change_priority (number): Defaults to 90.
-- - change_symbol (string): Defaults to a value from gitsigns config
-- when available, otherwise box drawing heavy vertical.
-- - delete_highlight (string): Defaults to a value from gitsigns config
-- when available, otherwise 'DiffDelete'.
-- - delete_priority (number): See ':help scrollview.register_sign_spec()'
-- for the default value when not specified.
-- - delete_priority (number): Defaults to 90.
-- - delete_symbol (string): Defaults to a value from gitsigns config
-- when available, otherwise lower one-eigth block.
-- - enabled (boolean): Whether signs are enabled immediately. If false,
Expand All @@ -45,6 +42,9 @@ function M.setup(config)
enabled = true,
hide_full_add = true,
only_first_line = false,
add_priority = 90,
change_priority = 90,
delete_priority = 90,
}

-- Try setting highlight and symbol defaults from gitsigns config.
Expand Down Expand Up @@ -78,21 +78,11 @@ function M.setup(config)
defaults.delete_symbol = defaults.delete_symbol or fn.nr2char(0x2581)

-- Set missing config values with defaults.
if config.enabled == nil then
config.enabled = defaults.enabled
end
if config.hide_full_add == nil then
config.hide_full_add = defaults.hide_full_add
end
config.add_highlight = config.add_highlight or defaults.add_highlight
config.change_highlight = config.change_highlight or defaults.change_highlight
config.delete_highlight = config.delete_highlight or defaults.delete_highlight
if config.only_first_line == nil then
config.only_first_line = defaults.only_first_line
for key, val in pairs(defaults) do
if config[key] == nil then
config[key] = val
end
end
config.add_symbol = config.add_symbol or defaults.add_symbol
config.change_symbol = config.change_symbol or defaults.change_symbol
config.delete_symbol = config.delete_symbol or defaults.delete_symbol

local group = 'gitsigns'

Expand Down

0 comments on commit 10eb56b

Please sign in to comment.