Skip to content

Commit 7ed1b16

Browse files
committed
fix(statuscolumn): Fixed a bug with current line number not having correct highlight
1 parent d09dbc7 commit 7ed1b16

File tree

1 file changed

+35
-33
lines changed

1 file changed

+35
-33
lines changed

lua/bars/statuscolumn.lua

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@ local statuscolumn = {};
55
---@type string
66
local STC = "%!v:lua.require('bars.statuscolumn').render()";
77

8+
local gradient_map = {
9+
default = "BarsNormal%d",
10+
11+
["v"] = "BarsVisual%d",
12+
["V"] = "BarsVisualLine%d",
13+
[""] = "BarsVisualBlock%d",
14+
15+
["s"] = "BarsVisual%d",
16+
["S"] = "BarsVisualLine%d",
17+
[""] = "BarsVisualBlock%d",
18+
19+
["i"] = "BarsInsert%d",
20+
["ic"] = "BarsInsert%d",
21+
["ix"] = "BarsInsert%d",
22+
23+
["R"] = "BarsInsert%d",
24+
["Rc"] = "BarsInsert%d",
25+
26+
["c"] = "BarsCommand%d",
27+
["!"] = "BarsCommand%d",
28+
};
29+
30+
831
---@type statuscolumn.config
932
statuscolumn.config = {
1033
ignore_filetypes = { "blink-cmp-menu" },
@@ -114,50 +137,31 @@ statuscolumn.config = {
114137
virt_hl = {
115138
"BarsVirtual1", "BarsVirtual2", "BarsVirtual3", "BarsVirtual4", "BarsVirtual5",
116139
},
117-
hl = {
118-
"BarsLineNr",
119-
"LineNr",
120-
}
140+
hl = function ()
141+
---@type string
142+
local mode = vim.api.nvim_get_mode().mode;
143+
local USE = gradient_map[mode] or gradient_map.default
144+
145+
return {
146+
string.format(USE, 1),
147+
"LineNr",
148+
};
149+
end,
121150
},
122151
{
123152
kind = "border",
124153
text = "",
125-
hl = function (_, window)
126-
---|fS "Color matching the mode"
127-
154+
hl = function ()
128155
local _o = {};
129-
local gr_map = {
130-
default = "BarsNormal%d",
131-
132-
["v"] = "BarsVisual%d",
133-
["V"] = "BarsVisualLine%d",
134-
[""] = "BarsVisualBlock%d",
135-
136-
["s"] = "BarsVisual%d",
137-
["S"] = "BarsVisualLine%d",
138-
[""] = "BarsVisualBlock%d",
139-
140-
["i"] = "BarsInsert%d",
141-
["ic"] = "BarsInsert%d",
142-
["ix"] = "BarsInsert%d",
143-
144-
["R"] = "BarsInsert%d",
145-
["Rc"] = "BarsInsert%d",
146-
147-
["c"] = "BarsCommand%d",
148-
["!"] = "BarsCommand%d",
149-
};
150-
151156
---@type string
152157
local mode = vim.api.nvim_get_mode().mode;
153-
local USE = gr_map[mode] or gr_map.default
158+
local USE = gradient_map[mode] or gradient_map.default
154159

155160
for g = 1, 7 do
156161
table.insert(_o, string.format(USE, g));
157162
end
158163

159164
return _o;
160-
---|fE
161165
end
162166
},
163167
{
@@ -393,6 +397,4 @@ statuscolumn.setup = function (config)
393397
---|fE
394398
end
395399

396-
local times = {};
397-
398400
return statuscolumn;

0 commit comments

Comments
 (0)