OPENRNDR with vscode

hello community!

wanna introduce how to use visual studio code for OPENRNDR.

I’m not familiar with JAVA/kotlin compilation on terminal so it was bit hard first time but had conversation with @abe. now it’s available.

so far linux and mac works. but here’s how you can.

  1. download vscode
  2. open cloned openrndr-template folder with vscode
  3. update build.gradle.kts as here
  4. download zip file from vscode helper repo
  5. unzip and paste to openrndr-template folder
  6. open any source code
  7. open command palette by ctrl+shift+p (cmd+shift+p for macOS),
  8. type tasks: Run Task then you can see OPENRNDR RUN

vscode support tasks.json for run shell command. and also run shellscript.
all codes can see here repository.

so if you have better idea, or found a bug, post issue or pull requst.

2 Likes

Hi @icq4ever

Huge respect that you are trying to do it in an ecosystem which considers JVM/Java/Kotlin stack as almost hostile and competitive entities. As gradle is the build system chosen by OPENRNDR, I would suggest trying this integration:

However I’ve never used VS Studio, so I cannot tell much about maturity of these plugins. Knowing how fast gradle evolved in recent years, and how even JVM-native IntelliJ has sometimes troubles keeping up, I predict many obstacles on your way.

Good luck!

1 Like

hello @kazik

thank you for pointing that! I completely miss that way.

I just installed and wow you right that extention read gradle setting directly. but at the moment it cannot pass -P argument as terminal.

Configuration cache is an incubating feature.
Reusing configuration cache.
<==========---> 80% EXECUTING [95ms]
> :run
Error: Could not find or load main class extension 'application'Kt
Caused by: java.lang.ClassNotFoundException: extension 'application'Kt

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/home/icq4ever/.sdkman/candidates/java/17.0.5-ms/bin/java'' finished with non-zero exit value 1

for example, if I want to run src/main/kotlin/example/Example01.kt, terminal command like this

$ ./gradlew run -Pexample.Example01

gradle extension should work. I’ll take a deeper look.

well, my approach mainly rely on shell script so can be used in vim or other terminal based editor.

here’s similar topic I found.

Thank you for your contribution! :slight_smile: I hope this can bring a few new users to the community :slight_smile:

I don’t know if it’s a copy paste error, but the command is missing here

$ ./gradlew -Pexample.Example01

it should actually be

$ ./gradlew run -Pexample.Example01
1 Like

ah that’s my mistake :slight_smile: fixed

still gradle extension for vscode still issue. answer should be somewhere…

Executing task: gradle: run 

Configuration cache is an incubating feature.
Reusing configuration cache.
<==========---> 80% EXECUTING [571ms]
> :run
Error: Could not find or load main class extension 'application'Kt
Caused by: java.lang.ClassNotFoundException: extension 'application'Kt

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/home/icq4ever/.sdkman/candidates/java/17.0.5-ms/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

> Task :run FAILED
3 actionable tasks: 1 executed, 2 up-to-date
Configuration cache entry reused.
Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.6-bin.zip'.
 *  The terminal process terminated with exit code: 1. 

What if you run the task openrndr > run TemplateProgramKt (at the top of the list)?

I don’t know why it’s trying to run 'application'Kt.

I tried following the steps above but I don’t see an OPENRNDR RUN task.

Do I have to install a Kotlin or Gradle plugin?

Update: Ah I see what I did wrong. I just need to drop the .vscode folder and the openrndr-vscode-launcher.sh file inside openrndr-template.

Then it actually worked! For the 3 .kt files I tested. When I pasted Other.kt into foo it even added the right package automatically.

image

More feedback: I installed the Kotlin extension but I don’t know why most of the code is marked as an error, even if I can run it fine. I restarted the language server but it didn’t help.

It seems to be because incompatible Kotlin versions but I don’t know how to change that:

And something minor: in Idea I can type drawer.stroke = WHITE and it will autocomplete to ColorRGBa.WHITE but vscode doesn’t do that. This is very convenient in Idea because it shows the constants I’m allowed to use in a given line.

happy to hear that works well!

and for the reason why kotelin extension not work properly because “kotlin language server”, not support “1.8.0” yet. (we talked about that last time here). it will work as change “1.8.0” to “1.6.0” here .

after change it, restart kotlin language server by command prompt in vscode.
kotlin extension start index for a while, and as soon as it ready, you can see code suggestion like this.



++ PLUS
sometimes kotlin language server is not launching because it cannot find proper JAVA bin.
in this case you can set java JAVA_HOME path in vscode setting for kotlin settings.

you can find JAVA_HOME by which java in terminal.
(FYI, I installed JAVA with sdk man)

hope this helps!

Thank you, yeah I already forgot about the 1.6.0 vs 1.8.0 hehe :slight_smile:

Maybe when this is updated in the Kotlin language server repo we could include the .vscode folder in openrndr-template, or at least create a openrndr-vscode-template so then one can just clone and start working :slight_smile:

yeah that sounds good :slight_smile: maybe add integrate with vscode? for advanced user.

btw I’m struggling with on windows. shellscript is not compatible with git bash. (‘/’ is not recognized with it)
so anyone have a experience with windows powershell, or cmd, git bash. it might be super helpful.

I tried but still same result. :frowning: