zls
zls copied to clipboard
writeFile2 options give completions for `Dir` instead of options struct
Zig Version
0.12.0-dev.1856+94c63f31f
Zig Language Server Version
0.12.0-dev.336+5c0bebe
Client / Code Editor / Extensions
No response
Steps to Reproduce and Observed Behavior
const std = @import("std");
test {
std.fs.cwd().writeFile2(.{.<cursor>});
}
gives completion for fd field which is part of the cwd() Dir struct
Expected Behavior
give completions for WriteFileOptions
Relevant log output
No response
Maybe
diff --git a/src/features/completions.zig b/src/features/completions.zig
index ce92b9a..4460de3 100644
--- a/src/features/completions.zig
+++ b/src/features/completions.zig
@@ -1491,6 +1491,7 @@ fn collectFieldAccessContainerNodes(
if (field_access_slice[0] == '@') break :blk 1; // assume `@import("..").some.Other{.}`
var symbol_iter = std.mem.tokenizeScalar(u8, field_access_slice, '.');
const first_symbol = symbol_iter.next() orelse continue;
+ if (std.mem.eql(u8, first_symbol, "std")) break :blk if (try analyser.hasSelfParam(fn_proto_handle, full_fn_proto)) 2 else 1;
const symbol_decl = try analyser.lookupSymbolGlobal(handle, first_symbol, loc.start) orelse continue;
const symbol_type = try symbol_decl.resolveType(analyser) orelse continue;
if (!symbol_type.is_type_val) { // then => instance_of_T
I'm wondering if there should be a more reliable way to know if we're looking at the ret type of a fn as a self param to another..
PS Feel free to PR it if there're no side effects