diff --git a/lua/lazyvim/plugins/extras/lang/r.lua b/lua/lazyvim/plugins/extras/lang/r.lua index a57ce011..37b600d4 100644 --- a/lua/lazyvim/plugins/extras/lang/r.lua +++ b/lua/lazyvim/plugins/extras/lang/r.lua @@ -16,16 +16,11 @@ return { -- 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.api.nvim_buf_set_keymap(0, "n", "", "RDSendLine", {}) - vim.api.nvim_buf_set_keymap(0, "v", "", "RSendSelection", {}) + vim.keymap.set("n", "", "RDSendLine", { buffer = true }) + vim.keymap.set("v", "", "RSendSelection", { buffer = true }) -- Increase the width of which-key to handle the longer r-nvim descriptions local wk = require("which-key") - wk.setup({ - layout = { - width = { min = 20, max = 100 }, -- min and max width of the columns - }, - }) -- Workaround from https://github.com/folke/which-key.nvim/issues/514#issuecomment-1987286901 wk.register({ [""] = { @@ -44,20 +39,15 @@ return { }) end, }, - pdfviewer = (function() - if vim.loop.os_uname().sysname:find("Windows", 1, true) then - return "open" -- according to @Aman9das on Github - elseif vim.loop.os_uname().sysname:find("Darwin", 1, true) then - return "open" - else - return "xdg-open" -- according to @Aman9das on Github - end - end)(), }, + config = function(_, opts) + require("r").setup(opts) + require("r.pdf.generic").open = vim.ui.open + end, }, { "hrsh7th/nvim-cmp", - dependencies = { "R-nvim/cmp-r" }, + optional = true, opts = function(_, opts) opts.sources = opts.sources or {} table.insert(opts.sources, { name = "cmp_r" })