@@ -17,6 +17,8 @@ vim.g.__tabline = utils.constant(vim.o.tabline);
17
17
18
18
--- | fE
19
19
20
+ --- Attach various bars & lines globally if
21
+ --- `global = true`.
20
22
if require (" bars" ).config .global == true then
21
23
require (" bars.statuscolumn" ).global_attach ();
22
24
require (" bars.statusline" ).global_attach ();
27
29
require (" bars.tabline" ).attach ();
28
30
end
29
31
32
+ --- Attach to new Windows.
33
+ ---
34
+ --- Also rum this when a buffer is displayed
35
+ --- in a window as the filetype/buftype may
36
+ --- could have changed.
37
+ ---
38
+ --- `VimEnter` is used because the other events
39
+ --- don't trigger when entering Neovim.
30
40
vim .api .nvim_create_autocmd ({
31
41
" VimEnter" ,
32
42
33
43
" WinNew" ,
34
44
" BufWinEnter"
35
45
}, {
36
46
callback = function ()
47
+ --- | fS
48
+
37
49
require (" bars.statusline" ).clean ();
38
50
require (" bars.statuscolumn" ).clean ();
39
51
require (" bars.winbar" ).clean ();
@@ -47,12 +59,22 @@ vim.api.nvim_create_autocmd({
47
59
end
48
60
49
61
require (" bars.tabline" ).attach ();
50
- end )
62
+ end );
63
+
64
+ --- | fE
51
65
end
52
66
});
53
67
68
+ --- When the 'filetype' or 'buftype' option is set
69
+ --- we must clean up any window that has become invalid
70
+ --- and update the configuration of existing windows.
71
+ ---
72
+ --- TODO, Check if this causes performance issues
73
+ --- with large amount of windows.
54
74
vim .api .nvim_create_autocmd ({ " OptionSet" }, {
55
75
callback = function ()
76
+ --- | fS
77
+
56
78
local option = vim .fn .expand (" <amatch>" );
57
79
local valid_options = { " filetype" , " buftype" };
58
80
@@ -74,6 +96,27 @@ vim.api.nvim_create_autocmd({ "OptionSet" }, {
74
96
end
75
97
76
98
require (" bars.tabline" ).attach ();
77
- end )
99
+ end );
100
+
101
+ --- | fE
102
+ end
103
+ });
104
+
105
+ --- Update various bars & lines on Vim mode change.
106
+ vim .api .nvim_create_autocmd ({ " ModeChanged" }, {
107
+ callback = function (event )
108
+ --- | fS
109
+
110
+ pcall (vim .api .nvim__redraw , {
111
+ buf = event .buf ,
112
+ flush = true ,
113
+
114
+ statuscolumn = true ,
115
+ statusline = true ,
116
+ winbar = true ,
117
+ tabline = true
118
+ });
119
+
120
+ --- | fE
78
121
end
79
122
});
0 commit comments