emacs-lsp / lsp-metals

lsp-mode :heart: metals
https://emacs-lsp.github.io/lsp-metals
GNU General Public License v3.0
58 stars 33 forks source link

lsp-metals always guesses the wrong project root. #31

Closed endrebak closed 3 years ago

endrebak commented 3 years ago

Describe the bug

l open the file ~/code/functional_scala/recfun/build.sbt (downloaded from http://alaska.epfl.ch/~dockermoocs/handouts-coursera-2.13/recfun.zip). The project root is (obviously?) ~/code/functional_scala/recfun/. Still, lsp-metals guesses the root is ~/code/functional_scala.

LSP :: Guessed project root is ~/code/functional_scala

To Reproduce

See above.

wget http://alaska.epfl.ch/~dockermoocs/handouts-coursera-2.13/recfun.zip
unzip recfun.zip

Now open the file build.sbt in the recfun folder in emacs.

Expected behavior

LSP :: Guessed project root is ~/code/functional_scala/recfun/

Screenshots If applicable, add screenshots to help explain your problem.

Logs

;; M-x lsp-metals-doctor-run
Metals Doctor

These are the installed build targets for this workspace. One build target corresponds to one classpath. For example, normally one sbt project maps to two build targets: main
and test.

⚠️ No build targets were detected in this workspace so most functionality won't work.

* Make sure the workspace directory '/Users/endrebakkenstovner/code/functional_scala' matches the root of your build.
* Try removing the directories .metals/ and .bloop/, then restart metals And import the build again.

I have tried to remove the .metals directory. .bloop was never created.

yyoncho commented 3 years ago

Please report that in doom repo.

Guessed project root is

This message does not come from lsp-mode. By default lsp-mode asks the user to confirm project root so the user can correct the suggested directory. If you set lsp-auto-guess to t you should make sure that projectile will return the correct project root.

endrebak commented 3 years ago

When I tried to download recfun to my root folder it worked. So I guess this bug is not reproducible.

Is there a way to select root path and Import build after being asked the first time? After opening the .sbt file you get asked once, but never again.

endrebak commented 3 years ago

Please report that in doom repo.

Will do!

make sure that projectile will return the correct project root.

Is there a way to set project root again in lsp-mode?

endrebak commented 3 years ago

Feel free to close btw.

yyoncho commented 3 years ago

Use lsp-workspace-folders-add/remove to manage the workspace folders.