@@ -37,16 +37,45 @@ M.get_client = function(name)
3737end
3838
3939M .get_spring_boot_client = function ()
40- return M .get_client (" spring-boot" )
40+ local clients = vim .lsp .get_clients ({ name = " spring-boot" })
41+ if clients and # clients > 0 then
42+ return clients [1 ]
43+ end
44+ return nil
4145end
42- M .boot_execute_command = function (command , param , callback )
43- local err , resp = M .execute_command (M .get_spring_boot_client (), command , param , callback )
46+
47+ M ._boot_command_co = {}
48+ local function boot_client_execute_command (client , command , param , callback )
49+ local err , resp = M .execute_command (client , command , param , callback )
4450 if err then
4551 print (" Error executeCommand: " .. command .. " \n " .. vim .inspect (err ))
4652 end
4753 return resp
4854end
4955
56+ M .boot_ls_init = function (_ , _ )
57+ for _ , co in ipairs (M ._boot_command_co ) do
58+ coroutine.resume (co )
59+ end
60+ M ._boot_command_co = {}
61+ end
62+
63+ M .boot_execute_command = function (command , param , callback )
64+ local client = M .get_spring_boot_client ()
65+ if client then
66+ return boot_client_execute_command (client , command , param , callback )
67+ end
68+ vim .notify (" Spring Boot LS is not ready, waiting for start" , vim .log .levels .INFO )
69+ local pco = coroutine.running ()
70+ local co = coroutine.create (function ()
71+ local resp = boot_client_execute_command (M .get_spring_boot_client (), command , param , callback )
72+ coroutine.resume (pco , resp )
73+ return resp
74+ end )
75+ table.insert (M ._boot_command_co , co )
76+ return coroutine.yield ()
77+ end
78+
5079M .execute_command = function (client , command , param , callback )
5180 local co
5281 if not callback then
0 commit comments