Skip to content

Commit da6df3d

Browse files
authored
fix(kotlin-ls): improve root detection for Gradle multi-project builds (anomalyco#6717)
1 parent b9b0e34 commit da6df3d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/opencode/src/lsp/server.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,19 @@ export namespace LSPServer {
12121212
export const KotlinLS: Info = {
12131213
id: "kotlin-ls",
12141214
extensions: [".kt", ".kts"],
1215-
root: NearestRoot(["build.gradle", "build.gradle.kts", "settings.gradle.kts", "pom.xml"]),
1215+
root: async (file) => {
1216+
// 1) Nearest Gradle root (multi-project or included build)
1217+
const settingsRoot = await NearestRoot(["settings.gradle.kts", "settings.gradle"])(file)
1218+
if (settingsRoot) return settingsRoot
1219+
// 2) Gradle wrapper (strong root signal)
1220+
const wrapperRoot = await NearestRoot(["gradlew", "gradlew.bat"])(file)
1221+
if (wrapperRoot) return wrapperRoot
1222+
// 3) Single-project or module-level build
1223+
const buildRoot = await NearestRoot(["build.gradle.kts", "build.gradle"])(file)
1224+
if (buildRoot) return buildRoot
1225+
// 4) Maven fallback
1226+
return NearestRoot(["pom.xml"])(file)
1227+
},
12161228
async spawn(root) {
12171229
const distPath = path.join(Global.Path.bin, "kotlin-ls")
12181230
const launcherScript =

0 commit comments

Comments
 (0)