r.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. return {
  2. {
  3. "R-nvim/R.nvim",
  4. -- Only required if you also set defaults.lazy = true
  5. lazy = false,
  6. -- R.nvim is still young and we may make some breaking changes from time
  7. -- to time (but also bug fixes all the time). If configuration stability
  8. -- is a high priority for you, pin to the latest minor version, but unpin
  9. -- it and try the latest version before reporting an issue:
  10. -- version = "~0.1.0"
  11. config = function()
  12. -- Create a table with the options to be passed to setup()
  13. ---@type RConfigUserOpts
  14. local opts = {
  15. hook = {
  16. on_filetype = function()
  17. vim.api.nvim_buf_set_keymap(0, "n", "<Enter>", "<Plug>RDSendLine", {})
  18. vim.api.nvim_buf_set_keymap(0, "v", "<Enter>", "<Plug>RSendSelection", {})
  19. end,
  20. },
  21. R_args = { "--quiet", "--no-save" },
  22. min_editor_width = 72,
  23. rconsole_width = 78,
  24. objbr_mappings = { -- Object browser keymap
  25. c = "class", -- Call R functions
  26. ["<localleader>gg"] = "head({object}, n = 15)", -- Use {object} notation to write arbitrary R code.
  27. v = function()
  28. -- Run lua functions
  29. require("r.browser").toggle_view()
  30. end,
  31. },
  32. disable_cmds = {
  33. "RClearConsole",
  34. "RCustomStart",
  35. "RSPlot",
  36. "RSaveClose",
  37. },
  38. }
  39. -- Check if the environment variable "R_AUTO_START" exists.
  40. -- If using fish shell, you could put in your config.fish:
  41. -- alias r "R_AUTO_START=true nvim"
  42. if vim.env.R_AUTO_START == "true" then
  43. opts.auto_start = "on startup"
  44. opts.objbr_auto_start = true
  45. end
  46. require("r").setup(opts)
  47. end,
  48. },
  49. }