Show how to configure auto-completion in IntelliJ
sschuberth opened this issue · comments
Could you please extend the examples to also make auto-completion, e.g. in hello-kotlinx-html.scriptwithdeps.kts
, work in IntelliJ?
For example, if I'm extending ScriptWithMavenDeps
with a dummy property like
abstract class ScriptWithMavenDeps {
val dummy: String = "oink"
}
what does it take to offer dummy
when typing this.
in hello-kotlinx-html.scriptwithdeps.kts
?
It's a bit complicated and also the area where we're going to change thing soon, so we'll update the description later, but for an example what works now, you may have a look at simple-main-kts
here.
It works by 1) putting the definition into the separate module, and 2) include it as a dependency to the use-site module. A possible quirk is that you may need to compile the definition module and then reload the project in IntelliJ to make it work.
you may need to compile the definition module and then reload the project in IntelliJ to make it work.
That's indeed one of the (undocumented) pitfalls I ran into, but I eventually got it working in oss-review-toolkit/ort#4887.
Hi I am also looking to get autocompletion going in a custom script inside IntelliJ. Is this still up to date? The current KEEP mentions something about extra gradle config with the kotlinScriptDef
configuration. I am not seeing that anywhere here
extra gradle config with the
kotlinScriptDef
configuration. I am not seeing that anywhere here
For the record, I'm also not using the kotlinScriptDef
configuration in https://github.com/oss-review-toolkit/ort but still auto-completion works for the file at https://github.com/oss-review-toolkit/ort/blob/main/examples/evaluator-rules/src/main/resources/example.rules.kts.
I guess you only need the kotlinScriptDef
configuration if your project does not anyway depend (via the implementation
configuration) on the module that contains the script definitions.
It works by 1) putting the definition into the separate module, and 2) include it as a dependency to the use-site module.
Is there a way to have autocompletion for standalone scripts outside a project?
If by "standalone" you mean standard .main.kts
files, we get "Apply Context" for those in the top right. I'm using IntelliJ IDEA 2023.2.2 Ultimate with Kotlin plugin 232-1.9.0.
Are there any updates on this? It would be instrumental to be able to offer code completion in projects where the build system is not gradle and the script files are being used as config for custom tooling. (only the final jar is present that has the scripting host)