Files
LazyVim/lua/lazyvim/plugins/extras/lang/r.lua
Ben Puryear 5339acacec feat(R): added new which-key group for new install feature (#4078)
## Description

<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

A new feature was added to `r.nvim` that added a new key bind. This pr
adds that key bind (and group in case more are added) to the current
which-key config.

(I also removed a comment that I made previously for increasing the
width of the which-key window to fit the longer keybind descriptions,
something that eventually was taken out of the previous PR long ago)

## Related Issue(s)

<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

None

## Screenshots

<!-- Add screenshots of the changes if applicable. -->

<img width="154" alt="Screenshot 2024-07-16 at 9 24 54 AM"
src="https://github.com/user-attachments/assets/70336846-cf42-458e-89f3-3e7cf1b94c3f">

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2024-07-16 18:34:51 +02:00

89 lines
2.6 KiB
Lua

return {
recommended = function()
return LazyVim.extras.wants({
ft = "r",
root = { "*.R", "*.Rmd", "*qmd" },
})
end,
{
"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,
},
{
"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,
},
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "r", "rnoweb" } },
},
{
"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,
},
},
},
},
{
"nvim-neotest/neotest",
optional = true,
dependencies = {
"shunsambongi/neotest-testthat",
},
opts = {
adapters = {
["neotest-testthat"] = {},
},
},
},
}