ziglang / zig.vim

Vim configuration for Zig
MIT License
448 stars 56 forks source link

Indentation - fixing "lone" else lines #59

Closed yohannd1 closed 2 years ago

yohannd1 commented 3 years ago

Currently, "lone" else lines don't seem to indent properly. I'm trying to fix that. Current progress on this branch (you should be able to =G from the first line and have the same result):

{
    if (cond) branchA()
else branchB(); // not properly indented yet
}

{
    if (cond) branchA()
    else branchB();

    if (cond)
        if (foo)
            blk: {
                break :blk branchA();
            }
        else
            branchB();
    else
        branchB();

    const val = if (cond) branchA();
    else branchB();

    const val = if (cond)
        branchA();
    else
        branchB();

    const val = if (cond) blk: {
        break :blk branchA();
    }
    else blk: {
        break :blk branchB();
    }
}

Suggestions are appreciated!

Also, the method I'm doing uses a for loop - I'm not sure if that's very efficient so that might be a thing to be changed later.

haze commented 2 years ago

Are you still working on this? If not, I'd appreciate closing the issue and leaving the branch up for someone else to continue the work, and opening an issue with a description (if you want) edit: I see that you have it linked in the other PR

yohannd1 commented 2 years ago

Yeah... I was working on this the other day but I didn't really get anywhere. I think I'll make an issue for that then. (And if the issue you mentioned is #42, that's not really related. That one is related to the PR #56)

yohannd1 commented 2 years ago

Done! Created #73. Closing this PR now.