ldelossa / gh.nvim

A fully featured GitHub integration for performing code reviews in Neovim.
MIT License
520 stars 24 forks source link

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

Open marcomayer opened 1 year ago

marcomayer commented 1 year ago

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.