gh.nvim icon indicating copy to clipboard operation
gh.nvim copied to clipboard

Issue with multi-root workspace folders (golang)

Open marcomayer opened this issue 2 years ago • 0 comments

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.

marcomayer avatar Aug 31 '22 08:08 marcomayer