R
info
You can enable the extra with the :LazyExtras
command.
Plugins marked as optional will only be configured if they are installed.
Alternatively, you can add it to your lazy.nvim
imports
lua/config/lazy.lua
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.r" },
{ import = "plugins" },
},
})
Below you can find a list of included plugins and their default settings.
caution
You don't need to copy the default settings to your config. They are only shown here for reference.
R.nvim
- Options
- Full Spec
opts = {
-- Create a table with the options to be passed to setup()
R_args = { "--quiet", "--no-save" },
hook = {
on_filetype = function()
-- This function will be called at the FileType event
-- of files supported by R.nvim. This is an
-- opportunity to create mappings local to buffers.
vim.keymap.set("n", "<Enter>", "<Plug>RDSendLine", { buffer = true })
vim.keymap.set("v", "<Enter>", "<Plug>RSendSelection", { buffer = true })
local wk = require("which-key")
wk.add({
buffer = true,
{ "<localleader>a", group = "all" },
{ "<localleader>b", group = "between marks" },
{ "<localleader>c", group = "chunks" },
{ "<localleader>f", group = "functions" },
{ "<localleader>g", group = "goto" },
{ "<localleader>i", group = "install" },
{ "<localleader>k", group = "knit" },
{ "<localleader>p", group = "paragraph" },
{ "<localleader>q", group = "quarto" },
{ "<localleader>r", group = "r general" },
{ "<localleader>s", group = "split or send" },
{ "<localleader>t", group = "terminal" },
{ "<localleader>v", group = "view" },
})
end,
},
pdfviewer = "",
}
{
"R-nvim/R.nvim",
lazy = false,
opts = {
-- Create a table with the options to be passed to setup()
R_args = { "--quiet", "--no-save" },
hook = {
on_filetype = function()
-- This function will be called at the FileType event
-- of files supported by R.nvim. This is an
-- opportunity to create mappings local to buffers.
vim.keymap.set("n", "<Enter>", "<Plug>RDSendLine", { buffer = true })
vim.keymap.set("v", "<Enter>", "<Plug>RSendSelection", { buffer = true })
local wk = require("which-key")
wk.add({
buffer = true,
{ "<localleader>a", group = "all" },
{ "<localleader>b", group = "between marks" },
{ "<localleader>c", group = "chunks" },
{ "<localleader>f", group = "functions" },
{ "<localleader>g", group = "goto" },
{ "<localleader>i", group = "install" },
{ "<localleader>k", group = "knit" },
{ "<localleader>p", group = "paragraph" },
{ "<localleader>q", group = "quarto" },
{ "<localleader>r", group = "r general" },
{ "<localleader>s", group = "split or send" },
{ "<localleader>t", group = "terminal" },
{ "<localleader>v", group = "view" },
})
end,
},
pdfviewer = "",
},
config = function(_, opts)
vim.g.rout_follow_colorscheme = true
require("r").setup(opts)
require("r.pdf.generic").open = vim.ui.open
end,
}
cmp-r
- Options
- Full Spec
opts = nil
{ "R-nvim/cmp-r" }
nvim-treesitter
- Options
- Full Spec
opts = { ensure_installed = { "r", "rnoweb" } }
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "r", "rnoweb" } },
}
nvim-lspconfig
- Options
- Full Spec
opts = {
servers = {
r_language_server = {
root_dir = function(fname)
return require("lspconfig.util").root_pattern("DESCRIPTION", "NAMESPACE", ".Rbuildignore")(fname)
or require("lspconfig.util").find_git_ancestor(fname)
or vim.loop.os_homedir()
end,
},
},
}
{
"neovim/nvim-lspconfig",
opts = {
servers = {
r_language_server = {
root_dir = function(fname)
return require("lspconfig.util").root_pattern("DESCRIPTION", "NAMESPACE", ".Rbuildignore")(fname)
or require("lspconfig.util").find_git_ancestor(fname)
or vim.loop.os_homedir()
end,
},
},
},
}
neotest-testthat
- Options
- Full Spec
opts = nil
{
"shunsambongi/neotest-testthat",
}
nvim-cmp (optional)
- Options
- Full Spec
opts = function(_, opts)
opts.sources = opts.sources or {}
table.insert(opts.sources, { name = "cmp_r" })
end
{
"hrsh7th/nvim-cmp",
optional = true,
dependencies = { "R-nvim/cmp-r" },
opts = function(_, opts)
opts.sources = opts.sources or {}
table.insert(opts.sources, { name = "cmp_r" })
end,
}
neotest (optional)
- Options
- Full Spec
opts = {
adapters = {
["neotest-testthat"] = {},
},
}
{
"nvim-neotest/neotest",
optional = true,
dependencies = {
"shunsambongi/neotest-testthat",
},
opts = {
adapters = {
["neotest-testthat"] = {},
},
},
}