Skip to content

Commit

Permalink
ZLS has deprecated --enable-debug-log in favor of --log-level
Browse files Browse the repository at this point in the history
It is expected to be removed in ZLS 0.14.0
  • Loading branch information
Techatrix committed Nov 16, 2024
1 parent a23c64f commit e0e9efb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/zls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function restartClient(context: vscode.ExtensionContext): Promise<v
if (!result) return;

try {
const newClient = await startClient(result.exe);
const newClient = await startClient(result.exe, result.version);
await stopClient();
client = newClient;
} catch (reason) {
Expand All @@ -48,13 +48,25 @@ export async function restartClient(context: vscode.ExtensionContext): Promise<v
}
}

async function startClient(zlsPath: string): Promise<LanguageClient> {
async function startClient(zlsPath: string, zlsVersion: semver.SemVer): Promise<LanguageClient> {
const configuration = vscode.workspace.getConfiguration("zig.zls");
const debugLog = configuration.get<boolean>("debugLog", false);

const args: string[] = [];

if (debugLog) {
/** `--enable-debug-log` has been deprecated in favor of `--log-level`. https://github.com/zigtools/zls/pull/1957 */
const zlsCLIRevampVersion = new semver.SemVer("0.14.0-50+3354fdc");
if (semver.lt(zlsVersion, zlsCLIRevampVersion)) {
args.push("--enable-debug-log");
} else {
args.push("--log-level", "debug");
}
}

const serverOptions: ServerOptions = {
command: zlsPath,
args: debugLog ? ["--enable-debug-log"] : [],
args: args,
};

const clientOptions: LanguageClientOptions = {
Expand Down

0 comments on commit e0e9efb

Please sign in to comment.