Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ firm commitment to backwards compatibility.
- `R_source` and `after_R_start` have been replaced with more powerful `hook`
options.

- When running R in the Neovim built-in terminal or in a WezTerm split pane,
the `R.nvim` config option `rconsole_pos` should be used to define the
position of the R Console. The Vim options 'splitright' and 'splitbelow' are
ignored.

- `nvimpager`, which controls how R documentation is displayed, now has
possible options `"split_h"`, `"split_v"`, `"tab"`, `"float"` (not
implemented yet), and `"no"`.
Expand Down
11 changes: 8 additions & 3 deletions doc/R.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ You may close the window opened by `:RConfigShow` by simply pressing `q`.
|config_tmux| Don't use a specially built Tmux config file
|rconsole_height| Number of lines of R Console
|rconsole_width| Number of columns of R Console
|register_treesitter| Register treesitter parsers for quarto and rmd files
|rconsole_pos| Position of the R Console relative to the editor window

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be added in 6.14? Along with

rconsole_height
rconsole_width
rconsole_pos
min_editor_width

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add it...

|min_editor_width| Minimum number of columns of editor after R start
|RStudio_cmd| Run RStudio instead of R.
|listmethods| Do `nvim.list.args()` instead of `args()`
Expand All @@ -1001,6 +1001,7 @@ You may close the window opened by `:RConfigShow` by simply pressing `q`.
|open_html| Open HTML after processing Rmd or Quarto
|insert_mode_cmds| Allow R commands in insert mode
|rmhidden| Remove hidden objects from R workspace
|register_treesitter| Register treesitter parsers for quarto and rmd files
|set_params| Control setting `params` in `.GlobalEnv`
|wait| Time to wait for nvimcom loading
|wait_reply| Time to wait for R reply
Expand Down Expand Up @@ -1842,6 +1843,7 @@ file (~/.tmux.conf).
------------------------------------------------------------------------------
6.14. Control of R window *rconsole_height*
*rconsole_width*
*rconsole_pos*
*min_editor_width*

When starting R, Neovim's buffer is split vertically if its width is larger
Expand All @@ -1867,8 +1869,11 @@ For a horizontal split, you can set the number of lines of the R window:
>lua
rconsole_height = 15
<
You should set 'nosplitright' if you wanted the R Console on the left side,
and 'nosplitbelow' if you wanted it above the R script.
By default, in a vertical split, the R Console opens on the right of the
editor window; in a horizontal split, it opens below the editor window. You
can set the value of `rconsole_pos` to get the R Console in a different
position. Valid values are "below,right", "below,left", "above,right", and
"above,left".

Note: If running R in a Neovim buffer, the number of lines and columns will
automatically change if you switch between horizontal and vertical splits (see
Expand Down
4 changes: 4 additions & 0 deletions lua/r/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ local hooks = require("r.hooks")
---Do `:help rconsole_width` for more information.
---@field rconsole_width? integer
---
--- Position of the R Console relative to the editor window.
---@field rconsole_pos? '"below,right"' | '"below,left"' | "above,right" | '"above,left"'
---
---Whether to register the Markdown parser for Quarto and RMarkdown documents;
---defaults to `true`. Do `:help register_treesitter` for more information.
---@field register_treesitter? boolean
Expand Down Expand Up @@ -576,6 +579,7 @@ local config = {
roxygen_hl = false,
rconsole_height = 15,
rconsole_width = 80,
rconsole_pos = "below,right",
register_treesitter = true,
remote_compl_dir = "",
remote_R_host = "",
Expand Down
10 changes: 6 additions & 4 deletions lua/r/term/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,24 @@ local split_window = function()
local nw = vim.o.number and vim.o.numberwidth or 0
local sw = config.rconsole_width + config.min_editor_width + 1 + nw
if config.rconsole_width > 0 and vim.fn.winwidth(0) > sw then
local pos = config.rconsole_pos:find("left") and "aboveleft" or "belowright"
if
config.rconsole_width > 16
and config.rconsole_width < (vim.fn.winwidth(0) - 17)
then
vim.cmd("silent exe 'belowright " .. config.rconsole_width .. "vnew'")
vim.cmd("silent exe '" .. pos .. " " .. config.rconsole_width .. "vnew'")
else
vim.cmd("silent belowright vnew")
vim.cmd("silent " .. pos .. " vnew")
end
else
local pos = config.rconsole_pos:find("above") and "aboveleft" or "belowright"
if
config.rconsole_height > 0
and config.rconsole_height < (vim.fn.winheight(0) - 1)
then
vim.cmd("silent exe 'belowright " .. config.rconsole_height .. "new'")
vim.cmd("silent exe '" .. pos .. " " .. config.rconsole_height .. "new'")
else
vim.cmd("silent belowright new")
vim.cmd("silent " .. pos .. " new")
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lua/r/term/wezterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ M.start = function()
}
else
ed_pane = vim.env.WEZTERM_PANE
local location = "--right"
local location = config.rconsole_pos:find("left") and "--left" or "--right"
local nw = vim.o.number and vim.o.numberwidth or 0
local swd = config.rconsole_width + config.min_editor_width + 1 + nw
if config.rconsole_width == 0 or (vim.fn.winwidth(0) < swd) then
location = "--bottom"
location = config.rconsole_pos:find("above") and "--top" or "--bottom"
end

local prcnt
if location == "--right" then
if location == "--right" or location == "--left" then
prcnt = vim.fn.round(100 * config.rconsole_width / vim.fn.winwidth(0))
else
prcnt = vim.fn.round(100 * config.rconsole_height / vim.fn.winheight(0))
Expand Down
Loading