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 · 11 comments
Closed

x/tools/gopls: add configuration to ignore certain workspace folders #37697

stamblerre opened this issue Mar 5, 2020 · 11 comments

Comments

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Mar 5, 2020

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.

@apmckinlay
Copy link

@apmckinlay apmckinlay commented Mar 5, 2020

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

@jniedrauer jniedrauer commented Mar 6, 2020

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

@stamblerre stamblerre commented Mar 9, 2020

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 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.

@heschik
Copy link
Contributor

@heschik heschik 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

@AndreasBackx AndreasBackx commented May 26, 2020

@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.

@heschik
Copy link
Contributor

@heschik heschik 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 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 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 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
@stamblerre stamblerre moved this from Maybe to Critical in gopls: on by default in vscode-go Sep 9, 2020
@heschik
Copy link
Contributor

@heschik heschik 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.

@heschik heschik closed this Sep 9, 2020
gopls: on by default in vscode-go automation moved this from Critical to Closed Sep 9, 2020
@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.5.0 Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.