scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.09k stars 332 forks source link

incorrect build root directory when build.gradle is in a sub-directory #900

Closed eriklovlie closed 5 years ago

eriklovlie commented 5 years ago

Describe the bug

I have a project that is inside a sub-directory, i.e. there's no build.gradle in the root directory of the git worktree. The metals.log says this after I open a scala file in this project in emacs:

WARN  no build tool detected in workspace '/path/to/git/clone'. The most common cause for this problem is that the editor was opened in the wrong working directory, for example if you use sbt then the workspace directory should contain build.sbt. 
WARN  no build target: /path/to/git/clone/subdir/src/main/scala/blabla/Main.scala

To Reproduce

  1. Install lsp-mode in emacs and metals-emacs exactly as specified in https://scalameta.org/metals/docs/editors/emacs.html as of 2019-09-05
  2. Open emacs
  3. Try to open a scala file
  4. When asked for an action you import the project
  5. Try to navigate to a type definition

Expected behavior

I expected the top-most build.gradle to define the root of the project, not the git root directory.

tgodzik commented 5 years ago

Thanks for reporting! I think you need to open Emacs at the directory where build.gradle is defined. It's the LSP client that sends and information about the workspace root, not Metals.

We don't currently search for subdirectories and I don't think this is a use case we will support.