Skip to content

Kotlin ksp becomes unstable when using KSP Gradle plugin #225

Description

@kalin91

Summary

Applying the KSP Gradle plugin (com.google.devtools.ksp) to a module makes the Kotlin LSP unstable. After the plugin is applied, imports from external libraries are no longer resolved: they don't get semantic highlighting, hover/peek doesn't work, and Ctrl+Click navigation silently fails (the cursor turns into the pointer hand on hover, suggesting navigation is available, but clicking does nothing).

The project itself compiles fine via Gradle — this is purely an LSP/editor experience issue.

Reproduction

libs.versions.toml:

[versions]
ksp = "2.3.9"

[plugins]
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

Root build.gradle.kts:

plugins {
    alias(libs.plugins.ksp) apply false
}

app/build.gradle.kts:

plugins {
    alias(libs.plugins.ksp)
}

Applying KSP to the module is enough to trigger the regression — no processors need to be registered as ksp(...) dependencies for the symptoms to appear.

Expected behavior

  • External library imports are recognized and semantically highlighted.
  • Ctrl+Click on an import or symbol from a library navigates to its declaration (decompiled source or attached sources).
  • Hover/peek shows documentation and type info.

Actual behavior

  • External library imports are not semantically highlighted.
  • Ctrl+Hover shows the pointer-hand cursor as if navigation were available, but Ctrl+Click does nothing.
  • No "Go to Definition" target is offered for library symbols.
  • The behavior degrades the moment KSP is applied; removing the plugin restores normal LSP behavior.

Project-internal symbols (within the same module/codebase) still seem to resolve, but anything coming from a .jar dependency stops working.

Environment

  • VS Code version: 1.126.0
  • Kotlin by JetBrains extension version: 0.0.5
  • Kotlin version: 2.3.21
  • KSP version: 2.3.9
  • Gradle version: 9.4.1
  • JDK: 17.0.1 (openjdk)
  • OS: Linux Mint 22.3 (zena) - Linux 7.0.0-14-generic (x86-64)

Additional notes

Gradle build, compilation, and KSP code generation all work correctly from the CLI. The issue is strictly with the LSP-driven editor experience after the KSP plugin is applied to a module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions