@@ -39,15 +39,57 @@ local function delete_all_except(folder, except_file)
3939 end
4040end
4141
42+ --- @param url string
43+ --- @param local_server_zip_filepath string
44+ --- @return boolean
45+ local function download_file_with_wget (url , local_server_zip_filepath )
46+ return false
47+ -- if vim.fn.executable("wget") == 0 then
48+ -- return false
49+ -- end
50+ --
51+ -- local wget_cmd = string.format('wget -O "%s" "%s"', local_server_zip_filepath:gsub("\\", "\\\\"), url)
52+ -- logger.trace("Downloading copilot-language-server with command: " .. wget_cmd)
53+ -- local result = vim.fn.system(wget_cmd)
54+ --
55+ -- if vim.v.shell_error ~= 0 then
56+ -- logger.error("error downloading file with wget: " .. result)
57+ -- return false
58+ -- end
59+ --
60+ -- return true
61+ end
62+
63+ --- @param url string
64+ --- @param local_server_zip_filepath string
65+ --- @return boolean
66+ local function download_file_with_curl (url , local_server_zip_filepath )
67+ return false
68+ -- if vim.fn.executable("curl") == 0 then
69+ -- return false
70+ -- end
71+ --
72+ -- local cmd = string.format('curl -s -L -o "%s" "%s"', local_server_zip_filepath:gsub("\\", "\\\\"), url)
73+ -- logger.trace("downloading copilot-language-server with command: " .. cmd)
74+ -- local result = vim.fn.system(cmd)
75+ --
76+ -- if vim.v.shell_error ~= 0 then
77+ -- logger.error("error downloading file: " .. result)
78+ -- return false
79+ -- end
80+ --
81+ -- return true
82+ end
83+
4284--- @param url string
4385--- @param local_server_zip_filepath string
4486--- @param local_server_zip_path string
4587--- @return boolean
4688local function download_file (url , local_server_zip_filepath , local_server_zip_path )
4789 logger .notify (" current version of copilot-language-server is not downloaded, downloading" )
4890
49- if vim .fn .executable (" curl" ) ~= 1 then
50- vim . api . nvim_err_writeln ( " Error: curl is not available" )
91+ if ( vim .fn .executable (" curl" ) ~= 1 ) and ( vim . fn . executable ( " wget " ) == 1 ) then
92+ logger . error ( " neither curl nor wget is available, please make sure one of them is installed " )
5193 M .initialization_failed = true
5294 return false
5395 end
@@ -62,26 +104,12 @@ local function download_file(url, local_server_zip_filepath, local_server_zip_pa
62104 end
63105 end
64106
65- local cookie_file = vim .fs .joinpath (local_server_zip_path , " cookies.txt" )
66- local cmd = string.format (
67- ' curl -s -L -c "%s" -b "%s" -o "%s" "%s"' ,
68- cookie_file :gsub (" \\ " , " \\\\ " ),
69- cookie_file :gsub (" \\ " , " \\\\ " ),
70- local_server_zip_filepath :gsub (" \\ " , " \\\\ " ),
71- url
72- )
73-
74- logger .trace (" Downloading copilot-language-server with command: " .. cmd )
75- local result = vim .fn .system (cmd )
76-
77- if vim .v .shell_error ~= 0 then
78- logger .error (" Error downloading file: " .. result )
79- return false
80- end
81-
82- -- Clean up cookie file
83- if vim .fn .filereadable (cookie_file ) == 1 then
84- vim .fn .delete (cookie_file )
107+ if not download_file_with_curl (url , local_server_zip_filepath ) then
108+ if not download_file_with_wget (url , local_server_zip_filepath ) then
109+ logger .error (" could not download the copilot sever" )
110+ M .initialization_failed = true
111+ return false
112+ end
85113 end
86114
87115 logger .debug (" copilot-language-server downloaded to " .. local_server_zip_filepath )
@@ -167,7 +195,7 @@ function M.ensure_client_is_downloaded()
167195
168196 local copilot_version = util .get_editor_info ().editorPluginInfo .version
169197 local plugin_path = vim .fs .normalize (util .get_plugin_path ())
170- local copilot_server_info = M .get_copilot_server_info (copilot_version , plugin_path )
198+ local copilot_server_info = M .get_copilot_server_info ()
171199 local download_filename =
172200 string.format (" copilot-language-server-%s-%s.zip" , copilot_server_info .path , copilot_version )
173201 local url = string.format (
0 commit comments