REditorSupport / vscode-R

R Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=REditorSupport.r
MIT License
1.06k stars 125 forks source link

Ikuyadeu.r formatter is #862

Closed Yemoloh closed 1 year ago

Yemoloh commented 2 years ago

Hi, I've installed R on VScode, but when I try to format my code, I have this message : "There is no formatter for 'r' files installed" This is my settings.json

{ "tabnine.experimentalAutoImports": true, "workbench.colorTheme": "Cobalt2", "r.alwaysUseActiveTerminal": true, "r.rpath.windows": "C:\Program Files\R\R-4.1.2\bin", "r.rterm.windows": "C:\Program Files\R\R-4.1.2\bin\R.exe", "files.associations": { "*.rmd": "markdown" }, "r.dependencyChecks": true, "editor.formatOnPaste": true, "editor.formatOnType": true, "r.lsp.debug": true, "[r]": { "editor.defaultFormatter": "Ikuyadeu.r" }, }

Does anybody had this issue before ?

Yemoloh

To Reproduce Steps to reproduce the behavior:

  1. Install languageserver
  2. Install r.extension
  3. Add : "[r]": { "editor.defaultFormatter": "Ikuyadeu.r" }, in settings.json
  4. Open an r.file, type unformatted code and hit shift+alt+f
renkun-ken commented 2 years ago

Looks like the R language client does not correctly start and thus not registered as a valid R formatter. Could you go to Output -> R Language Server and take a look at the log of language server. Does it start correctly?

robokamran commented 2 years ago

I have the same problem with pretty much the same configuration. how should I go to Output -> R Language Server ?? edit: I have installed the binaries by these commands: install.packages("httpgd") install.packages("languageserver") could that be the case?

renkun-ken commented 2 years ago

Go to the Output pane and choose "R Language Server" and view the log:

image
robokamran commented 2 years ago

Thank you for your quit reply. Here is my screenshot, the code runs correctly, but when I hit ALT+Shift+F I get that error. And the output looks like this:

Screenshot 2021-11-27 191819

Edit: my settings.json just in case:

{
  "editor.suggestSelection": "first",
  "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
  "workbench.iconTheme": "material-icon-theme",
  "C_Cpp.updateChannel": "Insiders",
  "cmake.configureOnOpen": true,
  "explorer.confirmDragAndDrop": false,
  "window.zoomLevel": 0,
  "editor.lineHeight": 0,
  "editor.fontSize": 13,
  "workbench.startupEditor": "none",
  "http.proxySupport": "off",
  "window.restoreWindows": "none",
  "stm32-for-vscode.openOCDPath": "D:\\PROGRAM FILES\\OPENOCD\\BIN\\OPENOCD.EXE",
  "stm32-for-vscode.makePath": "C:\\PROGRAM FILES (X86)\\GNUWIN32\\BIN\\MAKE.EXE",
  "stm32-for-vscode.armToolchainPath": "C:\\PROGRAM FILES (X86)\\GNU ARM EMBEDDED TOOLCHAIN\\9 2020-Q2-UPDATE\\BIN",
  "security.workspace.trust.banner": "never",
  "security.workspace.trust.enabled": false,
  "security.workspace.trust.untrustedFiles": "open",
  "r.bracketedPaste": true,
  "r.rpath.windows": "\"C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe\"",
  "r.rterm.windows": "C:\\Users\\Kamran\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\radian.exe"
}
renkun-ken commented 2 years ago

Looks like the language server does not start at all.

@ManuelHentschel Does the value of r.rpath.windows looks correct?

robokamran commented 2 years ago

I can use R.exe address for r.rpath.windows with/without the double quotations, or even remove the whole r.rpath.windows entry. The result is the same. The install address of my R executable instance is correct though. Also I when I install languageserver this is the output:

> install.packages("languageserver")
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cran.ism.ac.jp/bin/windows/contrib/4.1/languageserver_0.3.12.zip'
Content type 'application/zip' length 808148 bytes (789 KB)
downloaded 789 KB

package 'languageserver' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
        C:\Users\Kamran\AppData\Local\Temp\RtmpqmtkCP\downloaded_packages
>
ManuelHentschel commented 2 years ago

@ManuelHentschel Does the value of r.rpath.windows looks correct?

With the quotes, I get the same error, removing the quotes fixes the error for me.

robokamran commented 2 years ago

I removed the quotes and did multiple restarts. Still, there was no success. But I did this once in my R terminal and it was fixed: (Edit: with the quotes being omitted of course)

> library(languageserver)
> languageserver::run
function (debug = FALSE, host = "localhost", port = NULL)
{
    tools::Rd2txt_options(underline_titles = FALSE)
    tools::Rd2txt_options(itemBullet = "* ")
    lsp_settings$update_from_options()
    if (isTRUE(debug)) {
        lsp_settings$set("debug", TRUE)
        lsp_settings$set("log_file", NULL)
    }
    else if (is.character(debug)) {
        lsp_settings$set("debug", TRUE)
        lsp_settings$set("log_file", debug)
    }
    langserver <- LanguageServer$new(host, port)
    langserver$run()
}
<bytecode: 0x000000001da7bbc0>
<environment: namespace:languageserver>
>
renkun-ken commented 2 years ago

Would you like to confirm that you are using the following setting:

"r.rpath.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe"

but the language server still cannot start like

R Language Server (undefined) started
robokamran commented 2 years ago

Yes, it was like that. With the following setting: "r.rpath.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe" I also got this error: R Language Server (undefined) started But I ran these commands in my R terminal and the problem was fixed (I ran the commands only one time and it was fixed):

> library(languageserver)
> languageserver::run

My current config (which is working) is still like this: "r.rpath.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe"

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 365 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.

yxb-cn commented 1 year ago

I wonder if this problem is solved? I meet the same error.

robokamran commented 1 year ago

Yes, the issue was solved for me using the procedure I mentioned. However, I've not been using R for months. So I hope the same procedure still works with the newer updates.

hhilbig commented 3 months ago

In case someone still has this issue: language server also did not start for me, as discussed earlier. I got "R Language Server (-1) started". It turned out that r.rpath.mac was pointing to an older R version in my library (4.3). I changed r.rpath.mac to the most recent R version (4.4), which fixed the issue.