@@ -7,8 +7,10 @@ copilot.lsp_start_client = function(cmd, handler_names)
77 for _ , name in ipairs (handler_names ) do
88 handlers [name ] = function (err , result )
99 if result then
10- local retval = vim .call (' copilot#agent#LspHandle' , id , {method = name , params = result })
11- if type (retval ) == ' table' then return retval .result , retval .error end
10+ local retval = vim .call (' copilot#agent#LspHandle' , id , { method = name , params = result })
11+ if type (retval ) == ' table' then
12+ return retval .result , retval .error
13+ end
1214 end
1315 end
1416 if name :match (' ^copilot/' ) then
@@ -32,16 +34,18 @@ copilot.lsp_start_client = function(cmd, handler_names)
3234 vim .schedule (function ()
3335 vim .call (' copilot#agent#LspExit' , client_id , code , signal )
3436 end )
35- end
37+ end ,
3638 })
3739 return id
3840end
3941
4042copilot .lsp_request = function (client_id , method , params )
4143 local client = vim .lsp .get_client_by_id (client_id )
42- if not client then return end
44+ if not client then
45+ return
46+ end
4347 pcall (vim .lsp .buf_attach_client , 0 , client_id )
44- for _ , doc in ipairs ({params .doc , params .textDocument }) do
48+ for _ , doc in ipairs ({ params .doc , params .textDocument }) do
4549 if doc and type (doc .uri ) == ' number' then
4650 local bufnr = doc .uri
4751 pcall (vim .lsp .buf_attach_client , bufnr , client_id )
@@ -51,24 +55,28 @@ copilot.lsp_request = function(client_id, method, params)
5155 end
5256 local _ , id
5357 _ , id = client .request (method , params , function (err , result )
54- vim .call (' copilot#agent#LspResponse' , client_id , {id = id , error = err , result = result })
58+ vim .call (' copilot#agent#LspResponse' , client_id , { id = id , error = err , result = result })
5559 end )
5660 return id
5761end
5862
5963copilot .rpc_request = function (client_id , method , params )
6064 local client = vim .lsp .get_client_by_id (client_id )
61- if not client then return end
65+ if not client then
66+ return
67+ end
6268 local _ , id
6369 _ , id = client .rpc .request (method , params , function (err , result )
64- vim .call (' copilot#agent#LspResponse' , client_id , {id = id , error = err , result = result })
70+ vim .call (' copilot#agent#LspResponse' , client_id , { id = id , error = err , result = result })
6571 end )
6672 return id
6773end
6874
6975copilot .rpc_notify = function (client_id , method , params )
7076 local client = vim .lsp .get_client_by_id (client_id )
71- if not client then return end
77+ if not client then
78+ return
79+ end
7280 return client .rpc .notify (method , params )
7381end
7482
0 commit comments