feat: add RStartHorizontal and RStartVertical mappings#501
feat: add RStartHorizontal and RStartVertical mappings#501guilhermegarcia wants to merge 1 commit intoR-nvim:mainfrom
Conversation
Add <Plug>RStartHorizontal (\rfh) and <Plug>RStartVertical (\rfv) mappings that let users start R with an explicit 50/50 split direction. The direction is passed cleanly as a function parameter through start_R -> start_R2 -> builtin.start -> split_window, with no config mutation. The existing \rf mapping and all config-based split logic remain unchanged.
|
Thank you for your pull request! However, we may not need it for the user case that you mentioned. This is part of my R.nvim config: ---@type RConfigUserOpts
local opts = {
-- Other options here...
}
if vim.o.columns > 200 then
opts.objbr_auto_start = true
opts.objbr_w = 60
opts.rconsole_height = 24
if vim.env.WEZTERM_PANE then
vim.env.RTERM = "external"
opts.external_term = "wezterm_split"
end
elseif vim.o.columns > 140 then
opts.objbr_auto_start = false
opts.objbr_w = 35
opts.rconsole_height = 20
else
opts.objbr_auto_start = false
opts.objbr_w = 25
opts.rconsole_height = 14
end
require("r").setup(opts)As you can see, I change not only how the window is split, but also whether I will run R in the built-in terminal buffer or in a WezTerm split pane, whether the Object Browser will start automatically or not, and the width/height of the Object Browser and R Console.
if (Sys.getenv("RTERM") == "external") {
options(
term_background = "#000000",
term_foreground = "#dddddd",
term_palette = c(
"#cc0403",
"#19cb00",
"#cecb00",
"#0d73cc",
"#cb1ed1",
"#0dcdcd",
"#dddddd",
"#767676",
"#f2201f"
),
term_col = TRUE,
device = terminalgraphics::tgp
)
} |
|
Your pull request also has changes to |
5f3e4da to
f2e1028
Compare
|
Good catch — the Regarding the config-time approach: my use case is a bit different — I work in a single terminal window and like to choose the split direction interactively each time I start R, depending on what I'm working on. Since That said, I understand if this is too niche for upstream. Happy to keep it in my fork if it doesn't fit the project's direction. |
ed2fa26 to
f2e1028
Compare
This is a different use case... Let's wait for comments from @PMassicotte (and, possibly, other developers). |
|
I am trying to use this PR.
|
|
Thanks for testing @PMassicotte! Regarding issue 2 (both producing vertical): that's unexpected — it works correctly on my end. What's your My suspicion is that |
|
I am not sure about the delay in @jalvesaq what do you think? |
|
The delay after typing I'll try the changed code... |
|
It works with @guilhermegarcia, I know that this means spending your time implementing features that you will never use, but, as a public project, we need to keep it internally consistent. This is why I usually resist adding support for specific R packages or accepting pull requests that implement features that I don't believe will be widely used. An alternative to implementing this feature is creating a custom key map in your Neovim config that would sequentially run |
|
Thanks for the thoughtful review @jalvesaq. Implementing this across all terminal backends makes sense for consistency, but it's beyond what I can reasonably test on my end. I'll keep this in my fork for personal use. Thanks @PMassicotte for testing as well! |


Summary
<Plug>RStartHorizontal(\rfh) and<Plug>RStartVertical(\rfv) mappings that let users start R with an explicit 50/50 split directionstart_R→start_R2→builtin.start→split_window, with no config mutation\rfmapping and all config-based split logic remain unchangedMotivation
Currently, the R console split direction is determined statically at config time via
rconsole_widthandrconsole_height. Users who switch between wide monitors (prefer vertical) and laptops (prefer horizontal) must change their config manually. These mappings let users choose the split direction at start time.Design decisions
math.floor(vim.o.columns / 2)for vertical,math.floor(vim.o.lines / 2)for horizontal. User can resize manually afterwards.\rfprefix is extended —\rfhand\rfvbuild on the existing\rfprefix. With which-key or similar plugins, pressing\rfwill show a menu with the available options (\rffor default,\rfhfor horizontal,\rfvfor vertical). Without such plugins,\rfstill fires aftertimeoutlen.\rfh, the console reopens horizontally.splitparameter only applies to the built-in terminal path; external terminals ignore it.Test plan
\rfv→ R console should appear in a vertical 50/50 split\rfh→ R console should reopen horizontally at 50/50\rf(wait for timeout) → original config-based split logic still worksuser_maps_only = true→ default keys disabled but<Plug>RStartHorizontal/<Plug>RStartVerticalstill available