@@ -26,6 +26,52 @@ local signs_staged --- @type Gitsigns.Signs
2626
2727local M = {}
2828
29+ local statuscolumn_active = false
30+
31+ --- @param bufnr ? integer
32+ --- @param top ? integer
33+ --- @param bot ? integer
34+ local function redraw_statuscol (bufnr , top , bot )
35+ if statuscolumn_active then
36+ api .nvim__redraw ({
37+ buf = bufnr ,
38+ range = { top , bot },
39+ statuscolumn = true ,
40+ })
41+ end
42+ end
43+
44+ function M .statuscolumn ()
45+ if not statuscolumn_active then
46+ config .signcolumn = false
47+ statuscolumn_active = true
48+ end
49+
50+ local res = {}
51+ local res_len = 0
52+ local max_pad = 0
53+ local lnum = vim .v .lnum
54+ for _ , signs in pairs ({ signs_normal , signs_staged }) do
55+ if next (signs .signs ) then
56+ max_pad = 2
57+ end
58+ local marks = api .nvim_buf_get_extmarks (0 , signs .ns , { lnum - 1 , 0 }, { lnum - 1 , - 1 }, {})
59+ for _ , mark in pairs (marks ) do
60+ local id = mark [1 ]
61+ local s = signs .signs [id ]
62+ if s then
63+ table.insert (res , ' %#' .. s [2 ] .. ' #' )
64+ table.insert (res , s [1 ])
65+ res_len = res_len + vim .str_utfindex (s [1 ])
66+ table.insert (res , ' %#NONE#' )
67+ end
68+ end
69+ end
70+
71+ local pad = math.max (0 , max_pad - res_len )
72+ return table.concat (res ) .. string.rep (' ' , pad )
73+ end
74+
2975--- @param bufnr integer
3076--- @param signs Gitsigns.Signs
3177--- @param hunks Gitsigns.Hunk.Hunk[]
@@ -77,6 +123,9 @@ local function apply_win_signs(bufnr, top, bot, clear)
77123 if signs_staged then
78124 apply_win_signs0 (bufnr , signs_staged , bcache .hunks_staged , top , bot , clear , false )
79125 end
126+ if clear then
127+ redraw_statuscol (bufnr , top , bot )
128+ end
80129end
81130
82131--- @param blame table<integer,Gitsigns.BlameInfo ? >?
@@ -349,7 +398,7 @@ function M.show_deleted_in_float(bufnr, nsd, hunk, staged)
349398
350399 -- Navigate to hunk
351400 vim .cmd (' normal ' .. tostring (hunk .removed .start ) .. ' gg' )
352- vim .cmd (' normal ' .. vim . api .nvim_replace_termcodes (' z<CR>' , true , false , true ))
401+ vim .cmd (' normal ' .. api .nvim_replace_termcodes (' z<CR>' , true , false , true ))
353402 end )
354403
355404 local last_lnum = api .nvim_buf_line_count (bufnr )
@@ -531,6 +580,7 @@ function M.detach(bufnr, keep_signs)
531580 if signs_staged then
532581 signs_staged :remove (bufnr )
533582 end
583+ redraw_statuscol (bufnr )
534584 end
535585end
536586
@@ -542,6 +592,7 @@ function M.reset_signs()
542592 if signs_staged then
543593 signs_staged :reset ()
544594 end
595+ redraw_statuscol ()
545596end
546597
547598--- @param _cb ' win'
0 commit comments