@@ -13,14 +13,7 @@ import semver from "semver";
1313
1414import * as minisign from "./minisign" ;
1515import * as versionManager from "./versionManager" ;
16- import {
17- getHostZigName ,
18- getZigArchName ,
19- getZigOSName ,
20- handleConfigOption ,
21- resolveExePathAndVersion ,
22- workspaceConfigUpdateNoThrow ,
23- } from "./zigUtil" ;
16+ import * as zigUtil from "./zigUtil" ;
2417import { zigProvider } from "./zigSetup" ;
2518
2619const ZIG_MODE = [
@@ -114,16 +107,16 @@ async function getZLSPath(context: vscode.ExtensionContext): Promise<{ exe: stri
114107 if ( ! ! zlsExePath ) {
115108 // This will fail on older ZLS version that do not support `zls --version`.
116109 // It should be more likely that the given executable is invalid than someone using ZLS 0.9.0 or older.
117- const result = resolveExePathAndVersion ( zlsExePath , "--version" ) ;
110+ const result = zigUtil . resolveExePathAndVersion ( zlsExePath , "--version" ) ;
118111 if ( "message" in result ) {
119112 vscode . window
120113 . showErrorMessage ( `Unexpected 'zig.zls.path': ${ result . message } ` , "install ZLS" , "open settings" )
121114 . then ( async ( response ) => {
122115 switch ( response ) {
123116 case "install ZLS" :
124117 const zlsConfig = vscode . workspace . getConfiguration ( "zig.zls" ) ;
125- await workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
126- await workspaceConfigUpdateNoThrow ( zlsConfig , "path" , undefined ) ;
118+ await zigUtil . workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
119+ await zigUtil . workspaceConfigUpdateNoThrow ( zlsConfig , "path" , undefined ) ;
127120 break ;
128121 case "open settings" :
129122 await vscode . commands . executeCommand ( "workbench.action.openSettings" , "zig.zls.path" ) ;
@@ -179,7 +172,7 @@ function configurationMiddleware(params: ConfigurationParams): LSPAny[] | Respon
179172
180173 if ( typeof value === "string" ) {
181174 // Make sure that `""` gets converted to `undefined` and resolve predefined values
182- value = value ? handleConfigOption ( value , workspaceFolder ?? "guess" ) : undefined ;
175+ value = value ? zigUtil . handleConfigOption ( value , workspaceFolder ?? "guess" ) : undefined ;
183176 } else if ( typeof value === "object" && value !== null && ! Array . isArray ( value ) ) {
184177 // Recursively update the config options
185178 const newValue : Record < string , unknown > = { } ;
@@ -277,13 +270,13 @@ async function validateAdditionalOptions(): Promise<void> {
277270 switch ( response ) {
278271 case `Use ${ optionName } instead` :
279272 const { [ optionName ] : newValue , ...updatedAdditionalOptions } = additionalOptions ;
280- await workspaceConfigUpdateNoThrow (
273+ await zigUtil . workspaceConfigUpdateNoThrow (
281274 configuration ,
282275 "additionalOptions" ,
283276 Object . keys ( updatedAdditionalOptions ) . length ? updatedAdditionalOptions : undefined ,
284277 true ,
285278 ) ;
286- await workspaceConfigUpdateNoThrow ( configuration , section , newValue , true ) ;
279+ await zigUtil . workspaceConfigUpdateNoThrow ( configuration , section , newValue , true ) ;
287280 break ;
288281 case "Show zig.zls.additionalOptions" :
289282 await vscode . commands . executeCommand ( "workbench.action.openSettingsJson" , {
@@ -367,19 +360,20 @@ async function fetchVersion(
367360 void vscode . window . showErrorMessage ( `Unable to fetch ZLS: ${ response . message as string } ` ) ;
368361 return null ;
369362 }
363+ const version = new semver . SemVer ( response . version ) ;
364+ const armName = semver . gte ( version , "0.15.0" ) ? "arm" : "armv7a" ;
365+ const targetName = `${ zigUtil . getZigArchName ( armName ) } -${ zigUtil . getZigOSName ( ) } ` ;
370366
371- const hostName = getHostZigName ( ) ;
372-
373- if ( ! ( hostName in response ) ) {
367+ if ( ! ( targetName in response ) ) {
374368 void vscode . window . showErrorMessage (
375369 `A prebuilt ZLS ${ response . version } binary is not available for your system. You can build it yourself with https://github.com/zigtools/zls#from-source` ,
376370 ) ;
377371 return null ;
378372 }
379373
380374 return {
381- version : new semver . SemVer ( response . version ) ,
382- artifact : response [ hostName ] as ArtifactEntry ,
375+ version : version ,
376+ artifact : response [ targetName ] as ArtifactEntry ,
383377 } ;
384378}
385379
@@ -401,10 +395,10 @@ async function isEnabled(): Promise<boolean> {
401395 ) ;
402396 switch ( response ) {
403397 case "Yes" :
404- await workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
398+ await zigUtil . workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
405399 return true ;
406400 case "No" :
407- await workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "off" , true ) ;
401+ await zigUtil . workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "off" , true ) ;
408402 return false ;
409403 case undefined :
410404 return false ;
@@ -455,8 +449,8 @@ export async function activate(context: vscode.ExtensionContext) {
455449 const zlsConfig = vscode . workspace . getConfiguration ( "zig.zls" ) ;
456450 const zlsPath = zlsConfig . get < string > ( "path" , "" ) ;
457451 if ( zlsPath . startsWith ( context . globalStorageUri . fsPath ) ) {
458- await workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
459- await workspaceConfigUpdateNoThrow ( zlsConfig , "path" , undefined , true ) ;
452+ await zigUtil . workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
453+ await zigUtil . workspaceConfigUpdateNoThrow ( zlsConfig , "path" , undefined , true ) ;
460454 }
461455 }
462456
@@ -475,7 +469,10 @@ export async function activate(context: vscode.ExtensionContext) {
475469 } ,
476470 getArtifactName ( version ) {
477471 const fileExtension = process . platform === "win32" ? "zip" : "tar.xz" ;
478- return `zls-${ getZigOSName ( ) } -${ getZigArchName ( ) } -${ version . raw } .${ fileExtension } ` ;
472+ const targetName = semver . gte ( version , "0.15.0" )
473+ ? `${ zigUtil . getZigArchName ( "arm" ) } -${ zigUtil . getZigOSName ( ) } `
474+ : `${ zigUtil . getZigOSName ( ) } -${ zigUtil . getZigArchName ( "armv7a" ) } ` ;
475+ return `zls-${ targetName } -${ version . raw } .${ fileExtension } ` ;
479476 } ,
480477 } ;
481478
@@ -492,14 +489,14 @@ export async function activate(context: vscode.ExtensionContext) {
492489 statusItem ,
493490 vscode . commands . registerCommand ( "zig.zls.enable" , async ( ) => {
494491 const zlsConfig = vscode . workspace . getConfiguration ( "zig.zls" ) ;
495- await workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
492+ await zigUtil . workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
496493 } ) ,
497494 vscode . commands . registerCommand ( "zig.zls.stop" , async ( ) => {
498495 await stopClient ( ) ;
499496 } ) ,
500497 vscode . commands . registerCommand ( "zig.zls.startRestart" , async ( ) => {
501498 const zlsConfig = vscode . workspace . getConfiguration ( "zig.zls" ) ;
502- await workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
499+ await zigUtil . workspaceConfigUpdateNoThrow ( zlsConfig , "enabled" , "on" , true ) ;
503500 await restartClient ( context ) ;
504501 } ) ,
505502 vscode . commands . registerCommand ( "zig.zls.openOutput" , ( ) => {
0 commit comments