-
-
Notifications
You must be signed in to change notification settings - Fork 859
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
Nested go.mod files not handled well #3473
Comments
It looks like with #2619 it might be possible now to simply |
We cannot solve automatically problems like that because everything is case by case. That is why we leave to the user to interactivelly select the project roots. |
Would a pull request be accepted to add documentation to https://emacs-lsp.github.io/lsp-mode/page/lsp-gopls/ about how to resolve this error message? |
Of course. |
Awesome, will try to submit something later this week. |
Created #3483. |
Thank you for the bug report
lsp-mode
related packages.M-x lsp-start-plain
Bug description
lsp-mode does not seem to work transparently with nested modules under gopls. When having a nested go.mod file in a subdirectory of a repository, autocompletions and source navigation do not work for the code in the nested project.
Steps to reproduce
Sample code: https://github.com/raxod502-plaid/gopls-issue-repro
Upon opening
main.go
at the root of the repository, LSP prompts to add the repository root as a workspace directory. This is correct, and required to get autocompletions for that file. Autocompletions work fine for files outside the subproject.However, upon opening
subproject/main.go
in the subproject, LSP does not realize that it needs a separate workspace directory, and uses the existing repository root for it. This causes errors to immediately appear (e.g., inlsp-start-plain
, errors are highlighted with Flycheck; see screenshots below).This error appears in
*lsp-log*
:Screenshots:
Expected behavior
lsp-mode should automatically detect the nested go.mod file and use a separate workspace directory for files under that directory, with no user intervention required.
Or, if this is not possible, instructions on how to manually configure lsp-mode to work correctly for a multi-module project should be available at https://emacs-lsp.github.io/lsp-mode/page/lsp-gopls/.
Which Language Server did you use?
gopls
OS
macOS
Error callstack
No response
Anything else?
See also:
This is tested using macOS Monterey 12.3.1, Emacs 28.1 configured
--with-json --with-native-compilation
, gopls e1e2a49 via radian-software/straight.el@e2de88e, and gopls 0.7.5.The text was updated successfully, but these errors were encountered: