"styler" fails to format R/Rmd files
Neovim version (nvim -v)
0.10.0
Operating system/version
ubuntu22.04
Add the debug logs
- [X] I have set
log_level = vim.log.levels.DEBUGand pasted the log contents below.
Log file
Log file: /home/thomas/.local/state/nvim/conform.log
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
18:47:53[ERROR] Formatter 'styler' error: Error in loadNamespace(x) : there is no package called ‘r.nvim’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
18:48:00[ERROR] Formatter 'styler' error: Error in loadNamespace(x) : there is no package called ‘r.nvim’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
18:54:23[WARN] Formatter 'styler' timeout
18:54:46[WARN] Formatter 'styler' timeout
18:54:59[WARN] Formatter 'styler' timeout
18:55:11[WARN] Formatter 'styler' timeout
18:56:08[WARN] Formatter 'styler' timeout
18:56:14[WARN] Formatter 'styler' timeout
18:57:20[WARN] Formatter 'styler' timeout
19:16:09[WARN] Formatter 'styler' timeout
19:16:13[WARN] Formatter 'styler' timeout
19:16:31[WARN] Formatter 'styler' timeout
19:19:40[WARN] Formatter 'styler' timeout
Formatters for this buffer:
styler ready (rmd, r)
Other formatters:
beautysh ready (bash)
black ready (python)
clang-format unavailable: No config found
stylua ready (lua)
Describe the bug
Formatter "styler" fails to format the .r/.rmd file.
The package r.nvim has been installed as here, below is the validation:
What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
Below is my configuration:
{
"stevearc/conform.nvim",
opts = {},
config = function()
require("conform").setup {
formatters_by_ft = {
lua = { "stylua" },
-- Conform will run multiple formatters sequentially
python = { "black" },
cpp = { "clang-format" },
bash = { "beautysh" },
r = { "styler" },
rmd = { "styler" },
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_fallback = true,
},
}
end,
lazy = false,
},
Expected Behavior
The formatter can format the code/code chunk properly.
Minimal example file
My full configuration is here.
Additional context
Thanks very much.
Unfortunately I don't really understand how this formatter works, since it relies on another neovim plugin and isn't just a simple binary command. Maybe @JohnCoene can help debug?
The error originates from R because you are missing the r.nvim package, you need to install it with:
# install.packages("remotes")
remotes::install_github("devOpifex/r.nvim")
Hi. I did install the r.nvim package, as the screenshot shown in the Describe the bug session above.
The error is there is no package called ‘r.nvim’ so there is no such package installed in the environment where you are trying to run the formatter.
Are you running this within an renv environment? Make sure it is installed where your code.
If that does not fix the issue can you please share more about the environment you are running this in?