Rework into opts, modify pdfviewer to be os dependent

This commit is contained in:
Ben Puryear 2024-05-23 12:31:10 -07:00
parent 4b68c4d164
commit 4f1b02ea02

View file

@ -7,9 +7,9 @@ return {
end, end,
{ {
"R-nvim/R.nvim", "R-nvim/R.nvim",
config = function() lazy = false,
opts = {
-- Create a table with the options to be passed to setup() -- Create a table with the options to be passed to setup()
local opts = {
R_args = { "--quiet", "--no-save" }, R_args = { "--quiet", "--no-save" },
hook = { hook = {
on_filetype = function() on_filetype = function()
@ -19,7 +19,7 @@ return {
vim.api.nvim_buf_set_keymap(0, "n", "<Enter>", "<Plug>RDSendLine", {}) vim.api.nvim_buf_set_keymap(0, "n", "<Enter>", "<Plug>RDSendLine", {})
vim.api.nvim_buf_set_keymap(0, "v", "<Enter>", "<Plug>RSendSelection", {}) vim.api.nvim_buf_set_keymap(0, "v", "<Enter>", "<Plug>RSendSelection", {})
-- Increase the width of which-key to handle the r-nvim descriptions -- Increase the width of which-key to handle the longer r-nvim descriptions
local wk = require("which-key") local wk = require("which-key")
wk.setup({ wk.setup({
layout = { layout = {
@ -44,27 +44,16 @@ return {
}) })
end, end,
}, },
min_editor_width = 72, pdfviewer = (function()
rconsole_width = 78, if vim.loop.os_uname().sysname:find("Windows", 1, true) then
disable_cmds = { return "open" -- according to @Aman9das on Github
"RClearConsole", elseif vim.loop.os_uname().sysname:find("Darwin", 1, true) then
"RCustomStart", return "open"
"RSPlot", else
"RSaveClose", return "xdg-open" -- according to @Aman9das on Github
},
synctex = false,
pdfviewer = "open",
}
-- Check if the environment variable "R_AUTO_START" exists.
-- If using fish shell, you could put in your config.fish:
-- alias r "R_AUTO_START=true nvim"
if vim.env.R_AUTO_START == "true" then
opts.auto_start = "on startup"
opts.objbr_auto_start = true
end end
require("r").setup(opts) end)(),
end, },
lazy = false,
}, },
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",