1
+ local utils = require (" heirline.utils" )
2
+
1
3
-- Now we define some dictionaries to map the output of mode() to the
2
4
-- corresponding string and color. We can put these into `static` to compute
3
5
-- them at initialisation time.
@@ -51,6 +53,25 @@ local mode_colors = {
51
53
t = " red" ,
52
54
}
53
55
56
+ local function mode_hl ()
57
+ local mode = vim .fn .mode (1 ):sub (1 , 1 ):lower () -- get only the first mode character
58
+
59
+ -- My hardcoded settings
60
+ if mode == " n" then
61
+ return " StatusLine"
62
+ elseif mode == " c" then
63
+ return " DiffDelete"
64
+ elseif mode == " i" then
65
+ return " dkoStatusItem"
66
+ elseif mode == " r" then
67
+ return " dkoLineModeReplace"
68
+ elseif mode == " v" then
69
+ return " Cursor"
70
+ end
71
+
72
+ return { fg = mode_colors [mode ] }
73
+ end
74
+
54
75
return {
55
76
-- get vim current mode, this information will be required by the provider
56
77
-- and the highlight functions, so we compute it only once per component
@@ -69,32 +90,25 @@ return {
69
90
end
70
91
end ,
71
92
72
- provider = function (self )
73
- return mode_names [self .mode ]
74
- end ,
75
-
76
- -- Same goes for the highlight. Now the foreground will change according to the current mode.
77
- hl = function (self )
78
- local mode = self .mode :sub (1 , 1 ):lower () -- get only the first mode character
79
-
80
- -- My hardcoded settings
81
- if mode == " n" then
82
- return " StatusLine"
83
- elseif mode == " c" then
84
- return " DiffDelete"
85
- elseif mode == " i" then
86
- return " dkoStatusItem"
87
- elseif mode == " r" then
88
- return " dkoLineModeReplace"
89
- elseif mode == " v" then
90
- return " Cursor"
93
+ utils .surround ({ " █" , " " }, function ()
94
+ local hl = mode_hl ()
95
+ if type (hl ) == " string" then
96
+ return utils .get_highlight (hl ).bg
91
97
end
98
+ return utils .get_highlight (" StatusLine" ).bg
99
+ end , {
100
+ provider = function (self )
101
+ return mode_names [self .mode ]
102
+ end ,
92
103
93
- return { fg = mode_colors [mode ] }
94
- end ,
104
+ -- Same goes for the highlight. Now the foreground will change according to the current mode.
105
+ hl = function ()
106
+ return mode_hl ()
107
+ end ,
95
108
96
- -- Re-evaluate the component only on ModeChanged event!
97
- -- This is not required in any way, but it's there, and it's a small
98
- -- performance improvement.
99
- update = { " ModeChanged" , " TermLeave" },
109
+ -- Re-evaluate the component only on ModeChanged event!
110
+ -- This is not required in any way, but it's there, and it's a small
111
+ -- performance improvement.
112
+ update = { " ModeChanged" , " TermLeave" },
113
+ }),
100
114
}
0 commit comments