ktlint-intellij-plugin
ktlint-intellij-plugin copied to clipboard
Support IntelliJ's K2 mode?
K2 Kotlin Mode (Alpha) in IntelliJ IDEA
When enabled and the IDE restarted, the ktlint plugin is disabled.
Of course, this is in alpha, but would be handy and cool to see if it works using K2.
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.
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.
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...
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)
Jetbrains just posted this: https://kotlin.github.io/analysis-api/migrating-from-k1.html
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.
Blocked by #568