360
360
statuscolumn .can_attach = function (win )
361
361
if vim .api .nvim_win_is_valid (win ) == false then
362
362
return false ;
363
+ elseif statuscolumn .state .attached_windows [win ] == false then
364
+ return false ;
365
+ elseif statuscolumn .state .enable == false then
366
+ return false ;
363
367
end
364
368
365
369
local buffer = vim .api .nvim_win_get_buf (win );
423
427
424
428
--- Attaches globally.
425
429
statuscolumn .global_attach = function ()
430
+ if statuscolumn .state .enable == false then
431
+ return ;
432
+ end
433
+
426
434
for _ , window in ipairs (vim .api .nvim_list_wins ()) do
427
435
statuscolumn .update_id (window );
428
436
end
@@ -446,6 +454,8 @@ statuscolumn.clean = function ()
446
454
--- | fE
447
455
end
448
456
457
+ ---- ------------------------------------------------------------------
458
+
449
459
--- Toggles state of given window.
450
460
--- @param window integer
451
461
statuscolumn .toggle = function (window )
@@ -454,7 +464,7 @@ statuscolumn.toggle = function (window)
454
464
elseif statuscolumn .state .attached_windows [window ] == true then
455
465
statuscolumn .detach (window );
456
466
else
457
- statuscolumn .attach (window );
467
+ statuscolumn .attach (window );
458
468
end
459
469
end
460
470
@@ -471,6 +481,52 @@ statuscolumn.Toggle = function ()
471
481
statuscolumn .state .enable = not statuscolumn .state .enable ;
472
482
end
473
483
484
+ ---- ------------------------------------------------------------------
485
+
486
+ --- Enables statuscolumn for `window`.
487
+ --- @param window integer
488
+ statuscolumn .enable = function (window )
489
+ if type (window ) ~= " number" or statuscolumn .state .attached_windows [window ] == nil then
490
+ return ;
491
+ end
492
+
493
+ statuscolumn .attach (window );
494
+ end
495
+
496
+ --- Enables *all* attached windows.
497
+ statuscolumn .Enable = function ()
498
+ statuscolumn .state .enable = true ;
499
+
500
+ for window , state in pairs (statuscolumn .state .attached_windows ) do
501
+ if state ~= true then
502
+ statuscolumn .attach (window );
503
+ end
504
+ end
505
+ end
506
+
507
+ --- Disables statuscolumn for `window`.
508
+ --- @param window integer
509
+ statuscolumn .disable = function (window )
510
+ if type (window ) ~= " number" or statuscolumn .state .attached_windows [window ] == nil then
511
+ return ;
512
+ end
513
+
514
+ statuscolumn .detach (window );
515
+ end
516
+
517
+ --- Disables *all* attached windows.
518
+ statuscolumn .Disable = function ()
519
+ for window , state in pairs (statuscolumn .state .attached_windows ) do
520
+ if state ~= false then
521
+ statuscolumn .detach (window );
522
+ end
523
+ end
524
+
525
+ statuscolumn .state .enable = false ;
526
+ end
527
+
528
+ ---- ------------------------------------------------------------------
529
+
474
530
--- Sets up the statuscolumn module.
475
531
--- @param config statuscolumn.config | nil
476
532
statuscolumn .setup = function (config )
0 commit comments