zigtools / zls

A Zig language server supporting Zig developers with features like autocomplete and goto definition
MIT License
3.06k stars 301 forks source link

A problem with zls and a VSCode workspace spread out over multiple folders #705

Open unvestigate opened 2 years ago

unvestigate commented 2 years ago

I am using zig version 0.10.0-dev.4253+fa9327ac0 and zls commit 19fd17ff76d055606e2e9dde9e09dac7f9538430.

I have a VSCode workspace, the structure of which looks like this:

{
    "folders": [
        {
            "path": "."
        },
        {
            "name": "Basis",
            "path": "../Basis/zig"
        },
        {
            "name": "Goofy",
            "path": "../Goofy/zig"
        },
        {
            "name": "VHL",
            "path": "../ZigLibs/VehicleHelperLibrary"
        }
    ],
    "settings": {
        "editor.formatOnSave": true
    }
}

The "Basis", "Goofy" and "VHL" folders are included as packages in the build.zig file. They don't have build.zig files themselves. ZLS seems to be able to provide pretty nice intellisense for zig files in the "main" folder, but it often fails to do so when working in any of the other packages. It's not very consistent though. Sometimes it seems to work for those packages too only to fail a minute later, simply not doing anything when typing a symbol followed by a period, and expecting the editor to show suggestions. The project's build.zig file is sitting in the "main" folder, ie. at path "." in the workspace above.

Are there any known issues with the setup I am using, eg. not supporting folders without a build.zig or something? I can try to debug and possibly fix the issue but I am unsure where to start looking. Does zls log errors and warnings somewhere?

unvestigate commented 2 years ago

I am happy to report that adding build.zig files to the roots of the packages seems to help a lot. I just have to make it very clear to anyone reading the code (including future me) that those packages shouldn't be built individually. So it's a bit of a hack, but it brings autocompletion to parts that previously haven't had any.