How can I turn on the syntax highlighting for top ...
# scripting
i
How can I turn on the syntax highlighting for top level kts scripts on Intellij? tried adding the stdlib to the module but didn't work
n
syntax highlighting only happens when the file is n a sourceset i think
and specialcased for gradle scripts
i just found that myself:

https://i.imgur.com/idJPLGm.png

possibly you could edit the kotlin configuration of the mudule .. i guess that would be the root module..and define the classpath and classes for kotlin scripting
i
It could be specialized for any custom script, not only for gradle. But you need to have a script definition for it, and make IDEA aware of it. We need to make docs about it, but the whole topic is a moving target, so it probably takes some time. Sorry about it.
n
but afaik it eeds to be in a module at least.. and configuring the root module did not work for me when i tried.. i am not sure how to reference where it can find the script definition since that is in the classpath of the
_main
module
but yes, docs would be helpful and i would LOVE it if there is a way to configure the kotlin-scripts definitions on a module using the gradle-idea plugin so i do not have to redo the whole process on every device or write a detailed setup guide
i
Besides classpath discovery (that would work on script in source roots anyway), you can write a plugin or supply definition via compiler options in IDEA.
n
compiler options so that idea recognizes it.. as in if i add the script to the javac options idea will pick up on that ?
i
About the configuring from the gradle - could you, please, give more info: are you using scripts outside of source roots?
n
i would like to, yes, because if they are inside sourceroots then running a gradle task will compile the scripts that will then just get recompiled by my application
but if they are outside, currently the highlighting does not work
the only thing that is affected is the startup speed when running it through gradle .. it feels like i could shave off 2-3 seconds before it actually starts working by skipping th compilation of all scripts in sourceroots
i
I’m not sure I understand the question about the options, but what I mean is IDEA preferences (settings) -> Build, Execution, Deployment -> Compiler -> Kotlin Compiler -> Kotlin Scripting. Are you aware of these?
About the scripts outside of the source roots - we’re thinking about it, but so far there are quite many open questions. But I hope we’ll be able to offer some solution here as well.
n
i saw those options.. but i am not sure what to put there, should the field
Script template classes
get the fully qualified classname? eg.
com.example.ScriptDefinition
but what do i write in the classpath field? the jar of the library or what ?
i
Jar with all dependencies, if there are any.
n
that is usually on mavenLocal or a remote maven.. maybe possible if i make a gradle task to download the shadowedJar from jenkins.. but this already seems overcomplicated
or i make a task that just creates the shadowjar in a libs folder.. that might just work if i find a way to run this after idea import
i
It wasn’t implemented as a proper tool, more like a workaround. Initial assumption was that if you need a support for a custom non-source scripts in the IDE, you have to add an IDEA plugin. Maybe we should provide some more light-weight way to do it, but so far we are not.
n
i hoped i could get away without idea plugin and just provide a simple jar that opens a JFileChooser to pick a folder and that owuld then create a gradle project with the correct dependencies
162 Views