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: add configuration to ignore certain workspace folders #37697

Closed
stamblerre opened this issue Mar 5, 2020 · 16 comments
Closed
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@stamblerre
Copy link
Contributor

The workspace load looks at all files in a directory, but it seems it's not correctly excluding ignored files. VS Code also allows the user to ignore files with the "files.exclude" setting, which the language client should probably handle in some way? But that needs to be confirmed.

See microsoft/vscode-go#3036 for more context.

@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 5, 2020
@stamblerre stamblerre added this to the gopls/v0.4.0 milestone Mar 5, 2020
@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 Mar 5, 2020
@apmckinlay
Copy link

Would it make sense to ignore files and folders starting with '.' e.g. .git, .vscode, .history

Another possibility would be to respect .gitignore

@jniedrauer
Copy link

This is a problem for more than just gopls. x/mod has a hardcoded module size limit, and there is no way to ignore files or directories at the same level as the go.mod file. Either .gitignore should be respected or go.mod needs an exclusion section.

@stamblerre
Copy link
Contributor Author

I know that #37724 is tracking discussion of how files should be ignored by the go command, but we will definitely need a temporary work-around for gopls, since it will be a while before anything lands in the go command.

@heschik: Do you think that we can ignore files starting with . for type-checking/diagnostics as a work-around like @apmckinlay suggested?

@AndreasBackx
Copy link

AndreasBackx commented May 24, 2020

What about generated files? I am ignoring .gql.go files in .gitignore (not VS Code) as that's the suffix I am using for files generated by gqlgen that I do not want to check in.

@heschi
Copy link
Contributor

heschi commented May 26, 2020

@AndreasBackx I don't understand what that has to do with gopls. You may want to file a new issue, or at least explain exactly what you're looking for here.

@AndreasBackx
Copy link

@heschik my apologies, I was trying to mention that there still is a use case for excluded files that gopls will most likely need to still keep track of. When using generated files, they might be ignored/excluded, but are still essential for gopls to work as desired.

@heschi
Copy link
Contributor

heschi commented May 26, 2020

I see. Whatever is done for this will need to be in sync with the go command's behavior, so I don't think we'd be able to ignore individual files anyway. The vscode issue was for ignoring directories, which should be much more clear and not have the problems you're worried about.

@OneOfOne
Copy link
Contributor

OneOfOne commented Aug 6, 2020

I just got bit by this, one of my ignored folders have about 2 million auto generated files (not go files), but for some reason that pretty much kills gopls.

@ermik
Copy link

ermik commented Aug 28, 2020

Not all workspace folders can be assumed to be valid go module roots; I don't know if this is tracked in multi-module workspace issues but I just wanted to highlight it as explicit ignore setting for workspace folders is needed.

I noted how well jest.disabledWorkspaceFolders does it.

@stamblerre
Copy link
Contributor Author

stamblerre commented Sep 9, 2020

I believe that some part of this may be handled by the multi-module workspace proposal, which will not search for modules in any folder that the go command would ignore. Also, we will allow users to specify their own workspace module through a gopls.mod file, so that might be one way of managing ignored folders.

I do like the idea of a "disableWorkspaceFolders" configuration, thanks for bringing it up @ermik. Some users may just want a simple way of ignoring a single folder.

Edit: Note that this will only work for directory that are outside of a Go module. Directories within modules could not be ignored by the go command until #37724 is resolved.

@stamblerre stamblerre changed the title x/tools/gopls: ignore excluded or ignored files x/tools/gopls: add configuration to ignore certain workspace folders Sep 9, 2020
@heschi
Copy link
Contributor

heschi commented Sep 9, 2020

It seems to me that the original problems reported on this issue are related to hidden directories, and I believe that was fixed as of https://golang.org/cl/239288. I'm going to close this issue. If you still have a problem, please open a new issue as usual and we'll take a look.

@heschi heschi closed this as completed Sep 9, 2020
@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.5.0 Sep 9, 2020
@gonzojive
Copy link

gopls is offering "import" autocomplete options for a bazel directory within my workspace (and go.mod directory) that's in my "files.exclude" list.

I'm experiencing microsoft/vscode-go#3179 and guessing inclusion of bazel directories is causing gopls to slow down, but I haven't really diagnosed yet.

In any case, I can open a new bug for this as suggested above. The issue is identical, though, so please confirm a new issue is in order.

@stamblerre
Copy link
Contributor Author

In general, gopls doesn't really support Bazel well (https://github.com/golang/tools/blob/master/gopls/README.md#supported-go-versions-and-build-systems), so it's expected that you'd have see some odd behaviors. Folks are working on bazelbuild/rules_go#512, which will enable us to improve support for Bazel in gopls.

@adam-azarchs
Copy link
Contributor

Whatever is done for this will need to be in sync with the go command's behavior

The go command ignores symlinks (for a particularly pertinent example, bazel-out), but gopls does not.

@TobiaszCudnik
Copy link

I can still see references to files under hidden dirs in the server log, eg

[Info  - 6:05:34 PM] 2021/09/26 18:05:34 reloadOrphanedFiles reloading

Lists all files from .history.

@gonzojive
Copy link

It seems the proposal to add an ignore section to go.mod was rejected (chttps://github.com//issues/37724), so perhaps a different mechanism is needed for go tools to ignore directories that exist during development but not release.

I'll file a bug for my specific issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests