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

Issue with multi-root workspace folders (golang) #71

Open
marcomayer opened this issue Aug 31, 2022 · 0 comments
Open

Issue with multi-root workspace folders (golang) #71

marcomayer opened this issue Aug 31, 2022 · 0 comments

Comments

@marcomayer
Copy link

marcomayer commented Aug 31, 2022

In some cases when opening a PR and then trying to open a file for a diff, it can't find it because the path is wrong.

Let's say the path is this/my/pkg and I try to open the file this/my/pkg/subpkg/file.go I'll get an error that the file can't be found by gopls LSP[gopls] Error loading workspace folders (expected 1, got 0) failed to load view for file:///Users/projects/this/my/pkg/subpkg/my/pkg/subpkg/: invalid workspace folder path: no such file or directory

So it seems like it's adding the whole path to the path again. I'm not sure where and why this happens but when I just open the file the normal way, everything works fine.

I'm not entirely sure what the problem is but the repo has multiple workspace roots, so if I check vim.lsp.buf.list_workspace_folders() I get {"this/", "this/my/pkg/"}. My guess now is that instead of using the first one ("this/") and adding the file path to it, the second one is used to add the whole path.

Maybe something like local workfolder = vim.lsp.buf.list_workspace_folders()[1] or vfn.getcwd() when determining the path might help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant