From 246fee8a1b60f05adb8b9ee0b34d2cff8736411a Mon Sep 17 00:00:00 2001 From: Auguste Rame <19855629+SuperAuguste@users.noreply.github.com> Date: Thu, 1 Sep 2022 09:26:58 -0400 Subject: [PATCH] ast-check fixes --- src/Server.zig | 4 ++-- src/setup.zig | 4 ++-- src/types.zig | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Server.zig b/src/Server.zig index 3015443..8447120 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -237,14 +237,14 @@ fn publishDiagnostics(server: *Server, writer: anytype, handle: DocumentStore.Ha }); } - if (server.config.enable_ast_check_diagnostics) diag: { + if (server.config.enable_ast_check_diagnostics and tree.errors.len == 0) diag: { if (server.config.zig_exe_path) |zig_exe_path| { var process = std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "ast-check", "--color", "off" }, server.allocator); process.stdin_behavior = .Pipe; process.stderr_behavior = .Pipe; process.spawn() catch |err| { - Logger.warn(server, writer, "Failed to spawn zig fmt process, error: {}", .{err}); + Logger.warn(server, writer, "Failed to spawn zig ast-check process, error: {}", .{err}); break :diag; }; try process.stdin.?.writeAll(handle.document.text); diff --git a/src/setup.zig b/src/setup.zig index 8d124f8..40b058e 100644 --- a/src/setup.zig +++ b/src/setup.zig @@ -170,7 +170,7 @@ pub fn wizard(allocator: std.mem.Allocator) !void { const editor = try askSelectOne("Which code editor do you use?", enum { VSCode, Sublime, Kate, Neovim, Vim8, Emacs, Doom, Spacemacs, Helix, Other }); const snippets = try askBool("Do you want to enable snippets?"); - const unused_variables = try askBool("Do you want to enable unused variable warnings?"); + const ast_check = try askBool("Do you want to enable ast-check diagnostics?"); const ief_apc = try askBool("Do you want to enable @import/@embedFile argument path completion?"); const style = try askBool("Do you want to enable style warnings?"); const semantic_tokens = try askBool("Do you want to enable semantic highlighting?"); @@ -192,7 +192,7 @@ pub fn wizard(allocator: std.mem.Allocator) !void { .@"$schema" = "https://raw.githubusercontent.com/zigtools/zls/master/schema.json", .zig_exe_path = zig_exe_path, .enable_snippets = snippets, - .enable_unused_variable_warnings = unused_variables, + .enable_ast_check_diagnostics = ast_check, .enable_import_embedfile_argument_completions = ief_apc, .warn_style = style, .enable_semantic_tokens = semantic_tokens, diff --git a/src/types.zig b/src/types.zig index c7f773e..f6500a2 100644 --- a/src/types.zig +++ b/src/types.zig @@ -119,7 +119,7 @@ pub const Diagnostic = struct { code: string, source: string, message: string, - relatedInformation: []const DiagnosticRelatedInformation = &[0]DiagnosticRelatedInformation{}, + relatedInformation: []const DiagnosticRelatedInformation = &.{}, }; pub const TextDocument = struct {