1+ --- @diagnostic disable : undefined-field
2+
13--- Update the tab list when opening new windows.
24vim .api .nvim_create_autocmd ({ " VimEnter" }, {
35 callback = function ()
@@ -180,17 +182,14 @@ vim.api.nvim_create_autocmd({ "ColorScheme" }, {
180182 end
181183});
182184
183-
184- -- ----------------------------------------------------------------------
185+ ---- ------------------------------------------------------------------
185186
186187--- Custom completion for the `?` operator.
187188--- @param before string
188189--- @return string[]
189190_G .__bars_comp = function (before )
190191 --- | fS
191192
192- local bars = require (" bars" );
193-
194193 local tokens = vim .split (before , " " , { trimempty = true });
195194 local modules = { " statusline" , " statuscolumn" , " tabline" , " winbar" };
196195 local _c = {};
@@ -318,9 +317,9 @@ end, {
318317 return vim .list_contains (tokens , tostring (val )) == false and string.match (tostring (val ), arg_lead ) ~= nil ;
319318 end , vim .tbl_keys (module .state .attached_windows ));
320319
321- table . foreach ( _c , function ( key , value )
322- _c [key ] = tostring (value );
323- end )
320+ for k , v in pairs ( _c ) do
321+ _c [k ] = tostring (v );
322+ end
324323
325324 table.sort (_c );
326325 return _c ;
@@ -330,3 +329,81 @@ end, {
330329 end
331330});
332331
332+ ---- ------------------------------------------------------------------
333+
334+ vim .api .nvim_create_autocmd (" LspProgress" , {
335+ callback = function (event )
336+ --- | fS
337+
338+ local kind = event .data .params .value .kind ;
339+ local attached = vim .lsp .get_buffers_by_client_id (event .data .client_id );
340+
341+ --- Sets buffer state
342+ --- @param state " start" | " progress" | " finish" | nil
343+ local function set_state (state )
344+ --- | fS
345+
346+ for _ , buf in ipairs (attached ) do
347+ vim .b [buf ].lsp_loader_state = state ;
348+ end
349+
350+ --- | fE
351+ end
352+
353+ --- Gets the general state.
354+ --- @return " start" | " progress" | " finish" | nil
355+ local function get_state ()
356+ --- | fS
357+
358+ local states = {};
359+
360+ for _ , buf in ipairs (attached ) do
361+ table.insert (states , vim .b [buf ].lsp_loader_state );
362+ end
363+
364+ local state = states [1 ];
365+
366+ for _ , item in ipairs (states ) do
367+ if item ~= state then
368+ return nil ;
369+ end
370+ end
371+
372+ return state ;
373+
374+ --- | fE
375+ end
376+
377+ if kind == " begin" then
378+ set_state (" start" );
379+
380+ local lsp_timer = vim .uv .new_timer ();
381+
382+ lsp_timer :start (0 , 200 , vim .schedule_wrap (function ()
383+ if get_state () == nil then
384+ timer :stop ();
385+ return ;
386+ end
387+
388+ vim .api .nvim__redraw ({ statusline = true });
389+ end ));
390+
391+ vim .api .nvim__redraw ({ statusline = true });
392+ elseif kind == " report" then
393+ set_state (" progress" );
394+ else
395+ set_state (" finish" );
396+
397+ vim .defer_fn (function ()
398+ if get_state () == " finish" then
399+ set_state (nil );
400+ end
401+
402+ vim .api .nvim__redraw ({ statusline = true });
403+ end , 500 );
404+ end
405+
406+ --- | fE
407+ end
408+ });
409+
0 commit comments