@@ -48,18 +48,32 @@ function M.setup(config)
4848 delete_priority = 90 ,
4949 }
5050
51- -- Try setting highlight and symbol defaults from gitsigns config.
51+ -- Try setting symbol defaults from gitsigns config.
5252 pcall (function ()
5353 local signs = require (' gitsigns.config' ).config .signs
54- defaults .add_highlight = signs .add .hl
55- defaults .change_highlight = signs .change .hl
56- defaults .delete_highlight = signs .delete .hl
5754 defaults .add_symbol = signs .add .text
5855 defaults .change_symbol = signs .change .text
5956 defaults .delete_symbol = signs .delete .text
6057 end )
6158
62- -- Try setting highlight and symbol defaults from gitsigns defaults.
59+ -- Try setting highlight defaults from gitsigns config (relevant prior to
60+ -- gitsigns PR #1306).
61+ pcall (function ()
62+ local signs = require (' gitsigns.config' ).config .signs
63+ local default = signs .default
64+ if default .add .hl ~= nil then
65+ defaults .add_highlight = signs .add .hl
66+ end
67+ if default .change .hl ~= nil then
68+ defaults .change_highlight = signs .change .hl
69+ end
70+ if default .delete .hl ~= nil then
71+ defaults .delete_highlight = signs .delete .hl
72+ end
73+ end )
74+
75+ -- Try setting highlight and symbol defaults from gitsigns defaults (for
76+ -- highlights, relevant prior to gitsigns PR #1306).
6377 pcall (function ()
6478 local default = require (' gitsigns.config' ).schema .signs .default
6579 defaults .add_highlight = defaults .add_highlight or default .add .hl
@@ -70,6 +84,19 @@ function M.setup(config)
7084 defaults .delete_symbol = defaults .delete_symbol or default .delete .text
7185 end )
7286
87+ -- Try setting highlight defaults from gitsigns highlight groups.
88+ pcall (function ()
89+ if not vim .tbl_isempty (api .nvim_get_hl (0 , {name = ' GitSignsAdd' })) then
90+ defaults .add_highlight = defaults .add_highlight or ' GitSignsAdd'
91+ end
92+ if not vim .tbl_isempty (api .nvim_get_hl (0 , {name = ' GitSignsChange' })) then
93+ defaults .change_highlight = defaults .change_highlight or ' GitSignsChange'
94+ end
95+ if not vim .tbl_isempty (api .nvim_get_hl (0 , {name = ' GitSignsDelete' })) then
96+ defaults .delete_highlight = defaults .delete_highlight or ' GitSignsDelete'
97+ end
98+ end )
99+
73100 -- Try setting highlight and symbol defaults from fixed values.
74101 defaults .add_highlight = defaults .add_highlight or ' DiffAdd'
75102 defaults .change_highlight = defaults .change_highlight or ' DiffChange'
0 commit comments