Reputation: 2452
Working on Windows 10, no Formatter for the R-Language seems to do its job in Visual Studio Code. I've tried R support for Visual Studio Code and R-Tools, which seem to be the most popular extensions out there.
I've also checked that the path to the R binary file is correct. Nevertheless, when I hit SHIFT + ALT + F
I get the "There is no formatter for 'r'-files installed."
message.
Moreover I tried to enable the Settings Editor: Format On Type
and Editor: Format On Save
, but without luck.
Haven't been able to find other posts about this problem online. Any ideas? Big thanks
Upvotes: 12
Views: 15108
Reputation: 11
After the merge of R LSP into the R extension for VSCode, add this line to vscode settings.json
:
"[r]": {
"editor.defaultFormatter": "REditorSupport.r"
},
Upvotes: 1
Reputation: 196
Installing R Language Server and R LSP Client should do what you want
Open R Studio and install languageserver, tying this in the console window:
install.packages("languageserver")
Install R LSP Client Extension in VS Code
Toggle Format on Type
, Format On Save
, and Format On Paste
settings in VS Code editor preferences, depending on your needs.
Update: 2023. The R LSP Client extension was merged into VSCode R. See the R LSP Client github.
Upvotes: 18
Reputation: 1
Adding to Ctrl-Zed answer, if you have VSCode R extension by Yuki Ueda, this worked for me:
"[r]": {
"editor.defaultFormatter": "Ikuyadeu.r"
},
Upvotes: 0
Reputation: 687
Answer works as per user3451039, but if you are using another formatter in editor.defaultFormatter
(such as Prettier), you may need to add the following to your settings.json in VSCode:
"[r]": {
"editor.defaultFormatter": "REditorSupport.r-lsp"
},
Upvotes: 8