ktlint-intellij-plugin icon indicating copy to clipboard operation
ktlint-intellij-plugin copied to clipboard

Support IntelliJ's K2 mode?

Open ryanlewis opened this issue 10 months ago • 2 comments

K2 Kotlin Mode (Alpha) in IntelliJ IDEA

When enabled and the IDE restarted, the ktlint plugin is disabled.

image

Of course, this is in alpha, but would be handy and cool to see if it works using K2.

ryanlewis avatar Apr 16 '24 16:04 ryanlewis

For the moment this will not be possible according to this blog of Jetbrains:

Third-party IntelliJ IDEA plugins depending on the Kotlin plugin will be disabled. We will provide migration guidance for third-party plugin authors soon!

I will investigate once more information becomes available.

paul-dingemans avatar Apr 17 '24 15:04 paul-dingemans

As of today, it is still not possible to run the plugin in K2 mode. Other plugins (for example Ktor) suffer from the same problem.

paul-dingemans avatar Jun 11 '24 10:06 paul-dingemans

The most(?) recent guidance:

Why does IntelliJ IDEA return the “plugin is incompatible with K2 mode” error?

Some third-party IntelliJ IDEA plugins may currently be unavailable because of recent changes to the Kotlin Plugin API. We’re actively working on assisting plugin authors to quickly make their plugins compatible with K2 mode.

https://blog.jetbrains.com/idea/2024/08/meet-the-renovated-kotlin-support-k2-mode/

Hopefully they will be reaching out...

jasonab avatar Aug 08 '24 23:08 jasonab

and from the Slack:

Roman Golyshev [JetBrains] Today at 2:40 AM Hi! Regarding the K1/K2 compiler APIs difference, you can consult this guide: https://kotlin.github.io/analysis-api/migrating-from-k1.html There is a catch, however: at the moment, you would not be able to fully enable your IDE plugin with K2 Mode even if you make it fully compatible with it. Currently our team is in the process of preparing clear migration mechanisms for 3rd party plugins authors, but it is a WIP We’ll probably do some announcements here (in the public Kotlin Slack) when we have some news on that matter Meanwhile, you can see the guide above and understand how much you would need to change the code of your plugin to make it compatible with K2 Mode :pray: (edited)

jasonab avatar Aug 08 '24 23:08 jasonab

Jetbrains just posted this: https://kotlin.github.io/analysis-api/migrating-from-k1.html

jasonab avatar Aug 12 '24 16:08 jasonab

Tnx for sharing. Unfortunately, this documentation does not help me to determine what needs to be changed so that the plugin can be used in projects that have enabled K2 mode. The Ktlint Intellij Plugin is not doing the code analysis itself, but uses the depencies provided by the ktlint project (for which I am the maintainer as well). If the incompatibility of the plugin can only be resolved by migrating ktlint from K1 to K2 compiling, than this will be a big project as every rule in Ktlint and a part of the KtlintRuleEngine need to be rewritten . I am estimating this to be multiple man months (full time) of work, which I can not afford to spend on it.

paul-dingemans avatar Aug 13 '24 06:08 paul-dingemans

Blocked by #568

paul-dingemans avatar Sep 09 '24 14:09 paul-dingemans