Skip to content

Commit aba75aa

Browse files
committed
Add an option for controlling sign/scrollbar overlap
1 parent b65192e commit aba75aa

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

autoload/scrollview.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ let g:scrollview_signs_on_startup =
108108
\ get(g:, 'scrollview_signs_on_startup', s:default_signs)
109109
" Specifies the sign overflow direction ('left' or 'right').
110110
let g:scrollview_signs_overflow = get(g:, 'scrollview_signs_overflow', 'left')
111+
let g:scrollview_signs_scrollbar_overlap =
112+
\ get(g:, 'scrollview_signs_scrollbar_overlap', 'off')
111113
" Whether signs in folds should be shown or hidden.
112114
let g:scrollview_signs_show_in_folds =
113115
\ get(g:, 'scrollview_signs_show_in_folds', v:false)

doc/scrollview.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,15 @@ scrollview_signs_overflow *scrollview_signs_overflow*
401401
Possible values are `'left'` or `'right'`. Defaults to
402402
`'left'`.
403403

404+
scrollview_signs_scrollbar_overlap *scrollview_signs_scrollbar_overlap*
405+
|String| specifying whether/how signs overlap the
406+
scrollbar. Possible values are `'off'`, `'over'`, and `'under'`.
407+
Defaults to `'off'`.
408+
* `off` Signs are positioned to never overlap the
409+
scrollbar.
410+
* `over` A sign can be placed over the scrollbar.
411+
* `under` A sign can be placed under the scrollbar.
412+
404413
scrollview_signs_show_in_folds *scrollview_signs_show_in_folds*
405414
|Boolean| specifying whether signs on lines within hidden
406415
folds should be shown. Sign groups can override this

doc/tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ scrollview_signs_hidden_for_insert scrollview.txt /*scrollview_signs_hidden_for_
128128
scrollview_signs_max_per_row scrollview.txt /*scrollview_signs_max_per_row*
129129
scrollview_signs_on_startup scrollview.txt /*scrollview_signs_on_startup*
130130
scrollview_signs_overflow scrollview.txt /*scrollview_signs_overflow*
131+
scrollview_signs_scrollbar_overlap scrollview.txt /*scrollview_signs_scrollbar_overlap*
131132
scrollview_signs_show_in_folds scrollview.txt /*scrollview_signs_show_in_folds*
132133
scrollview_signs_version scrollview.txt /*scrollview_signs_version*
133134
scrollview_spell_priority scrollview.txt /*scrollview_spell_priority*

lua/scrollview.lua

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,16 +1868,17 @@ local show_signs = function(winid, sign_winids, bar_winid)
18681868
-- A set of columns, to prevent creating multiple signs in the same
18691869
-- location.
18701870
local total_width = 0 -- running sum of sign widths
1871+
local bar_row = bar_props ~= nil
1872+
and row >= bar_props.row
1873+
and row <= bar_props.row + bar_props.height - 1
18711874
-- Treat the bar as if it were a sign, and position subsequent signs
18721875
-- accordingly. This only applies if a scrollbar is shown (e.g., not when
18731876
-- it is hidden from hide_on_intersect or not shown because of an invalid
18741877
-- column).
1875-
if bar_props ~= nil
1876-
and row >= bar_props.row
1877-
and row <= bar_props.row + bar_props.height - 1 then
1878+
if vim.g.scrollview_signs_scrollbar_overlap == 'off' and bar_row then
18781879
total_width = total_width + 1
18791880
end
1880-
for _, properties in ipairs(props_list) do
1881+
for properties_idx, properties in ipairs(props_list) do
18811882
local symbol = properties.symbol
18821883
local sign_width = fn.strdisplaywidth(symbol)
18831884
local col = base_col
@@ -1971,6 +1972,13 @@ local show_signs = function(winid, sign_winids, bar_winid)
19711972
if is_float then
19721973
zindex = zindex + config.zindex
19731974
end
1975+
if bar_row and properties_idx == 1 then
1976+
if vim.g.scrollview_signs_scrollbar_overlap == 'over' then
1977+
zindex = zindex + 1
1978+
elseif vim.g.scrollview_signs_scrollbar_overlap == 'under' then
1979+
zindex = zindex - 1
1980+
end
1981+
end
19741982
local sign_config = {
19751983
win = winid,
19761984
relative = 'win',
@@ -1981,7 +1989,7 @@ local show_signs = function(winid, sign_winids, bar_winid)
19811989
width = sign_width,
19821990
row = row - 1,
19831991
col = col - 1,
1984-
zindex = zindex,
1992+
zindex = math.max(1, zindex),
19851993
}
19861994
-- Create a new window if none are available for re-use. Also, create a
19871995
-- new window if the base window is a floating window, to avoid Neovim
@@ -2046,6 +2054,22 @@ local show_signs = function(winid, sign_winids, bar_winid)
20462054
target = 'FloatBorder'
20472055
end
20482056
end
2057+
-- Properly highlight a sign over a scrollbar.
2058+
if bar_props ~= nil
2059+
and bar_row
2060+
and vim.g.scrollview_signs_scrollbar_overlap == 'over'
2061+
and properties_idx == 1 then
2062+
target = 'ScrollView'
2063+
if vim.g.scrollview_hover
2064+
and mousemove_received
2065+
and to_bool(fn.exists('&mousemoveevent'))
2066+
and vim.o.mousemoveevent then
2067+
if is_mouse_over_scrollview_win(bar_props.scrollview_winid)
2068+
or is_mouse_over_scrollview_win(sign_winid) then
2069+
target = 'ScrollViewHover'
2070+
end
2071+
end
2072+
end
20492073
target = get_mapped_highlight(winid, target)
20502074
local winhighlight = string.format(
20512075
'Normal:%s,EndOfBuffer:%s,NormalFloat:%s', target, target, target)

0 commit comments

Comments
 (0)