-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adapt project to zls 0.11.0 #1
base: main
Are you sure you want to change the base?
Conversation
This reverts commit dfe9280.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed some things that need to be resolved before this can be merged.
If you have any more question, please let me know.
@@ -11,10 +11,8 @@ pub fn build(b: *std.Build) void { | |||
.optimize = optimize, | |||
}); | |||
exe.addModule("zls", b.dependency("zls", .{}).module("zls")); | |||
exe.install(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be replaced with b.installArtifact(exe);
@@ -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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no equivalent function for maybeFreeArena
. Instead you should create your own ArenaAllocator here and use it when sending request to the 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, .{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't intend for the completionHandler
to be directly accesible here. Could you please call server.sendRequestSync(arena, "textDocument/completion", params)
here.
You are also leaking memory here because completionHandler
expects a arena-like allocator but you are passing std.heap.page_allocator
.
}, | ||
}) orelse zls.types.CompletionList{ .isIncomplete = true, .items = &.{} }).items; | ||
}) orelse emptyList).?.CompletionList.items; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the unwrap is needed here because zls.Server.ResultType("textDocument/completion")
is the following type:
https://github.com/zigtools/zls/blob/5bfff2a4b9ee01a7bab5fc26fad6e174f289c28d/src/lsp.zig#L7441-L7445
?union(enum) {
array_of_CompletionItem: []const CompletionItem,
CompletionList: CompletionList,
pub usingnamespace UnionParser(@This());
}
This means that ((try server.completionHandler(...)) orelse emptyList)
resolves to an optional because emptyList
is optional.
This pull request adapts zls as lib demo to zls version 0.11.0.
Things I'm not sure:
orelse
provides default value