Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: automatically include open packages in the workspace #54261

Closed
findleyr opened this issue Aug 4, 2022 · 3 comments
Closed

x/tools/gopls: automatically include open packages in the workspace #54261

findleyr opened this issue Aug 4, 2022 · 3 comments
Labels
gopls/metadata Issues related to metadata loading in gopls gopls/workspace Issues related to support for modules or multi-module workspaces. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Aug 4, 2022

Noticed indirectly via #53933: when packages are outside of the workspace, autocompletion stops working because it operates on packages in "TypeCheckWorkspace" mode, which means it does have function bodies for packages outside of the workspace.

That's not wrong, but we should automatically include any open packages in the workspace.

For the most part it should "just work" to adjust our workspace package algorithm, we just need to be sure to recompute workspace packages (snapshot.computeWorkspacePackages) following any didOpen or didClose event.

This is low-hanging fruit, as particularly with #53880 it could significantly improve the user experience with go.work files when opening a package outside the workspace: some functionality will still work, and the user will be alerted that other functionality will be degraded.

@findleyr findleyr added the gopls/workspace Issues related to support for modules or multi-module workspaces. label Aug 4, 2022
@findleyr findleyr added this to the gopls/v0.10.0 milestone Aug 4, 2022
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Aug 4, 2022
@findleyr
Copy link
Contributor Author

findleyr commented Aug 5, 2022

While working on an unrelated test, I realized that the heuristic is not quite right: we should not "include all packages containing open files" in the workspace, but rather "ensure that PackagesForFile(x) for all open files x is included in the workspace". The reason for this is actually subtle: if we reinitialize the view, we may not ask for PackagesForFile for files that aren't included in the workspace, so there is a chicken-and-egg problem.

@findleyr
Copy link
Contributor Author

findleyr commented May 3, 2023

Since this isn't critical for v0.12, moving to v0.13.

@findleyr
Copy link
Contributor Author

Redundant with zero-config.

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/metadata Issues related to metadata loading in gopls gopls/workspace Issues related to support for modules or multi-module workspaces. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants