Skip to content

Commit

Permalink
New option: auto_quit
Browse files Browse the repository at this point in the history
  • Loading branch information
jalvesaq committed Mar 17, 2024
1 parent c4b7e7c commit cf95861
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The complete list of options is in the documentation.

## Usage

Please read the plugin's [documentation](https://github.com/jamespeapen/Nvim-R/wiki) for instructions on [usage](https://github.com/jamespeapen/Nvim-R/wiki/Use).
Please read the plugin's [documentation](https://github.com/jamespeapen/Nvim-R/wiki) for instructions on usage. See also the output of `:RMapsDesc`.

## Transitioning from Nvim-R

Expand Down Expand Up @@ -129,6 +129,9 @@ There are two new commands:
There is one new command to send the above-piped chain of commands. Its
default key binding is `<LocalLeader>sc`.

There is a new option: `auto_quit` (only used if running R in an external
terminal emulator).

If you have [colorout] installed, and if you are not loading it in your
`~/.Rprofile`, it should be the development version. Reason: R.nvim calls the
function `colorout::isColorOut()` which unduly enables the colorizing of
Expand Down
10 changes: 10 additions & 0 deletions doc/R.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,16 @@ put in your config:
>lua
silent_term = true
<
When Neovim is closed, the R connection with Neovim is closed and cannot be
reestablished. Thus, unless you usually keep working on the R Console after
quitting Neovim, you will prefer that R quits automatically when you leave
Neovim. In this case, you have to put in your config:
>lua
auto_quit = true
<
This option is valid only when running R in an external terminal, and will
always be set to `false` otherwise.


------------------------------------------------------------------------------
6.4. Windows specific options *save_win_pos*
Expand Down
5 changes: 5 additions & 0 deletions lua/r/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local config = {
assign_map = "<M-->",
auto_scroll = true,
auto_start = "no",
auto_quit = false,
bracketed_paste = false,
buffer_opts = "winfixwidth winfixheight nobuflisted",
clear_console = true,
Expand Down Expand Up @@ -834,6 +835,10 @@ M.check_health = function()
warn("R_cmd executable not found: '" .. config.R_cmd .. "'")
end

if type(config.external_term) == "boolean" and config.external_term == false then
config.auto_quit = false
end

if vim.fn.has("nvim-0.9.5") ~= 1 then warn("R.nvim requires Neovim >= 0.9.5") end
end

Expand Down
3 changes: 3 additions & 0 deletions lua/r/edit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ M.add_for_deletion = function(fname)
end

M.vim_leave = function()
if vim.g.R_Nvim_status == 7 and config.auto_quit then
require("r.run").quit_R("nosave")
end
require("r.job").stop_rns()

for _, fn in pairs(del_list) do
Expand Down

0 comments on commit cf95861

Please sign in to comment.