FalsePattern / ZigBrains

The zig language plugin for intellij
https://plugins.jetbrains.com/plugin/22456-zigbrains
Other
105 stars 7 forks source link

no autocompletion with 0.9.0 #25

Closed chrispickard closed 3 months ago

chrispickard commented 9 months ago

I updated to 0.9.0 and lost autocompletion.

I'm on CLion 2023.2.2 Build #CL-232.9921.42

JensvandeWiel commented 8 months ago

What is your ZLS version? It should be 0.9.0

FalsePattern commented 7 months ago

@chrispickard Does this still happen with ZigBrains 12.0.0 and the latest master branch builds of zig and zls?

SvenMuth commented 4 months ago

I have some problems with autocompletion for variables i have created. It kind of depends on the scope whether it is completed or not. I'm using CLion 2024.1.2, ZigBrains 15.0.0, and ZLS 0.12.0.

FalsePattern commented 4 months ago

I have some problems with autocompletion for variables i have created. It kind of depends on the scope whether it is completed or not. I'm using CLion 2024.1.2, ZigBrains 15.0.0, and ZLS 0.12.0.

Please share the code this happens with so that i can test it on my side.

And also the exact version of zig you're using, ZigBrains currently only supports the master branch nightly builds of zig 0.13.0 with the master branch versions of ZLS 0.13.0

SvenMuth commented 3 months ago

Thanks for the fast response. I updated to 0.13.0 and got the same behavior. I'm new to Zig, so maybe it could be just a mistake on my side, but it should suggest the known variables, shouldn't it?

zig: 0.13.0-dev.349+4918c2ce2 and I build zls new with zig build -Doptimize=ReleaseSafe from the master branch. ZigBrains: 15.0.0-241

const std = @import("std");

pub fn main() !void {
    const fileName = "day1.txt";

    //'fileName' no autocompletion
    const file = try std.fs.cwd().openFile(fileName,.{});
    defer file.close();

    var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
    defer arena.deinit();
    const allocator = arena.allocator();

    //'allocator' no autocompletion
    const read_buf = try file.readToEndAlloc(allocator, 1024 * 1024);
    //'read_buf' no autocompletion
    defer allocator.free(read_buf);

    var it = std.mem.split(u8, read_buf, "\n");

    //'allocator' no autocompletion
    var elfArray = std.ArrayList(u32).init(allocator);
    defer elfArray.deinit();

    var elfCarryingAmount: u32 = 0;

    while(it.next()) |amount| {
        //'amount' no autocompletion
        if(amount.len == 0){
            //'elfCarryingAmount' no autocompletion
            try elfArray.append(elfCarryingAmount);
            elfCarryingAmount = 0;
        } else {
            const result: u32 = try std.fmt.parseInt(u32, amount, 10);
            elfCarryingAmount += result;
        }
    }
}
FalsePattern commented 3 months ago

I've found the issue, I'll put the fix in 15.0.2.

The autocompletion "word searcher" logic didn't consider ( as a separator symbol so it was trying to autocomplete free(..., if(..., etc., instead of treating the cursor right after a parenthesis as a blank autocomplete.

As a temporary workaround until the update is released, you can put a space after typing a ( and autocomplete will work