jalvesaq / Nvim-R

Vim plugin to work with R
GNU General Public License v2.0
968 stars 125 forks source link

Setting options to custom key bindings #731

Closed iago-pssjd closed 1 year ago

iago-pssjd commented 1 year ago

Hi,

Let's say I want to open R console splitting window vertically, but without modifying default options as suggested in section 6.14 (Control of R window) of documentation.

Is there some way, for example, setting some option to :call StartR("R")?

jalvesaq commented 1 year ago

The function StartR() receives only one argument. If it is "custom", then Nvim-R will ask for arguments to be passed to R. If it is anything else, it will start R with the arguments listed in R_args. But (Neo)Vim allows you to map a shortcut to a list of commands concatenated by pipes. Example:

nmap <F5> :let xx = 10 | let oldXX = xx | let xx = 20 | echo xx | let xx = oldXX<CR>

For init.lua:

vim.keymap.set('n', '<F5>', ':let xx = 10 | let oldXX = xx | let xx = 20 | echo xx | let xx = oldXX<CR>')
iago-pssjd commented 1 year ago

And in that way could I make that, when I start R with :call StartR("R") , the window split being vertical?

jalvesaq commented 1 year ago

You could try (replace 57 and 18 with values appropriate to your case):

nmap <F5> :let R_rconsole_width = 57 | let R_min_editor_width = 18 | call StartR("R") | let R_rconsole_width = 80 | let R_min_editor_width = 80
iago-pssjd commented 1 year ago

Thanks, so simplifying, the way would be, for example:

:let R_rconsole_width = 1 | call StartR("R")

(or any non-zero small number instead of 1). As it works, I close the issue.