-
(related to: #580) Hi, There's a very large project called Chipyard which has one big build.sbt file, which loads all sub-projects inside it, and (most importantly) declares all of the sub-projects' dependencies with each other. For example, most sub-projects depend on one specific sub-project named For example, the project I'm currently working on has a line in that main build.sbt which declares its dependencies and settings: lazy val messagequeue = (project in file("generators/message-queue"))
.settings(commonSettings).dependsOn(rocketchip, constellation)
.settings(libraryDependencies ++= rocketLibDeps.value) I can get Metals to load that main In the Chipyard project, that file's relative path is If I define library dependencies inside message-queue's build.sbt like this: libraryDependencies ++= Seq(
"edu.berkeley.cs" %% "chisel3" % chiselVersion,
"edu.berkeley.cs" %% "chiseltest" % "0.5.4" % "test",
"edu.berkeley.cs" % "rocketchip_2.12" % "1.2.+"
) then the Chipyard repo's setup process will fail, because crucially, the version of lazy val root = (project in file("."))
.settings(
name := "messagequeue",
libraryDependencies ++= Seq(
"edu.berkeley.cs" %% "chisel3" % chiselVersion,
"edu.berkeley.cs" %% "chiseltest" % "0.5.4" % "test",
"edu.berkeley.cs" % "rocketchip_2.12" % "1.2.+",
),
scalacOptions ++= Seq(
"-language:reflectiveCalls",
"-deprecation",
"-feature",
"-Xcheckinit",
"-P:chiselplugin:genBundleElements",
),
addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % chiselVersion cross CrossVersion.full),
) the setup process will also fail for a different reason (something about "messagequeue" not being a valid project). So I also can't define dependencies that way. Really, I'm only able to define organization, name, version, and scalaVersion in message-queue's build.sbt. But then if I tell Metals to load message-queue's build (as it prompts me any time I load that sub-project), and then open MessageQueue.scala, it doesn't recognize the dependencies as defined in the main build.sbt, and so it throws a thousand errors (because it doesn't recognize any of the imports). So I'm really stuck between a rock and a hard place. What I need to do is have Metals load the main build.sbt, and ignore the barebones build.sbt within the subproject, so that it recognizes all my dependencies. Is that possible? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
-
So I'll start off with saying I'm not sure how helpful I'll be if I can't actually try to reproduce what you're experiencing, but I'll try my best. So I think in general what might be happening is that you're hitting on this #417. Basically
Is this right? If so nvim-metals doesn't know how to go that many layers deep. It will only check one layer deep. It does this because if not, if you would have something like
It would end up thinking these two are one project. So a reasonable default is it finds the So in your scenario the moment you open up Again if I'm understanding right, this is a bit of an unconventional setup in Scala and one thing that you could try is to hack the |
Beta Was this translation helpful? Give feedback.
YES!!!! thank you so much!!! I managed to get it to work by modifying find_root_dir to check one level higher. This is now my config (in AstroNvim's
user.lua
, if anyone happens upon the same issue: