Is there any documentation on how to customize com...
# scripting
j
Is there any documentation on how to customize completions, etc inside a script ? 🙂
i
Unfortunately the documentation is mostly missing, we’re working on it though.
j
Is there any example/usage I can have a look at ?
i
What exactly you want to learn from examples? You can find some examples in the kotlin repo, e.g. at https://github.com/JetBrains/kotlin/tree/master/libraries/examples/scripting
j
So what I am trying to build is a mini online editor that allows to write custom scripts. Currently, the editor (based on code mirror) only has syntax highlighting, sends the code to my backend when pressing a button and the code is evaluated. This editor would be used by people not very familiar with Kotlin, and I want to add suggestions in it
So I need some kind of api that allows me to say "given this code, current cursor position (line + column), and script configuration => give me the list of suggestions" so that I can send those suggestions to the editor
i
That’s complicated. We do not have such an API yet, although we’re thinking about providing one, exactly for this kind of purposes. There are some possibilities to get this functionality now via some internal APIs, but it is unsupported, not easy and it will not remain stable for sure.
j
Could you give me pointers to these internal APIs ? I don't mind that it's not stable 🙂
i
It is actually quite complicated even to find the strings. And it is changing al the time. Maybe the best way for now would be to have a look into the kotlin eclipse plugin - https://github.com/JetBrains/kotlin-eclipse - and try to understand how it gets this information from kotlin infrastructure. But as far as I know, they do not support scripts as of yet.