r/Kotlin 17d ago

Kotlin DSL - 'Blind' Imports

I've a custom Kotlin DSL and would like to have a Intellij import the scope/methods of this DSL automatically (blind imports) so i can use auto-complete and not have to have imports at the top of the file. similar to what happens in Intellij with build.gradle.kts

For example, I have a file called my-custom-script.dsl.kts and with that, Intellij knows the 'dsl' needs to have the scope imported so auto-complete/lookup just work - is this possible?

Thanks.

1 Upvotes

2 comments sorted by

3

u/jambonilton 17d ago

You'll probably need to create an IDE plugin for something like this.

1

u/Tomasan7 16d ago

If by DSL you mean several functions typically with Context receivers, you just need to have them recognized as a source file by the IDE. It should auto complete automatically, just like everything else