@@ -151,10 +151,12 @@ local function extract_file(copilot_server_info, local_server_zip_filepath)
151
151
end
152
152
153
153
vim .fn .delete (local_server_zip_filepath )
154
- vim .fn .rename (
155
- vim .fs .joinpath (copilot_server_info .absolute_path , copilot_server_info .extracted_filename ),
156
- copilot_server_info .absolute_filepath
157
- )
154
+ if copilot_server_info .path ~= " js" then
155
+ vim .fn .rename (
156
+ vim .fs .joinpath (copilot_server_info .absolute_path , copilot_server_info .extracted_filename ),
157
+ copilot_server_info .absolute_filepath
158
+ )
159
+ end
158
160
159
161
return true
160
162
end
@@ -221,12 +223,14 @@ function M.ensure_client_is_downloaded()
221
223
return false
222
224
end
223
225
224
- if not set_permissions (copilot_server_info .absolute_filepath ) then
225
- logger .error (" could not set permissions for copilot-language-server" )
226
- return false
226
+ if copilot_server_info .path ~= " js" then
227
+ if not set_permissions (copilot_server_info .absolute_filepath ) then
228
+ logger .error (" could not set permissions for copilot-language-server" )
229
+ return false
230
+ end
231
+ delete_all_except (copilot_server_info .absolute_path , copilot_server_info .filename )
227
232
end
228
233
229
- delete_all_except (copilot_server_info .absolute_path , copilot_server_info .filename )
230
234
logger .notify (" copilot-language-server downloaded" )
231
235
return true
232
236
end
@@ -248,6 +252,22 @@ local function is_arm()
248
252
return os_name == " aarch64" or string.sub (os_name , 1 , 3 ) == " arm"
249
253
end
250
254
255
+ --- @return boolean
256
+ local function is_musl ()
257
+ local fh , err = assert (io.popen (" ldd --version 2>&1" , " r" ))
258
+ if err then
259
+ return false -- we assume glibc
260
+ end
261
+
262
+ local ldd_output
263
+ if fh then
264
+ ldd_output = fh :read ()
265
+ fh :close ()
266
+ end
267
+
268
+ return string.sub (ldd_output , 1 , 4 ) == " musl"
269
+ end
270
+
251
271
--- @return copilot_server_info
252
272
function M .get_copilot_server_info ()
253
273
if M .copilot_server_info then
@@ -263,8 +283,11 @@ function M.get_copilot_server_info()
263
283
if os == " Linux" then
264
284
if is_arm () then
265
285
path = " linux-arm64"
266
- else
286
+ elseif not is_musl () then
267
287
path = " linux-x64"
288
+ else
289
+ -- Fallback to plain nodejs project
290
+ path = " js"
268
291
end
269
292
elseif os == " Darwin" then
270
293
if is_arm () then
@@ -282,6 +305,11 @@ function M.get_copilot_server_info()
282
305
logger .error (" could not determine OS, please report this issue with the output of `uname -a`" )
283
306
end
284
307
308
+ if path == " js" then
309
+ filename = " language-server.js"
310
+ extracted_filename = " "
311
+ end
312
+
285
313
M .copilot_server_info = {
286
314
path = path ,
287
315
filename = filename ,
0 commit comments