zls icon indicating copy to clipboard operation
zls copied to clipboard

No autocomplete for packages

Open Beyley opened this issue 2 years ago • 9 comments

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)

Beyley avatar Feb 21 '22 01:02 Beyley

not a bug

nektro avatar Feb 22 '22 03:02 nektro

not a bug

That's not helpful either.

dxps avatar Mar 18 '22 10:03 dxps

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.

GideonUng avatar Apr 12 '22 15:04 GideonUng

Note that:

  1. zls, while useful for many people, is not official zig tooling, and
  2. a compiler server built into zig itself is planned.

andrewrk avatar Apr 12 '22 17:04 andrewrk

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)

GideonUng avatar Apr 12 '22 17:04 GideonUng

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

nektro avatar Apr 12 '22 17:04 nektro

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.

mattnite avatar Apr 12 '22 17:04 mattnite

Works for me on the latest master (ab62e58515956a35e54ded9ba55f2e6484b556a1)

mifopen avatar Jul 21 '22 06:07 mifopen

Also works for me. Could you try again the latest master? @Beyley

jiacai2050 avatar Jul 25 '22 14:07 jiacai2050

@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

leecannon avatar Aug 23 '22 20:08 leecannon