Skip to content
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
18 changes: 7 additions & 11 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,20 @@
// ```
// If you do not use Nix, a ZLS maintainer can take care of this.
.minimum_zig_version = "0.16.0-dev.2736+3b515fbed",
// Must be kept in sync with the `deps.nix` for the Nix flake.
// If you do not use Nix, a ZLS maintainer can take care of this.
// Whenever the dependencies are updated, run the following command:
// ```bash
// nix run github:nix-community/zon2nix#default_0_14 > deps.nix
// ```
// The `deps.nix` should also be updated to not fetch `tracy`.
.dependencies = .{
.known_folders = .{
.url = "https://github.com/ziglibs/known-folders/archive/71f0a3d660401ee461cc42ae1f2360f4b83084d3.tar.gz",
.hash = "known_folders-0.0.0-Fy-PJjrKAAAY9ALC7ALIxFsmKFP314HJw6v3NLSS3NDB",
.url = "https://github.com/ziglibs/known-folders/archive/175f5596b3d2ee3c658282bb07885580895a0e73.tar.gz",
.hash = "known_folders-0.0.0-Fy-PJk7KAAC41mQXzmFyGa0Q7tvmQjatENkREa6Gc4zu",
},
.diffz = .{
.url = "https://github.com/ziglibs/diffz/archive/aa11caef328a3f20f2493f8fd676a1dfa7819246.tar.gz",
.hash = "diffz-0.0.1-G2tlIYrNAQAQx3cuIp7EVs0xvxbv9DCPf4YuHmvubsrZ",
.url = "https://github.com/ziglibs/diffz/archive/d93d5737d2c19a2fb279c8dcaa80a4ce35529a3b.tar.gz",
.hash = "diffz-0.0.1-G2tlIXvNAQCPPTvl-leqv4d5nfEdwLw2lfE11P7EGKhy",
},
.lsp_kit = .{
.url = "git+https://github.com/zigtools/lsp-kit.git#98d6bed6e42a0866e1e2ba0867673d9f57ca6687",
.hash = "lsp_kit-0.1.0-bi_PLwozDAApVpvVJHz80NPklig5biWlZCkyxjFbOtiD",
.url = "https://github.com//zigtools/lsp-kit/archive/ec325a3c33d1da7708cf513355208f74d9560580.tar.gz",
.hash = "lsp_kit-0.1.0-bi_PL_kyDACVTEhLaMq2-PJx0MocqRyjXDAN0ybMUyQQ",
},
.tracy = .{
.url = "https://github.com/wolfpld/tracy/archive/refs/tags/v0.13.1.tar.gz",
Expand Down
28 changes: 15 additions & 13 deletions deps.nix
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# generated by zon2nix (https://github.com/nix-community/zon2nix)

{ linkFarm, fetchzip, fetchgit, emptyDirectory }:

{
linkFarm,
fetchzip,
fetchgit,
emptyDirectory,
}:
linkFarm "zig-packages" [
{
name = "diffz-0.0.1-G2tlIYrNAQAQx3cuIp7EVs0xvxbv9DCPf4YuHmvubsrZ";
name = "known_folders-0.0.0-Fy-PJk7KAAC41mQXzmFyGa0Q7tvmQjatENkREa6Gc4zu";
path = fetchzip {
url = "https://github.com/ziglibs/diffz/archive/aa11caef328a3f20f2493f8fd676a1dfa7819246.tar.gz";
hash = "sha256-bdL+xLnYVzYS6T3zsw7xfLKTUCUFI0pIpQaOxV6oTis=";
url = "https://github.com/ziglibs/known-folders/archive/4575ac4088eb7d0c8421d5b3d642f19de392d898.tar.gz";
hash = "sha256-YE4KRNvrqzMtB7sSPnnbhwCokfNP7RqNtO1QVgwbiBc=";
};
}
{
name = "known_folders-0.0.0-Fy-PJjrKAAAY9ALC7ALIxFsmKFP314HJw6v3NLSS3NDB";
name = "diffz-0.0.1-G2tlIXvNAQCPPTvl-leqv4d5nfEdwLw2lfE11P7EGKhy";
path = fetchzip {
url = "https://github.com/ziglibs/known-folders/archive/71f0a3d660401ee461cc42ae1f2360f4b83084d3.tar.gz";
hash = "sha256-oBLYbnIjOIRL1NWYANJZcT4vfUaWy2vDgzxnf8zMSPQ=";
url = "https://github.com/ziglibs/diffz/archive/d93d5737d2c19a2fb279c8dcaa80a4ce35529a3b.tar.gz";
hash = "sha256-1IDqdr0+74IlH76eovC6m5Ww6bNMAAyHFt1ukat/UXk=";
};
}
{
name = "lsp_kit-0.1.0-bi_PLwozDAApVpvVJHz80NPklig5biWlZCkyxjFbOtiD";
name = "lsp_kit-0.1.0-bi_PL_kyDACVTEhLaMq2-PJx0MocqRyjXDAN0ybMUyQQ";
path = fetchzip {
url = "https://github.com/zigtools/lsp-kit/archive/98d6bed6e42a0866e1e2ba0867673d9f57ca6687.tar.gz";
hash = "sha256-/p/AknpFGicfOhpsvyqCNHxeVNVBoiXWh6ctKTwStCM=";
url = "https://github.com/zigtools/lsp-kit/archive/ec325a3c33d1da7708cf513355208f74d9560580.tar.gz";
hash = "sha256-60F2BOCrl3CreQFmpH3HAz6zzxd3VgJ3iSEkP39gtgQ=";
};
}
# workaround: https://codeberg.org/ziglang/zig/issues/31162
Expand Down
4 changes: 2 additions & 2 deletions src/DiagnosticsCollection.zig
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ fn collectUrisFromErrorBundle(
}

fn pathToUri(allocator: std.mem.Allocator, base_path: ?[]const u8, src_path: []const u8) error{OutOfMemory}!?Uri {
if (std.fs.path.isAbsolute(src_path)) {
if (std.Io.Dir.path.isAbsolute(src_path)) {
return try .fromPath(allocator, src_path);
}
const base = base_path orelse return null;
const absolute_src_path = try std.fs.path.join(allocator, &.{ base, src_path });
const absolute_src_path = try std.Io.Dir.path.join(allocator, &.{ base, src_path });
defer allocator.free(absolute_src_path);

return try .fromPath(allocator, absolute_src_path);
Expand Down
28 changes: 14 additions & 14 deletions src/DocumentStore.zig
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ pub const Handle = struct {
const tracy_zone = tracy.traceNamed(@src(), "Handle.refresh");
defer tracy_zone.end();

const mode: Ast.Mode = if (std.mem.eql(u8, std.fs.path.extension(handle.uri.raw), ".zon")) .zon else .zig;
const mode: Ast.Mode = if (std.mem.eql(u8, std.Io.Dir.path.extension(handle.uri.raw), ".zon")) .zon else .zig;
var new_tree = try parseTree(allocator, text, mode);
errdefer new_tree.deinit(allocator);

Expand Down Expand Up @@ -847,7 +847,7 @@ pub fn openLspSyncedDocument(self: *DocumentStore, uri: Uri, text: []const u8) e
}
}

const duped_text = try self.allocator.dupeZ(u8, text);
const duped_text = try self.allocator.dupeSentinel(u8, text, 0);
_ = self.createAndStoreDocument(
uri,
.{ .text = duped_text },
Expand Down Expand Up @@ -1013,11 +1013,11 @@ pub fn loadDirectoryRecursive(store: *DocumentStore, directory_uri: Uri) LoadDir
}
continue;
}
if (!std.mem.eql(u8, std.fs.path.extension(entry.basename), ".zig")) continue;
if (!std.mem.eql(u8, std.Io.Dir.path.extension(entry.basename), ".zig")) continue;

file_count += 1;

const path = try std.fs.path.join(store.allocator, &.{ workspace_path, entry.path });
const path = try std.Io.Dir.path.join(store.allocator, &.{ workspace_path, entry.path });
defer store.allocator.free(path);

const uri: Uri = try .fromPath(store.allocator, path);
Expand Down Expand Up @@ -1046,7 +1046,7 @@ pub fn loadTrigramStores(
while (it.next()) |handle| {
const uri = handle.uri.toStdUri();

var component_it = std.fs.path.componentIterator(uri.path.percent_encoded);
var component_it = std.Io.Dir.path.componentIterator(uri.path.percent_encoded);
const skip = while (component_it.next()) |component| {
// Keep in sync with `loadDirectoryRecursive`
if (std.mem.startsWith(u8, component.name, ".")) break true;
Expand Down Expand Up @@ -1305,7 +1305,7 @@ fn loadBuildAssociatedConfiguration(io: std.Io, allocator: std.mem.Allocator, bu

const build_file_path = try build_file.uri.toFsPath(allocator);
defer allocator.free(build_file_path);
const config_file_path = try std.fs.path.resolve(allocator, &.{ build_file_path, "..", "zls.build.json" });
const config_file_path = try std.Io.Dir.path.resolve(allocator, &.{ build_file_path, "..", "zls.build.json" });
defer allocator.free(config_file_path);

const file_buf = try std.Io.Dir.cwd().readFileAlloc(
Expand Down Expand Up @@ -1373,7 +1373,7 @@ fn loadBuildConfiguration(self: *DocumentStore, build_file_uri: Uri, build_file_
const build_file_path = try build_file_uri.toFsPath(self.allocator);
defer self.allocator.free(build_file_path);

const cwd = std.fs.path.dirname(build_file_path).?;
const cwd = std.Io.Dir.path.dirname(build_file_path).?;

const args = try self.prepareBuildRunnerArgs(build_file_uri);
defer {
Expand Down Expand Up @@ -1489,16 +1489,16 @@ fn collectPotentialBuildFiles(self: *DocumentStore, uri: Uri) error{ Canceled, O
// https://github.com/ziglang/zig/issues/15607
const root_end_index: usize = root_end_index: {
if (builtin.target.os.tag != .windows) break :root_end_index 0;
const component_iterator = std.fs.path.componentIterator(path);
const component_iterator = std.Io.Dir.path.componentIterator(path);
break :root_end_index component_iterator.root_end_index;
};

var current_path: []const u8 = path;
while (std.fs.path.dirname(current_path)) |potential_root_path| : (current_path = potential_root_path) {
while (std.Io.Dir.path.dirname(current_path)) |potential_root_path| : (current_path = potential_root_path) {
if (potential_root_path.len < root_end_index) break;
if (!try buildDotZigExists(self.io, potential_root_path)) continue;

const build_path = try std.fs.path.join(self.allocator, &.{ potential_root_path, "build.zig" });
const build_path = try std.Io.Dir.path.join(self.allocator, &.{ potential_root_path, "build.zig" });
defer self.allocator.free(build_path);

try potential_build_files.ensureUnusedCapacity(self.allocator, 1);
Expand Down Expand Up @@ -1534,7 +1534,7 @@ fn createBuildFile(self: *DocumentStore, uri: Uri) error{ Canceled, OutOfMemory

if (cfg.value.relative_builtin_path) |relative_builtin_path| blk: {
const build_file_path = build_file.uri.toFsPath(self.allocator) catch break :blk;
const absolute_builtin_path = try std.fs.path.resolve(self.allocator, &.{ build_file_path, "..", relative_builtin_path });
const absolute_builtin_path = try std.Io.Dir.path.resolve(self.allocator, &.{ build_file_path, "..", relative_builtin_path });
defer self.allocator.free(absolute_builtin_path);
build_file.builtin_uri = try .fromPath(self.allocator, absolute_builtin_path);
}
Expand Down Expand Up @@ -1731,15 +1731,15 @@ pub fn collectIncludeDirs(

try include_dirs.ensureUnusedCapacity(allocator, module.include_dirs.len);
for (module.include_dirs) |include_path| {
const absolute_path = if (std.fs.path.isAbsolute(include_path))
const absolute_path = if (std.Io.Dir.path.isAbsolute(include_path))
try allocator.dupe(u8, include_path)
else blk: {
const build_file_path = resolved.build_file.uri.toFsPath(allocator) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.UnsupportedScheme => continue,
};
const build_file_dirname = std.fs.path.dirname(build_file_path) orelse continue;
break :blk try std.fs.path.join(allocator, &.{ build_file_dirname, include_path });
const build_file_dirname = std.Io.Dir.path.dirname(build_file_path) orelse continue;
break :blk try std.Io.Dir.path.join(allocator, &.{ build_file_dirname, include_path });
};

include_dirs.appendAssumeCapacity(absolute_path);
Expand Down
6 changes: 3 additions & 3 deletions src/Server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -739,14 +739,14 @@ fn handleConfiguration(server: *Server, json: std.json.Value) error{ Canceled, O
const field: *?[]const u8 = &@field(new_config, file_config.name);
if (field.*) |maybe_relative| resolve: {
if (maybe_relative.len == 0) break :resolve;
if (std.fs.path.isAbsolute(maybe_relative)) break :resolve;
if (std.Io.Dir.path.isAbsolute(maybe_relative)) break :resolve;

const root_dir = maybe_root_dir orelse {
log.err("relative path only supported for {s} with exactly one workspace", .{runtime_known_config_name});
break;
};

const absolute = try std.fs.path.resolve(arena, &.{
const absolute = try std.Io.Dir.path.resolve(arena, &.{
root_dir, maybe_relative,
});

Expand Down Expand Up @@ -902,7 +902,7 @@ fn didChangeWatchedFilesHandler(server: *Server, arena: std.mem.Allocator, notif
error.OutOfMemory => return error.OutOfMemory,
else => return error.InvalidParams,
};
const file_extension = std.fs.path.extension(uri.raw);
const file_extension = std.Io.Dir.path.extension(uri.raw);
if (!std.mem.eql(u8, file_extension, ".zig") and !std.mem.eql(u8, file_extension, ".zon")) continue;

switch (change.type) {
Expand Down
6 changes: 3 additions & 3 deletions src/Uri.zig
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ fn fromPathWithOs(
buf.appendSliceAssumeCapacity("file:");
if (is_windows and
path.len >= 2 and
std.fs.path.PathType.isSep(.windows, u8, path[0]) and
std.fs.path.PathType.isSep(.windows, u8, path[1]))
std.Io.Dir.path.PathType.isSep(.windows, u8, path[0]) and
std.Io.Dir.path.PathType.isSep(.windows, u8, path[1]))
{
// UNC path
} else if (!std.mem.startsWith(u8, path, "/")) {
Expand Down Expand Up @@ -449,7 +449,7 @@ pub fn resolveImport(
std.Uri.Component.percentEncode(&aw.writer, sub_path, isPathChar) catch unreachable;

const percent_encoded_path = parsed_uri.path.percent_encoded;
const joined_path = try std.fs.path.resolvePosix(allocator, &.{ percent_encoded_path, "..", aw.written() });
const joined_path = try std.Io.Dir.path.resolvePosix(allocator, &.{ percent_encoded_path, "..", aw.written() });
defer allocator.free(joined_path);

var buffer = aw.toArrayList();
Expand Down
2 changes: 1 addition & 1 deletion src/analyser/InternPool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ pub const Key = union(enum) {
=> |a_data, t| {
const b_data = @field(b, @tagName(t));

const Int = std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(a_data)));
const Int = @Int(.unsigned, @bitSizeOf(@TypeOf(a_data)));
return @as(Int, @bitCast(a_data)) == @as(Int, @bitCast(b_data));
},

Expand Down
2 changes: 1 addition & 1 deletion src/analyser/string_pool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub fn StringPool(comptime config: Config) type {
defer pool.mutex.unlock(io);
const string_bytes: [*:0]u8 = @ptrCast(pool.bytes.items.ptr);
const start = @intFromEnum(index);
return try allocator.dupeZ(u8, std.mem.sliceTo(string_bytes + start, 0));
return try allocator.dupeSentinel(u8, std.mem.sliceTo(string_bytes + start, 0), 0);
}

/// storage a slice that points into the internal storage of the `StringPool`.
Expand Down
6 changes: 3 additions & 3 deletions src/analysis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ fn resolveCallsiteReferences(analyser: *Analyser, decl_handle: DeclWithHandle) E
};

const tree = &decl_handle.handle.tree;
const is_cimport = std.mem.eql(u8, std.fs.path.basename(decl_handle.handle.uri.raw), "cimport.zig");
const is_cimport = std.mem.eql(u8, std.Io.Dir.path.basename(decl_handle.handle.uri.raw), "cimport.zig");

if (is_cimport or !analyser.collect_callsite_references) return null;

Expand Down Expand Up @@ -4632,7 +4632,7 @@ pub const Type = struct {
error.OutOfMemory => return error.OutOfMemory,
error.UnsupportedScheme => handle.uri.raw,
};
const str = std.fs.path.stem(path);
const str = std.Io.Dir.path.stem(path);
try writer.writeAll(str);
if (referenced) |r| try r.put(analyser.arena, .of(str, handle, tree.firstToken(node)), {});
},
Expand Down Expand Up @@ -4954,7 +4954,7 @@ pub fn getFieldAccessType(
source_index: usize,
loc: offsets.Loc,
) Error!?Type {
const held_range = try analyser.arena.dupeZ(u8, offsets.locToSlice(handle.tree.source, loc));
const held_range = try analyser.arena.dupeSentinel(u8, offsets.locToSlice(handle.tree.source, loc), 0);
var tokenizer: std.zig.Tokenizer = .init(held_range);
var current_type: ?Type = null;

Expand Down
18 changes: 9 additions & 9 deletions src/build_runner/build_runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn main(init: process.Init.Minimal) !void {
const option_contents = arg[2..];
if (option_contents.len == 0)
fatalWithHint("expected option name after '-D'", .{});
if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| {
if (mem.findScalar(u8, option_contents, '=')) |name_end| {
const option_name = option_contents[0..name_end];
const option_value = option_contents[name_end + 1 ..];
if (try builder.addUserInputOption(option_name, option_value))
Expand Down Expand Up @@ -369,7 +369,7 @@ pub fn main(init: process.Init.Minimal) !void {
try buffer.appendSlice(arena, k);
try buffer.append(arena, '\n');
}
const s = std.fs.path.sep_str;
const s = std.Io.Dir.path.sep_str;
const tmp_sub_path = "tmp" ++ s ++ (output_tmp_nonce orelse fatal("missing -Z arg", .{}));
local_cache_directory.handle.writeFile(io, .{
.sub_path = tmp_sub_path,
Expand Down Expand Up @@ -572,7 +572,7 @@ fn resolveStepNames(
step_names: []const []const u8,
check_step_only: bool,
) !std.AutoArrayHashMapUnmanaged(*Step, void) {
var starting_steps: std.AutoArrayHashMapUnmanaged(*Step, void) = .{};
var starting_steps: std.AutoArrayHashMapUnmanaged(*Step, void) = .empty;
errdefer starting_steps.deinit(gpa);

if (step_names.len == 0) {
Expand Down Expand Up @@ -1064,7 +1064,7 @@ fn extractBuildInformation(
if (other.generated_h) |header| {
try include_dirs.put(
allocator,
std.fs.path.dirname(header.getPath()).?,
std.Io.Dir.path.dirname(header.getPath()).?,
{},
);
}
Expand All @@ -1091,7 +1091,7 @@ fn extractBuildInformation(

const cwd = module.owner.graph.cache.cwd;

const root_source_file_path = try std.fs.path.resolve(allocator, &.{ cwd, root_source_file.getPath2(module.owner, null) });
const root_source_file_path = try std.Io.Dir.path.resolve(allocator, &.{ cwd, root_source_file.getPath2(module.owner, null) });

// All modules with the same root source file are merged. This limitation may be lifted in the future.
const gop = try modules.getOrPutValue(allocator, root_source_file_path, .{
Expand All @@ -1105,7 +1105,7 @@ fn extractBuildInformation(
const gop_import = try gop.value_ptr.import_table.map.getOrPut(allocator, name);
// This does not account for the possibility of collisions (i.e. modules with same root source file import different modules under the same name).
if (!gop_import.found_existing) {
gop_import.value_ptr.* = try std.fs.path.resolve(allocator, &.{ cwd, import_root_source_file.getPath2(import.owner, null) });
gop_import.value_ptr.* = try std.Io.Dir.path.resolve(allocator, &.{ cwd, import_root_source_file.getPath2(import.owner, null) });
}
}
gop.value_ptr.c_macros = try std.mem.concat(allocator, []const u8, &.{ gop.value_ptr.c_macros, c_macros.keys() });
Expand Down Expand Up @@ -1221,7 +1221,7 @@ fn extractBuildInformation(
for (all_steps.keys()) |step| {
const compile = step.cast(Step.Compile) orelse continue;
const root_source_file = compile.root_module.root_source_file orelse continue;
const root_source_file_path = try std.fs.path.resolve(arena, &.{ b.graph.cache.cwd, root_source_file.getPath2(compile.root_module.owner, null) });
const root_source_file_path = try std.Io.Dir.path.resolve(arena, &.{ b.graph.cache.cwd, root_source_file.getPath2(compile.root_module.owner, null) });
try compilations.append(arena, .{
.root_module = root_source_file_path,
});
Expand Down Expand Up @@ -1252,7 +1252,7 @@ fn extractBuildInformation(
try root_dependencies.put(
arena,
root_dep[0],
try std.fs.path.join(arena, &.{ package_info.build_root, "build.zig" }),
try std.Io.Dir.path.join(arena, &.{ package_info.build_root, "build.zig" }),
);
}
}
Expand Down Expand Up @@ -1353,7 +1353,7 @@ const copied_from_zig = struct {

// Now try appending ".0".
for (pkgs) |pkg| {
if (std.ascii.indexOfIgnoreCase(pkg.name, lib_name)) |pos| {
if (std.ascii.findIgnoreCase(pkg.name, lib_name)) |pos| {
if (pos != 0) continue;
if (mem.eql(u8, pkg.name[lib_name.len..], ".0")) {
break :match pkg.name;
Expand Down
Loading
Loading