Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config error reporting #1808

Merged
merged 4 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ The following options are currently available.
| `dangerous_comptime_experiments_do_not_enable` | `bool` | `false` | Whether to use the comptime interpreter |
| `skip_std_references` | `bool` | `false` | When true, skips searching for references in std. Improves lookup speed for functions in user's code. Renaming and go-to-definition will continue to work as is |
| `prefer_ast_check_as_child_process` | `bool` | `true` | Favor using `zig ast-check` instead of ZLS's fork |
| `record_session` | `bool` | `false` | When true, zls will record all request is receives and write in into `record_session_path`, so that they can replayed with `zls replay` |
| `record_session_path` | `?[]const u8` | `null` | Output file path when `record_session` is set. The recommended file extension *.zlsreplay |
| `replay_session_path` | `?[]const u8` | `null` | Used when calling `zls replay` for specifying the replay file. If no extra argument is given `record_session_path` is used as the default path. |
| `builtin_path` | `?[]const u8` | `null` | Path to 'builtin;' useful for debugging, automatically set if let null |
| `zig_lib_path` | `?[]const u8` | `null` | Zig library path, e.g. `/path/to/zig/lib/zig`, used to analyze std library imports |
| `zig_exe_path` | `?[]const u8` | `null` | Zig executable path, e.g. `/path/to/zig/zig`, used to run the custom build runner. If `null`, zig is looked up in `PATH`. Will be used to infer the zig standard library path if none is provided |
Expand Down
10 changes: 9 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const min_zig_string = "0.12.0-dev.3071+6f7354a04";
const Build = blk: {
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse(min_zig_string) catch unreachable;
const is_current_zig_tagged_release = current_zig.pre == null;
const is_current_zig_tagged_release = current_zig.pre == null and current_zig.build == null;
if (current_zig.order(min_zig) == .lt) {
const message = std.fmt.comptimePrint(
\\Your Zig version does not meet the minimum build requirement:
Expand All @@ -20,6 +20,7 @@ const Build = blk: {
\\
++ if (is_current_zig_tagged_release)
\\Please download or compile a tagged release of ZLS.
\\ -> https://github.com/zigtools/zls/releases
\\ -> https://github.com/zigtools/zls/releases/tag/{[current_version]}
else
\\You can take one of the following actions to resolve this issue:
Expand Down Expand Up @@ -344,3 +345,10 @@ fn getTracyModule(

return tracy_module;
}

comptime {
const min_zig = std.SemanticVersion.parse(min_zig_string) catch unreachable;
const min_zig_simple = std.SemanticVersion{ .major = min_zig.major, .minor = min_zig.minor, .patch = 0 };
const zls_version_simple = std.SemanticVersion{ .major = zls_version.major, .minor = zls_version.minor, .patch = 0 };
std.debug.assert(zls_version_simple.order(min_zig_simple) == .eq);
}
15 changes: 0 additions & 15 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,6 @@
"type": "boolean",
"default": true
},
"record_session": {
"description": "When true, zls will record all request is receives and write in into `record_session_path`, so that they can replayed with `zls replay`",
"type": "boolean",
"default": false
},
"record_session_path": {
"description": "Output file path when `record_session` is set. The recommended file extension *.zlsreplay",
"type": "string",
"default": null
},
"replay_session_path": {
"description": "Used when calling `zls replay` for specifying the replay file. If no extra argument is given `record_session_path` is used as the default path.",
"type": "string",
"default": null
},
"builtin_path": {
"description": "Path to 'builtin;' useful for debugging, automatically set if let null",
"type": "string",
Expand Down
9 changes: 0 additions & 9 deletions src/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,6 @@ skip_std_references: bool = false,
/// Favor using `zig ast-check` instead of ZLS's fork
prefer_ast_check_as_child_process: bool = true,

/// When true, zls will record all request is receives and write in into `record_session_path`, so that they can replayed with `zls replay`
record_session: bool = false,

/// Output file path when `record_session` is set. The recommended file extension *.zlsreplay
record_session_path: ?[]const u8 = null,

/// Used when calling `zls replay` for specifying the replay file. If no extra argument is given `record_session_path` is used as the default path.
replay_session_path: ?[]const u8 = null,

/// Path to 'builtin;' useful for debugging, automatically set if let null
builtin_path: ?[]const u8 = null,

Expand Down
6 changes: 1 addition & 5 deletions src/DocumentStore.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const BuildAssociatedConfig = @import("BuildAssociatedConfig.zig");
const BuildConfig = @import("build_runner/BuildConfig.zig");
const tracy = @import("tracy");
const Config = @import("Config.zig");
const ZigVersionWrapper = @import("ZigVersionWrapper.zig");
const translate_c = @import("translate_c.zig");
const ComptimeInterpreter = @import("ComptimeInterpreter.zig");
const AstGen = std.zig.AstGen;
Expand Down Expand Up @@ -599,8 +598,6 @@ pub const ErrorMessage = struct {
allocator: std.mem.Allocator,
/// the DocumentStore assumes that `config` is not modified while calling one of its functions.
config: *const Config,
/// the DocumentStore assumes that `runtime_zig_version` is not modified while calling one of its functions.
runtime_zig_version: *const ?ZigVersionWrapper,
lock: std.Thread.RwLock = .{},
thread_pool: if (builtin.single_threaded) void else *std.Thread.Pool,
handles: std.StringArrayHashMapUnmanaged(*Handle) = .{},
Expand Down Expand Up @@ -772,8 +769,7 @@ pub fn refreshDocument(self: *DocumentStore, uri: Uri, new_text: [:0]const u8) !
/// Invalidates a build files.
/// **Thread safe** takes a shared lock
pub fn invalidateBuildFile(self: *DocumentStore, build_file_uri: Uri) error{OutOfMemory}!void {
std.debug.assert(std.process.can_spawn);
if (!std.process.can_spawn) return;
comptime std.debug.assert(std.process.can_spawn);

if (self.config.zig_exe_path == null) return;
if (self.config.build_runner_path == null) return;
Expand Down
Loading