@@ -2,8 +2,8 @@ local slC = {};
2
2
local utils = require (" bars.utils" );
3
3
4
4
--- Shows current git branch.
5
- --- @param _ any
6
- --- @param window any
5
+ --- @param _ integer
6
+ --- @param window integer
7
7
--- @param main_config statusline.parts.branch
8
8
--- @return string
9
9
slC .branch = function (_ , window , main_config )
@@ -134,8 +134,8 @@ slC.branch = function (_, window, main_config)
134
134
end
135
135
136
136
--- Shows the buffer name.
137
- --- @param buffer any
138
- --- @param _ any
137
+ --- @param buffer integer
138
+ --- @param _ integer
139
139
--- @param main_config statusline.parts.bufname
140
140
slC .bufname = function (buffer , _ , main_config )
141
141
--- | fS
@@ -153,7 +153,7 @@ slC.bufname = function (buffer, _, main_config)
153
153
if vim .fn .strchars (fname ) <= name_len then
154
154
return fname ;
155
155
else
156
- local truncate_symbol = main_config .truncate_symbol or " > " ;
156
+ local truncate_symbol = main_config .truncate_symbol or " … " ;
157
157
158
158
local ext = vim .fn .fnamemodify (fname , " :e" );
159
159
local name = vim .fn .fnamemodify (fname , " :t:r" );
@@ -335,14 +335,15 @@ slC.diagnostics = function (buffer, window, config)
335
335
336
336
return table.concat ({
337
337
" %@v:lua.__change_diagnostic_state@" ,
338
+ utils .set_hl (config .hl ),
338
339
339
- string.format (" %s%s" , utils .set_hl (config .corner_left_hl or config . hl ), config .corner_left or " " ),
340
- string.format (" %s%s" , utils .set_hl (config .padding_left_hl or config . hl ), config .padding_left or " " ),
340
+ string.format (" %s%s" , utils .set_hl (config .corner_left_hl ), config .corner_left or " " ),
341
+ string.format (" %s%s" , utils .set_hl (config .padding_left_hl ), config .padding_left or " " ),
341
342
342
343
_d or " " ,
343
344
344
- string.format (" %s%s" , utils .set_hl (config .padding_right_hl or config . hl ), config .padding_right or " " ),
345
- string.format (" %s%s" , utils .set_hl (config .corner_right_hl or config . hl ), config .corner_right or " " ),
345
+ string.format (" %s%s" , utils .set_hl (config .padding_right_hl ), config .padding_right or " " ),
346
+ string.format (" %s%s" , utils .set_hl (config .corner_right_hl ), config .corner_right or " " ),
346
347
347
348
" %X"
348
349
});
@@ -358,72 +359,72 @@ slC.empty = function (_, _, config)
358
359
end
359
360
360
361
--- Shows current mode.
361
- --- @param _ integer Buffer ID.
362
- --- @param window integer Window ID.
363
362
--- @param main_config statusline.parts.mode
364
363
--- @return string
365
- slC .mode = function (_ , window , main_config )
364
+ slC .mode = function (_ , _ , main_config )
366
365
--- | fS
367
366
368
367
local ignore = { " default" , " min_width" , " kind" , " condition" , " kind" };
369
368
370
369
--- @type string Current mode shorthand.
371
370
local mode = vim .api .nvim_get_mode ().mode ;
371
+ --- @type mode.opts
372
372
local config = utils .match (main_config , mode , ignore );
373
373
374
- local min_width = main_config .min_width or 42 ;
375
-
376
- local w = vim .api .nvim_win_get_width (window )
377
-
378
- if window ~= vim .api .nvim_get_current_win () or w <= min_width then
374
+ if main_config .compact then
379
375
return table.concat ({
380
- string.format (" %s%s" , utils .set_hl (config .corner_left_hl or config .hl ), config .corner_left or " " ),
381
- string.format (" %s%s" , utils .set_hl (config .padding_left_hl or config .hl ), config .padding_left or " " ),
376
+ utils .set_hl (config .hl ),
377
+
378
+ string.format (" %s%s" , utils .set_hl (config .corner_left_hl ), config .corner_left or " " ),
379
+ string.format (" %s%s" , utils .set_hl (config .padding_left_hl ), config .padding_left or " " ),
382
380
383
- string.format (" %s%s" , utils .set_hl (config .padding_right_hl or config . hl ), config .padding_right or " " ),
384
- string.format (" %s%s" , utils .set_hl (config .corner_right_hl or config . hl ), config .corner_right or " " ),
381
+ string.format (" %s%s" , utils .set_hl (config .padding_right_hl ), config .padding_right or " " ),
382
+ string.format (" %s%s" , utils .set_hl (config .corner_right_hl ), config .corner_right or " " ),
385
383
});
386
384
else
387
385
return table.concat ({
388
- string.format (" %s%s" , utils .set_hl (config .corner_left_hl or config .hl ), config .corner_left or " " ),
389
- string.format (" %s%s" , utils .set_hl (config .padding_left_hl or config .hl ), config .padding_left or " " ),
390
- string.format (" %s%s" , utils .set_hl (config .icon_hl or config .hl ), config .icon or " " ),
386
+ utils .set_hl (config .hl ),
391
387
392
- string.format (" %s%s" , utils .set_hl (config .hl ), config .text or mode or " " ),
388
+ string.format (" %s%s" , utils .set_hl (config .corner_left_hl ), config .corner_left or " " ),
389
+ string.format (" %s%s" , utils .set_hl (config .padding_left_hl ), config .padding_left or " " ),
390
+ string.format (" %s%s" , utils .set_hl (config .icon_hl ), config .icon or " " ),
393
391
394
- string.format (" %s%s" , utils .set_hl (config .padding_right_hl or config .hl ), config .padding_right or " " ),
395
- string.format (" %s%s" , utils .set_hl (config .corner_right_hl or config .hl ), config .corner_right or " " ),
392
+ string.format (" %s" , config .text or mode or " " ),
393
+
394
+ string.format (" %s%s" , utils .set_hl (config .padding_right_hl ), config .padding_right or " " ),
395
+ string.format (" %s%s" , utils .set_hl (config .corner_right_hl ), config .corner_right or " " ),
396
396
});
397
397
end
398
398
399
399
--- | fE
400
400
end
401
401
402
- --- New section.
403
- --- @param config statusline.parts.section Configuration.
402
+ --- Custom section.
403
+ --- @param config statusline.parts.section
404
404
--- @return string
405
405
slC .section = function (_ , _ , config , _ )
406
406
--- | fS
407
407
408
408
return table.concat ({
409
409
config .click and string.format (" %@%s@" , config .click ) or " " ,
410
+ utils .set_hl (config .hl ),
410
411
411
- string.format (" %s%s" , utils .set_hl (config .corner_left_hl or config . hl ), config .corner_left or " " ),
412
- string.format (" %s%s" , utils .set_hl (config .padding_left_hl or config . hl ), config .padding_left or " " ),
413
- string.format (" %s%s" , utils .set_hl (config .icon_hl or config . hl ), config .icon or " " ),
412
+ string.format (" %s%s" , utils .set_hl (config .corner_left_hl ), config .corner_left or " " ),
413
+ string.format (" %s%s" , utils .set_hl (config .padding_left_hl ), config .padding_left or " " ),
414
+ string.format (" %s%s" , utils .set_hl (config .icon_hl ), config .icon or " " ),
414
415
415
416
string.format (" %s%s" , utils .set_hl (config .hl ), config .text or " " ),
416
417
417
- string.format (" %s%s" , utils .set_hl (config .padding_right_hl or config . hl ), config .padding_right or " " ),
418
- string.format (" %s%s" , utils .set_hl (config .corner_right_hl or config . hl ), config .corner_right or " " ),
418
+ string.format (" %s%s" , utils .set_hl (config .padding_right_hl ), config .padding_right or " " ),
419
+ string.format (" %s%s" , utils .set_hl (config .corner_right_hl ), config .corner_right or " " ),
419
420
420
421
config .click and " %X" or " " ,
421
422
});
422
423
423
424
--- | fE
424
425
end
425
426
426
- --- Custom ruler
427
+ --- Ruler.
427
428
--- @param _ integer
428
429
--- @param window integer
429
430
--- @param main_config statusline.parts.ruler
@@ -456,14 +457,16 @@ slC.ruler = function (_, window, main_config)
456
457
end
457
458
458
459
return table.concat ({
459
- string.format (" %s%s" , utils .set_hl (config .corner_left_hl or config .hl ), config .corner_left or " " ),
460
- string.format (" %s%s" , utils .set_hl (config .padding_left_hl or config .hl ), config .padding_left or " " ),
461
- string.format (" %s%s" , utils .set_hl (config .icon_hl or config .hl ), config .icon or " " ),
460
+ utils .set_hl (config .hl ),
461
+
462
+ string.format (" %s%s" , utils .set_hl (config .corner_left_hl ), config .corner_left or " " ),
463
+ string.format (" %s%s" , utils .set_hl (config .padding_left_hl ), config .padding_left or " " ),
464
+ string.format (" %s%s" , utils .set_hl (config .icon_hl ), config .icon or " " ),
462
465
463
466
string.format (" %s%s%s" , x , config .separator or " " , y ),
464
467
465
- string.format (" %s%s" , utils .set_hl (config .padding_right_hl or config . hl ), config .padding_right or " " ),
466
- string.format (" %s%s" , utils .set_hl (config .corner_right_hl or config . hl ), config .corner_right or " " )
468
+ string.format (" %s%s" , utils .set_hl (config .padding_right_hl ), config .padding_right or " " ),
469
+ string.format (" %s%s" , utils .set_hl (config .corner_right_hl ), config .corner_right or " " )
467
470
});
468
471
469
472
--- | fE
@@ -485,7 +488,7 @@ slC.get = function (name, buffer, window, part_config, statusline)
485
488
--- Component doesn't exist.
486
489
return " " ;
487
490
elseif type (slC [name ]) ~= " function" then
488
- --- Attempting to get internal property .
491
+ --- Not a valid component .
489
492
return " " ;
490
493
else
491
494
if part_config .condition ~= nil then
0 commit comments