From b82fb9c790d389ea66b45b79d4e73d0a1b8cf917 Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Mon, 25 May 2020 20:04:23 +0300 Subject: [PATCH] Added build_runner_path configuration option --- README.md | 1 + src/config.zig | 4 ++++ src/main.zig | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index abf15c2..a85c752 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ The following options are currently available. | `enable_snippets` | `bool` | `false` | Enables snippet completion, set to false for compatibility with language clients that do not support snippets (such as ale). | | `zig_lib_path` | `?[]const u8` | `null` | zig library path, e.g. `/path/to/zig/lib/zig`, used to analyze std library imports. | | `warn_style` | `bool` | `false` | Enables warnings for style *guideline* mismatches | +| `build_runner_path` | `?[]const u8` | `null` | Path to the build_runner.zig file provided by zls. This option must be present in one of the global configuration files to have any effect. `null` is equivalent to `${executable_directory}/build_runner.zig` | ## Usage diff --git a/src/config.zig b/src/config.zig index 9a6cd13..c209875 100644 --- a/src/config.zig +++ b/src/config.zig @@ -9,3 +9,7 @@ zig_lib_path: ?[]const u8 = null, /// Whether to pay attention to style issues. This is opt-in since the style /// guide explicitly states that the style info provided is a guideline only. warn_style: bool = false, + +/// Path to the build_runner.zig file. This option must be present in one of +/// the global configuration directories to have any effect. +build_runner_path: ?[]const u8 = null, diff --git a/src/main.zig b/src/main.zig index ec0d373..f93abd1 100644 --- a/src/main.zig +++ b/src/main.zig @@ -924,12 +924,14 @@ pub fn main() anyerror!void { } } - { + if (config.build_runner_path) |build_runner_path| { + try document_store.init(allocator, has_zig, try std.mem.dupe(allocator, u8, build_runner_path)); + } else { var exe_dir_bytes: [std.fs.MAX_PATH_BYTES]u8 = undefined; const exe_dir_path = try std.fs.selfExeDirPath(&exe_dir_bytes); - const document_runner_path = try std.fs.path.resolve(allocator, &[_][]const u8{ exe_dir_path, "build_runner.zig" }); - try document_store.init(allocator, has_zig, document_runner_path); + const build_runner_path = try std.fs.path.resolve(allocator, &[_][]const u8{ exe_dir_path, "build_runner.zig" }); + try document_store.init(allocator, has_zig, build_runner_path); } defer document_store.deinit();