extensions icon indicating copy to clipboard operation
extensions copied to clipboard

R

Open mr-mobster opened this issue 2 years ago • 7 comments
trafficstars

Check for existing issues

  • [X] Completed

Language

R

Tree Sitter parser link

https://github.com/r-lib/tree-sitter-r

Language server link

https://cran.r-project.org/web/packages/languageserver/index.html

Misc notes

R is usually written as standalone R scripts *.R files or as part of Markdown notebooks/reports (R Markdown) *.Rmd, where R code is embedded inside code blocks marked with {r}, e.g.:

```{r}
print("this is some R code")
```

mr-mobster avatar Mar 10 '23 13:03 mr-mobster

Is there some way for community members to help in implementing this? I really like the editor and would like to use it more, but lack of language support is problem. E.g. I see that this is now classified as "potential plugin". Is there a plugin API yet?

tzakharko avatar May 05 '23 08:05 tzakharko

Hey @tzakharko, thanks for reaching out. It's currently not possible for the community to extend Zed, but extensibility is on our radar. The potential plugin label is mostly for our own sake as it helps us see what the community is asking for. Unfortunately, I don't have any timeline at this point, but I'll make sure to leave an update whenever we've got something to share. 🙂

hovsater avatar May 05 '23 08:05 hovsater

Thanks @hovsater! Keep up the good work! Looking forward to see what you will cook up!

tzakharko avatar May 05 '23 08:05 tzakharko

rlang is a good keyword to mention for easier search than just "r"

jangorecki avatar Dec 03 '23 17:12 jangorecki

Hi! I would like to work on this :)

doriancodes avatar Jan 29 '24 06:01 doriancodes

for helix editor, there is some R language support perhaps we can use as reference to build R support in zed:

https://github.com/helix-editor/helix/tree/master/runtime/queries/r https://github.com/r-lib/tree-sitter-r

ipstone avatar Apr 01 '24 22:04 ipstone

Hi all, R language support was merged as an extension in #100 and I just opened #656 which adds updated highlighting, outline, and LSP support.

Any suggestions or fixes very much welcomed!

ocsmit avatar Apr 30 '24 20:04 ocsmit

I really like Zed, but as it stands, if I cannot run R code directly from the editor, I will probably prefer RStudio to Zed. RStudio allows for the current line to be executed with CMD+Enter, at which point the cursor moves to the next line.

jtlandis avatar May 29 '24 01:05 jtlandis

@jtlandis these days I mostly use vscode R extension (https://github.com/REditorSupport/vscode-R ), which has really good evaluation/send code blocks to the terminal etc. Together with some keybindings, vscode/R can even mimics nvim-R keybindings.

I think the vscode R extension would be something that can used as a reference if such functionality would be implemented in zed - wondering if @ocsmit is interested at these?

ipstone avatar Jun 11 '24 16:06 ipstone

SCR-20240716-lzmm

JosephTLyons avatar Jul 16 '24 17:07 JosephTLyons

I really like Zed, but as it stands, if I cannot run R code directly from the editor, I will probably prefer RStudio to Zed. RStudio allows for the current line to be executed with CMD+Enter, at which point the cursor moves to the next line.

@jtlandis these days I mostly use vscode R extension (https://github.com/REditorSupport/vscode-R ), which has really good evaluation/send code blocks to the terminal etc. Together with some keybindings, vscode/R can even mimics nvim-R keybindings.

I think the vscode R extension would be something that can used as a reference if such functionality would be implemented in zed - wondering if @ocsmit is interested at these?

I fully agree with what has been said about eval/send-code functionality. I have been keeping an eye on the development of the core zed repo, but right now my understanding is there is not a sure fire way to send text to the integrated terminal (although I would love to be wrong!).

ocsmit avatar Jul 17 '24 15:07 ocsmit

Actually, there is preliminary support for inline code execution through a Jupyter kernel with the REPL feature (https://github.com/ocsmit/zed-r/issues/1#issuecomment-2231811820). Just tested with the ark kernel and Zed Preview and works well! Thanks @rgbkrk for bringing to my attention!

For reference this what it looks like in the zed settings to enable. The Ark R-kernel will need to be installed following the instructions on their git page.

  "jupyter": {
    "enabled": true,
    "kernels": {
      "R": "ark"
    }
  }

ocsmit avatar Jul 17 '24 15:07 ocsmit

Awesome! I've got some more fixes coming in for the REPL feature, keep the feedback coming with new issues!

rgbkrk avatar Jul 17 '24 20:07 rgbkrk

@rgbkrk Just had a play with the repl using ark and there is a lot to like! Where is the best place to submit issues on this - in the /zed-industries/extensions repo or elsewhere? Thanks!

h-a-graham avatar Jul 18 '24 09:07 h-a-graham

Hooray! Please report them to zed-industries/zed. There are some known things we will be unable to do (for now), which you can see in the two tracking issues covering Jupyter + Zed:

  • https://github.com/zed-industries/zed/issues/9778
  • https://github.com/zed-industries/zed/issues/13942

rgbkrk avatar Jul 18 '24 17:07 rgbkrk

I’d like to bring to your attention two minor issues I encountered while working with Zed and R. Since I’m not entirely certain about the nature of the problem, I believe this thread is an appropriate forum to discuss it and gather more information.

  1. I get auto-completion suggestions when writing comments, which can be a bit annoying, as I constantly have to press escape and pay attention to what is being emitted in the editor. Is this an issue with the language server or something within Zed itself? Note that I don't have this behavior working with other LSP-enabled editors like VSCode or Sublime using R's language server.

  2. The R kernel appears to be localized in German for some reason? My machine's locale is set to en_US.UTF-8, so is R. Here is the locale output from the built-in Zed terminal running R:

    > Rscript -e "Sys.getlocale()"
    [1] "en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8"
    

    and here the same from the R REPL within Zed

    # %%
    Sys.getlocale()
    [1] C/en_US.UTF-8/C/C/C/C
    

    I get the correct locale when running an R kernel from Positron (which also uses ark). Any ideas what the issue might be?

I'd be very happy to contribute a patch, and I'd appreciate any leads as to what I should be looking at.

tzakharko avatar Aug 08 '24 08:08 tzakharko

I get auto-completion suggestions when writing comments, which can be a bit annoying, as I constantly have to press escape and pay attention to what is being emitted in the editor.

That's either due to CoPilot/Supermaven (AI Completion) or the R extension https://github.com/ocsmit/zed-r.

rgbkrk avatar Aug 09 '24 00:08 rgbkrk