Improve Zig version mismatch error (#744)

Improves the server message we send if the system Zig version is older
than the Zig version that ZLS was built with:

- Correct typo (“build with” → “built with”).
- Show versions so users know which one they need to update to.
- Suggest step needed to fix the error (“Update Zig…”).
This commit is contained in:
Nick Cernis 2022-11-10 05:13:35 +01:00 committed by GitHub
parent b08480256c
commit e58bddd769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1634,10 +1634,8 @@ fn initializeHandler(server: *Server, writer: anytype, id: types.RequestId, req:
const zig_exe_version = std.SemanticVersion.parse(env.version) catch return;
if (zig_builtin.zig_version.order(zig_exe_version) == .gt) {
try server.showMessage(writer, .Warning,
\\ZLS has been build with a newer version than you are using!
\\This may cause unexpected issues.
);
const version_mismatch_message = try std.fmt.allocPrint(server.arena.allocator(), "ZLS was built with Zig {}, but your Zig version is {s}. Update Zig to avoid unexpected behavior.", .{ zig_builtin.zig_version, env.version });
try server.showMessage(writer, .Warning, version_mismatch_message);
}
}