ast-check fixes

This commit is contained in:
Auguste Rame 2022-09-01 09:26:58 -04:00
parent 57a35a7bc8
commit 246fee8a1b
No known key found for this signature in database
GPG Key ID: 3A5E3F90DF2AAEFE
3 changed files with 5 additions and 5 deletions

View File

@ -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| { 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); var process = std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "ast-check", "--color", "off" }, server.allocator);
process.stdin_behavior = .Pipe; process.stdin_behavior = .Pipe;
process.stderr_behavior = .Pipe; process.stderr_behavior = .Pipe;
process.spawn() catch |err| { 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; break :diag;
}; };
try process.stdin.?.writeAll(handle.document.text); try process.stdin.?.writeAll(handle.document.text);

View File

@ -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 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 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 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 style = try askBool("Do you want to enable style warnings?");
const semantic_tokens = try askBool("Do you want to enable semantic highlighting?"); 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", .@"$schema" = "https://raw.githubusercontent.com/zigtools/zls/master/schema.json",
.zig_exe_path = zig_exe_path, .zig_exe_path = zig_exe_path,
.enable_snippets = snippets, .enable_snippets = snippets,
.enable_unused_variable_warnings = unused_variables, .enable_ast_check_diagnostics = ast_check,
.enable_import_embedfile_argument_completions = ief_apc, .enable_import_embedfile_argument_completions = ief_apc,
.warn_style = style, .warn_style = style,
.enable_semantic_tokens = semantic_tokens, .enable_semantic_tokens = semantic_tokens,

View File

@ -119,7 +119,7 @@ pub const Diagnostic = struct {
code: string, code: string,
source: string, source: string,
message: string, message: string,
relatedInformation: []const DiagnosticRelatedInformation = &[0]DiagnosticRelatedInformation{}, relatedInformation: []const DiagnosticRelatedInformation = &.{},
}; };
pub const TextDocument = struct { pub const TextDocument = struct {