apple / pkl-intellij

JetBrains editor plugins providing Pkl language support
https://pkl-lang.org/intellij/current/index.html
Apache License 2.0
49 stars 10 forks source link

add an Eval option for a pkl file #18

Open jstrachan opened 6 months ago

jstrachan commented 6 months ago

it would be super handy if there was a way to evaluate a pkl file from IntelliJ and then use the pkl source code viewer to show the results

e.g. right click on a pkl file and an Evaluate pkl option could appear

I find I'm often doing pkl eval something.pkl on the command line; then getting non-syntax highlighted & collapsable results; it'd be so much better to do this inside IntelliJ

even if all the plugin did was run pkl eval something.pkl with the file name and then piped the output to a temporary file and then opened it in the editor it'd be a nice start

stackoverflow commented 6 months ago

That's indeed a nice feature to have. Would need some drop down or input field to define which format to render to.

holzensp commented 5 months ago

For configurability, I imagine we want a Run Configuration template, so that you can set the output format, environment, feature flags, external properties, etc. I use my own ad-hoc configuration, invoking the CLI for "evaluate pkl file currently in focus," but it's surprising how much friction that focus requirement causes; I very often want to eval while I'm editing an upstream dependency. I think a good way to set an entry point would be nice.

jstrachan commented 5 months ago

For configurability, I imagine we want a Run Configuration template, so that you can set the output format, environment, feature flags, external properties, etc.

agreed. it'd be nice to have a default template Run Configuration for YAML (which you could configure if you wish to add feature flags/properties etc) which could be used OOTB via a combo box in the live view window without having to explicitly create and associate a Run Configuration for every pkl file; but if you really need to you could edit the generated default template for a particular file

you typically will have lots of pkl files; so having an easy way to render them as, say, YAML immediately via a click or two in the UI would be awesome; then allow editing of the Run Configurations for advanced users

holzensp commented 5 months ago

render them as, say, YAML immediately

That "say" is doing a lot of heavy lifting. YAML can't render certain things (Duration, Pair, ...). The choice for the default would have a big influence on the quality of the result. This is why we already do this, except we "say" Pcf ;)