Przeglądaj źródła

fix(kotlin-ls): improve root detection for Gradle multi-project builds (#6717)

Gabriel Patzleiner 1 miesiąc temu
rodzic
commit
da6df3d432
1 zmienionych plików z 13 dodań i 1 usunięć
  1. 13 1
      packages/opencode/src/lsp/server.ts

+ 13 - 1
packages/opencode/src/lsp/server.ts

@@ -1212,7 +1212,19 @@ export namespace LSPServer {
   export const KotlinLS: Info = {
     id: "kotlin-ls",
     extensions: [".kt", ".kts"],
-    root: NearestRoot(["build.gradle", "build.gradle.kts", "settings.gradle.kts", "pom.xml"]),
+    root: async (file) => {
+          // 1) Nearest Gradle root (multi-project or included build)
+          const settingsRoot = await NearestRoot(["settings.gradle.kts", "settings.gradle"])(file)
+          if (settingsRoot) return settingsRoot
+          // 2) Gradle wrapper (strong root signal)
+          const wrapperRoot = await NearestRoot(["gradlew", "gradlew.bat"])(file)
+          if (wrapperRoot) return wrapperRoot
+          // 3) Single-project or module-level build
+          const buildRoot = await NearestRoot(["build.gradle.kts", "build.gradle"])(file)
+          if (buildRoot) return buildRoot
+          // 4) Maven fallback
+          return NearestRoot(["pom.xml"])(file)
+    },
     async spawn(root) {
       const distPath = path.join(Global.Path.bin, "kotlin-ls")
       const launcherScript =