@@ -8,6 +8,7 @@ local default_config = {
8
8
copy = 0.15 ,
9
9
delete = 0.15 ,
10
10
change = 0.15 ,
11
+ format = 0.15 ,
11
12
insert = 0.15 ,
12
13
visual = 0.15 ,
13
14
},
@@ -41,12 +42,6 @@ local winhighlight = {
41
42
CursorLineSign = ' ModesCopyCursorLineSign' ,
42
43
CursorLineFold = ' ModesCopyCursorLineFold' ,
43
44
},
44
- insert = {
45
- CursorLine = ' ModesInsertCursorLine' ,
46
- CursorLineNr = ' ModesInsertCursorLineNr' ,
47
- CursorLineSign = ' ModesInsertCursorLineSign' ,
48
- CursorLineFold = ' ModesInsertCursorLineFold' ,
49
- },
50
45
delete = {
51
46
CursorLine = ' ModesDeleteCursorLine' ,
52
47
CursorLineNr = ' ModesDeleteCursorLineNr' ,
@@ -59,6 +54,18 @@ local winhighlight = {
59
54
CursorLineSign = ' ModesChangeCursorLineSign' ,
60
55
CursorLineFold = ' ModesChangeCursorLineFold' ,
61
56
},
57
+ format = {
58
+ CursorLine = ' ModesFormatCursorLine' ,
59
+ CursorLineNr = ' ModesFormatCursorLineNr' ,
60
+ CursorLineSign = ' ModesFormatCursorLineSign' ,
61
+ CursorLineFold = ' ModesFormatCursorLineFold' ,
62
+ },
63
+ insert = {
64
+ CursorLine = ' ModesInsertCursorLine' ,
65
+ CursorLineNr = ' ModesInsertCursorLineNr' ,
66
+ CursorLineSign = ' ModesInsertCursorLineSign' ,
67
+ CursorLineFold = ' ModesInsertCursorLineFold' ,
68
+ },
62
69
visual = {
63
70
CursorLine = ' ModesVisualCursorLine' ,
64
71
CursorLineNr = ' ModesVisualCursorLineNr' ,
@@ -90,7 +97,7 @@ M.restore = function()
90
97
end
91
98
92
99
--- Update highlights
93
- --- @param scene ' default' | ' insert ' | ' visual ' | ' copy ' | ' delete ' | ' change '
100
+ --- @param scene ' default' | ' copy ' | ' delete ' | ' change ' | ' format ' | ' insert ' | ' visual '
94
101
M .highlight = function (scene )
95
102
if in_ignored_buffer () then
96
103
return
@@ -132,26 +139,28 @@ M.highlight = function(scene)
132
139
vim .api .nvim_set_option_value (' winhighlight' , table.concat (new_value , ' ,' ), { win = 0 })
133
140
134
141
if vim .api .nvim_get_option_value (' showmode' , { scope = ' global' }) then
135
- if scene == ' visual' then
136
- utils .set_hl (' ModeMsg' , { link = ' ModesVisualModeMsg' })
137
- elseif scene == ' insert' then
142
+ if scene == ' insert' then
138
143
utils .set_hl (' ModeMsg' , { link = ' ModesInsertModeMsg' })
144
+ elseif scene == ' visual' then
145
+ utils .set_hl (' ModeMsg' , { link = ' ModesVisualModeMsg' })
139
146
else
140
147
utils .set_hl (' ModeMsg' , { link = ' ModesDefaultModeMsg' })
141
148
end
142
149
end
143
150
144
151
if config .set_cursor then
145
- if scene == ' delete' then
146
- utils .set_hl (' ModesOperator' , { link = ' ModesDelete' })
147
- elseif scene == ' copy' then
152
+ if scene == ' copy' then
148
153
utils .set_hl (' ModesOperator' , { link = ' ModesCopy' })
149
- elseif scene == ' visual' then
150
- utils .set_hl (' ModesOperator' , { link = ' ModesVisual' })
151
- elseif scene == ' insert' then
152
- utils .set_hl (' ModesOperator' , { link = ' ModesInsert' })
154
+ elseif scene == ' delete' then
155
+ utils .set_hl (' ModesOperator' , { link = ' ModesDelete' })
153
156
elseif scene == ' change' then
154
157
utils .set_hl (' ModesOperator' , { link = ' ModesChange' })
158
+ elseif scene == ' format' then
159
+ utils .set_hl (' ModesOperator' , { link = ' ModesFormat' })
160
+ elseif scene == ' insert' then
161
+ utils .set_hl (' ModesOperator' , { link = ' ModesInsert' })
162
+ elseif scene == ' visual' then
163
+ utils .set_hl (' ModesOperator' , { link = ' ModesVisual' })
155
164
else
156
165
utils .set_hl (' ModesOperator' , { link = ' ModesDefault' })
157
166
end
@@ -175,6 +184,7 @@ M.define = function()
175
184
bg = config .colors .bg or utils .get_bg (' Normal' , ' Normal' ),
176
185
copy = config .colors .copy or utils .get_bg (' ModesCopy' , ' #f5c359' ),
177
186
delete = config .colors .delete or utils .get_bg (' ModesDelete' , ' #c75c6a' ),
187
+ format = config .colors .format or utils .get_bg (' ModesFormat' , ' #c79585' ),
178
188
insert = config .colors .insert or utils .get_bg (' ModesInsert' , ' #78ccc5' ),
179
189
visual = config .colors .visual or utils .get_bg (' ModesVisual' , ' #9745be' ),
180
190
}
@@ -192,6 +202,11 @@ M.define = function()
192
202
colors .bg ,
193
203
config .line_opacity .change
194
204
),
205
+ format = utils .blend (
206
+ colors .format ,
207
+ colors .bg ,
208
+ config .line_opacity .format
209
+ ),
195
210
insert = utils .blend (
196
211
colors .insert ,
197
212
colors .bg ,
@@ -211,15 +226,18 @@ M.define = function()
211
226
if colors .delete ~= ' ' then
212
227
vim .cmd (' hi ModesDelete guibg=' .. colors .delete )
213
228
end
229
+ if colors .change ~= ' ' then
230
+ vim .cmd (' hi ModesChange guibg=' .. colors .change )
231
+ end
232
+ if colors .format ~= ' ' then
233
+ vim .cmd (' hi ModesFormat guibg=' .. colors .format )
234
+ end
214
235
if colors .insert ~= ' ' then
215
236
vim .cmd (' hi ModesInsert guibg=' .. colors .insert )
216
237
end
217
238
if colors .visual ~= ' ' then
218
239
vim .cmd (' hi ModesVisual guibg=' .. colors .visual )
219
240
end
220
- if colors .change ~= ' ' then
221
- vim .cmd (' hi ModesChange guibg=' .. colors .change )
222
- end
223
241
224
242
local default_operator = utils .get_bg (' Cursor' , ' #524f67' )
225
243
utils .set_hl (' ModesDefault' , { bg = default_operator })
@@ -234,7 +252,7 @@ M.define = function()
234
252
end
235
253
236
254
local line_nr_gui = utils .get_gui (' CursorLineNr' , ' none' )
237
- for _ , mode in ipairs ({ ' Copy' , ' Delete' , ' Insert ' , ' Visual ' , ' Change ' }) do
255
+ for _ , mode in ipairs ({ ' Copy' , ' Delete' , ' Change ' , ' Format ' , ' Insert ' , ' Visual ' }) do
238
256
local mode_fg = colors [mode :lower ()]
239
257
if mode_fg ~= ' ' then
240
258
local mode_bg = (mode :lower () == ' visual' ) and ' none' or blended_colors [mode :lower ()]
@@ -328,6 +346,7 @@ M.setup = function(opts)
328
346
copy = config .line_opacity ,
329
347
delete = config .line_opacity ,
330
348
change = config .line_opacity ,
349
+ format = config .line_opacity ,
331
350
insert = config .line_opacity ,
332
351
visual = config .line_opacity ,
333
352
}
@@ -346,12 +365,15 @@ M.setup = function(opts)
346
365
vim .api .nvim_create_autocmd (' ModeChanged' , {
347
366
pattern = ' *:no*' ,
348
367
callback = function ()
349
- if vim .v .operator == ' y' then
368
+ local operator = vim .v .operator
369
+ if operator == ' y' then
350
370
M .highlight (' copy' )
351
- elseif vim . v . operator == ' d' then
371
+ elseif operator == ' d' then
352
372
M .highlight (' delete' )
353
- elseif vim . v . operator == ' c' then
373
+ elseif operator == ' c' then
354
374
M .highlight (' change' )
375
+ elseif operator :match (' [=!><g]' ) then
376
+ M .highlight (' format' )
355
377
end
356
378
end ,
357
379
})
0 commit comments