zed icon indicating copy to clipboard operation
zed copied to clipboard

REPL: Support execution of R code blocks in markdown

Open JonGretar opened this issue 9 months ago • 4 comments

Summary

R code blocks are not sent to the jupyter kernel unlike python code blocks.

https://github.com/zed-industries/zed/pull/15100 added the ability to run markdown code blocks in the repl and it works beautifully.

However it does not work with R codeblocks. I can select the arc kernel and write the following:

    ```{R}
    a <- 2 + 2
    a
    ```

However it will not do anything if I ask it to run the cell.

I can change the cell type to {python} and it will perfectly happily send the R code to the arc kernel and evaluate it correctly.

So obviously everything works behind the scenes but code cell running is somewhere limited to python only. It would be nice to include other jupyter languages such as R, julia and so on.

Zed Version and System Specs

Zed: v0.179.3 (Zed) OS: macOS 15.3.2 Memory: 8 GiB Architecture: aarch64

JonGretar avatar Mar 30 '25 17:03 JonGretar

Hey there, R code is managed with the R extension, you can see the recommended steps for running R code and if you want us to include R markdown files, submit an issue to the R extension repo.

aymennasri avatar Apr 01 '25 14:04 aymennasri

Hey there, R code is managed with the R extension, you can see the recommended steps for running R code and if you want us to include R markdown files, submit an issue to the R extension repo.

Are you sure? The limitation seems to be added in the repl crate. repl_editor.rs to be specific.

https://github.com/zed-industries/zed/blob/64ef3ab09d8b88e1d9ecdf81ff4caa33d2984b52/crates/repl/src/repl_editor.rs#L455-L462

It seems that the R part is working perfectly. It's just that the repl implementation of markdown handling has a special exception for python and typescript. And I see no reason for why this should not include all jupyter languages. But I can see why there needs to be a list of languages. Otherwise we are sending mermaid code and all sorts of stuff to the kernels.

Possibly this could be a config value for the jupyter section of settings.json. ie.:

{
  "jupyter": {
    "available_languages": ["python", "julia", "typescript", "R"]
  }
}

JonGretar avatar Apr 01 '25 18:04 JonGretar

Yep. Looks like Zed hard coded support for TypeScript and Python support in https://github.com/zed-industries/zed/pull/15100.

Happy to review PRs if someone gets it working with R/Julia.

notpeter avatar Apr 29 '25 19:04 notpeter

Yep. Looks like Zed hard coded support for TypeScript and Python support in #15100.

Happy to review PRs if someone gets it working with R/Julia.

Made an attempt at this. Seems to work but this is my first time rusting.

JonGretar avatar Apr 30 '25 11:04 JonGretar