zls
zls copied to clipboard
No autocomplete for packages
If i attempt to import a package (whether through exe.addPackagePath
or with a std.build.Pkg
with exe.addPackage
), i get no autocompletion or any language features if i try to import said package in my main.zig
file, ex const glfw = @import("glfw");
even though it builds and runs fine, but if i import the package manually by file ex const glfw = @import("../deps/mach-glfw/src/main.zig");
, completion does work, but it does not build due to a import of file outside package path
error (which zls should probably show)
not a bug
not a bug
That's not helpful either.
That essential features like this are ignored in zig tooling is one of the things holding zig back. If this is omitted by design then the design of zls is the bug.
Note that:
- zls, while useful for many people, is not official zig tooling, and
- a compiler server built into zig itself is planned.
It is the tooling currently available and its an issue on zls not zig so the issue is still relevant imho. So until the zig compiler provides a ground truth for a language server this puts an obstacle in front of arguably good coding standards. (modularization and abstraction through modules/packages)
zig does a lot of great things, but its good to remember it is still in its early stages. tooling (both official and community) is in a "best effort" situation right now. if this is a issue of great inspiration to you, then research/a pr is very much welcome. sorry for being crude earlier, I was going through a lot of notifications at the time
I know that maintenance of zls has changed hands a few times, and that makes it difficult knowing what’s a bug, when regressions have taken place, etc. Big thanks to @nektro for taking on a lot of the responsibilities!
I remember from way back looking into how zls worked and this function came to mind: https://github.com/zigtools/zls/blob/fd2a863245a70ab57ea2d7b9195f8ee9c5263579/src/DocumentStore.zig#L121
From what I can tell zls is supposed to autocomplete packages, but there must have been a regression.
I think as a community we could pour a little more love into our third-party tools like zls. The @ZigEmbeddedGroup is committed to improving the workflow for imported packages in zls — it’s invaluable for working with register definitions. In addition to this we’ll likely be the ones stressing performance and this will lead to more improvements that the community will benefit from.
Works for me on the latest master (ab62e58515956a35e54ded9ba55f2e6484b556a1)
Also works for me. Could you try again the latest master? @Beyley
@Beyley If you are still getting this issue can you check the output in vscode again as a much better error should be provided due to https://github.com/zigtools/zls/pull/569