@@ -39,15 +39,57 @@ local function delete_all_except(folder, except_file)
39
39
end
40
40
end
41
41
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
+
42
84
--- @param url string
43
85
--- @param local_server_zip_filepath string
44
86
--- @param local_server_zip_path string
45
87
--- @return boolean
46
88
local function download_file (url , local_server_zip_filepath , local_server_zip_path )
47
89
logger .notify (" current version of copilot-language-server is not downloaded, downloading" )
48
90
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 " )
51
93
M .initialization_failed = true
52
94
return false
53
95
end
@@ -62,26 +104,12 @@ local function download_file(url, local_server_zip_filepath, local_server_zip_pa
62
104
end
63
105
end
64
106
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
85
113
end
86
114
87
115
logger .debug (" copilot-language-server downloaded to " .. local_server_zip_filepath )
@@ -167,7 +195,7 @@ function M.ensure_client_is_downloaded()
167
195
168
196
local copilot_version = util .get_editor_info ().editorPluginInfo .version
169
197
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 ()
171
199
local download_filename =
172
200
string.format (" copilot-language-server-%s-%s.zip" , copilot_server_info .path , copilot_version )
173
201
local url = string.format (
0 commit comments