diff --git a/build.zig b/build.zig index 7b9b9e2..32b8efb 100644 --- a/build.zig +++ b/build.zig @@ -11,10 +11,8 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); exe.addModule("zls", b.dependency("zls", .{}).module("zls")); - exe.install(); - - const run_cmd = exe.run(); + const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { diff --git a/build.zig.zon b/build.zig.zon index 9e3bb28..6294319 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,8 +3,8 @@ .version = "1.0.0", .dependencies = .{ .zls = .{ - .url = "https://github.com/zigtools/zls/archive/build-runner-param-plus-library.tar.gz", - .hash = "1220d72a4bc8e8c934d3854b29e065cbe7d09328c83368b0e658d3f6c0acd7424d92", + .url = "https://github.com/zigtools/zls/archive/refs/tags/0.11.0.tar.gz", + .hash = "1220ef39b9be17640457ba1a737ebbc664d7b728a84b3e088d89258a115816bf28c9", }, }, } diff --git a/src/main.zig b/src/main.zig index 40c1e38..1d57a1a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -31,7 +31,7 @@ pub fn main() !void { // Create a server, then set its encoding // to utf-8 so we can use the same indices // as a normal zig []const u8 - var server = try zls.Server.create(allocator, &config, null, false, false); + var server = try zls.Server.create(allocator, &config, null); server.offset_encoding = .@"utf-8"; defer server.destroy(); @@ -48,7 +48,7 @@ pub fn main() !void { while (true) { // Free the server arena if it's past // a certain threshold - defer server.maybeFreeArena(); + //defer server.maybeFreeArena(); var stdio = std.io.getStdIn().reader(); const input = stdio.readUntilDelimiterOrEof(&input_buf, '\n') catch |err| switch (err) { @@ -71,15 +71,17 @@ pub fn main() !void { , .{input})); // We request completions from zls - const completions: []const zls.types.CompletionItem = (try server.completionHandler(.{ + + const emptyList: zls.Server.ResultType("textDocument/completion") = .{ .CompletionList = zls.types.CompletionList{ .isIncomplete = true, .items = &.{} } }; + const completions: []const zls.types.CompletionItem = (try server.completionHandler(allocator, .{ .textDocument = .{ .uri = "file:///C:/Programming/Zig/zls-as-lib-demo/src/bs.zig", }, .position = .{ .line = 4, - .character = @intCast(u32, 4 + input.len), + .character = @intCast(4 + input.len), }, - }) orelse zls.types.CompletionList{ .isIncomplete = true, .items = &.{} }).items; + }) orelse emptyList).?.CompletionList.items; // We print out the completions for (completions) |comp| {