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
18 changes: 11 additions & 7 deletions doc/R.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1332,18 +1332,22 @@ in the Lua table `compl_data` in your `R.nvim` config. Below are the default
values:
>lua
compl_data = {
max_list_len = 10000,
max_depth = 3,
max_size = 1000000,
max_time = 100,
},
<
You should increase the value of `max_depth` if you want to complete or see in
the Object Browser more than 3 list levels. You should increase either
`max_size` or `max_time` if `nvimcom` needs more space or more time to build
the completion data with the desired list depth. You should decrease the
values if you notice any delay when R is running commands. In this case,
please, put `options(nvimcom.verbose = 1)` in your `~/.Rprofile` and use the
information output by `nvimcom` to decide what parameter to change.
You should increase the value of `max_list_len` if you want to be able to open in
the Object Browser and do completion of list and S4 objects with more than
10000 elements. You should increase the value of `max_depth` if you want to
complete or see in the Object Browser more than 3 list levels. You should
increase either `max_size` or `max_time` if `nvimcom` needs more space or more
time to build the completion data with the desired list depth. You should
decrease the values if you notice any delay when R is running commands. In
this case, please, put `options(nvimcom.verbose = 1)` in your `~/.Rprofile`
and use the information output by `nvimcom` to decide what parameter to
change.

It is possible to add a custom keymap through `objbr_mappings` table. The
keymap defined in this table will be available in the object browser only.
Expand Down
3 changes: 2 additions & 1 deletion lua/r/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ local hooks = require("r.hooks")
---
---Options for fine-grained control of the object browser. Do `:help compl_data`
---for more information.
---@field compl_data? { max_depth: integer, max_size: integer, max_time: integer }
---@field compl_data? { max_list_len: integer, max_depth: integer, max_size: integer, max_time: integer }
---
---Options for the r_ls (R.nvim's built-in language server)
---@field r_ls? RLSConfigOpts
Expand Down Expand Up @@ -496,6 +496,7 @@ local config = {
convert_range_int = false,
compldir = "",
compl_data = {
max_list_len = 10000,
max_depth = 3,
max_size = 1000000,
max_time = 100,
Expand Down
3 changes: 3 additions & 0 deletions lua/r/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ start_R2 = function()
'Sys.setenv(RNVIM_ID= "' .. vim.env.RNVIM_ID .. '")',
'Sys.setenv(RNVIM_SECRET = "' .. vim.env.RNVIM_SECRET .. '")',
'Sys.setenv(RNVIM_PORT = "' .. vim.env.RNVIM_PORT .. '")',
"options(nvimcom.max_list_len = "
.. tostring(config.compl_data.max_list_len)
.. ")",
"options(nvimcom.max_depth = " .. tostring(config.compl_data.max_depth) .. ")",
"options(nvimcom.max_size = " .. tostring(config.compl_data.max_size) .. ")",
"options(nvimcom.max_time = " .. tostring(config.compl_data.max_time) .. ")",
Expand Down
4 changes: 2 additions & 2 deletions nvimcom/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: nvimcom
Version: 0.9.94
Date: 2026-04-27
Version: 0.9.95
Date: 2026-06-04
Title: Intermediate the Communication Between R and Neovim
Authors@R: c(
person("Jakson", "Aquino", email = "jalvesaq@gmail.com",
Expand Down
2 changes: 2 additions & 0 deletions nvimcom/R/nvimcom.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ NvimcomEnv$tcb <- FALSE
options(nvimcom.setwidth = TRUE)
options(nvimcom.debug_r = TRUE)
options(nvimcom.nvimpager = TRUE)
options(nvimcom.max_list_len = 10000)
options(nvimcom.max_depth = 12)
options(nvimcom.max_size = 1000000)
options(nvimcom.max_time = 100)
Expand Down Expand Up @@ -65,6 +66,7 @@ NvimcomEnv$tcb <- FALSE
as.integer(getOption("nvimcom.verbose")),
as.integer(getOption("nvimcom.allnames")),
as.integer(getOption("nvimcom.setwidth")),
as.integer(getOption("nvimcom.max_list_len")),
as.integer(getOption("nvimcom.max_depth")),
as.integer(getOption("nvimcom.max_size")),
as.integer(getOption("nvimcom.max_time")),
Expand Down
45 changes: 25 additions & 20 deletions nvimcom/src/nvimcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static double timelimit =
100.0; // Maximum acceptable time to build list of .GlobalEnv objects
static int sizelimit = 1000000; // Maximum acceptable size of string
// representing .GlobalEnv (list of objects)
static int maxlslen = 10000; // Maximum acceptable list length
static int maxdepth = 12; // How many levels to parse in lists and S4 objects
// when building list of objects for auto-completion. The value decreases if
// the listing is too slow.
Expand Down Expand Up @@ -609,7 +610,7 @@ static char *nvimcom_glbnv_line(SEXP *x, const char *xname, const char *curenv,

if (xgroup == 4 || xgroup == 7) {
snprintf(newenv, 575, "%s%s@", curenv, xname);
if (len > 0) {
if (len > 0 && len < maxlslen) {
for (int i = 0; i < len; i++) {
ename = CHAR(STRING_ELT(sn, i));
if (R_has_slot(*x, Rf_install(ename)) == 1) {
Expand All @@ -627,7 +628,7 @@ static char *nvimcom_glbnv_line(SEXP *x, const char *xname, const char *curenv,
len = length(listNames);
if (len == 0) { /* Empty list? */
int len1 = length(*x);
if (len1 > 0) { /* List without names */
if (len1 > 0 && len1 < maxlslen) { /* List without names */
len1 -= 1;
if (newenv[strlen(newenv) - 1] == '$')
newenv[strlen(newenv) - 1] = 0; // Delete trailing '$'
Expand All @@ -643,28 +644,31 @@ static char *nvimcom_glbnv_line(SEXP *x, const char *xname, const char *curenv,
UNPROTECT(1);
}
} else { /* Named list */
SEXP eexp;
len -= 1;
for (int i = 0; i < len; i++) {
PROTECT(eexp = STRING_ELT(listNames, i));
ename = CHAR(eexp);
UNPROTECT(1);
if (len < maxlslen) {
SEXP eexp;
len -= 1;
for (int i = 0; i < len; i++) {
PROTECT(eexp = STRING_ELT(listNames, i));
ename = CHAR(eexp);
UNPROTECT(1);
if (ename[0] == 0) {
snprintf(ebuf, 63, "[[%d]]", i + 1);
ename = ebuf;
}
PROTECT(elmt = VECTOR_ELT(*x, i));
p = nvimcom_glbnv_line(&elmt, ename, newenv, p,
depth + 1);
UNPROTECT(1);
}
ename = CHAR(STRING_ELT(listNames, len));
if (ename[0] == 0) {
snprintf(ebuf, 63, "[[%d]]", i + 1);
snprintf(ebuf, 63, "[[%d]]", len + 1);
ename = ebuf;
}
PROTECT(elmt = VECTOR_ELT(*x, i));
PROTECT(elmt = VECTOR_ELT(*x, len));
p = nvimcom_glbnv_line(&elmt, ename, newenv, p, depth + 1);
UNPROTECT(1);
}
ename = CHAR(STRING_ELT(listNames, len));
if (ename[0] == 0) {
snprintf(ebuf, 63, "[[%d]]", len + 1);
ename = ebuf;
}
PROTECT(elmt = VECTOR_ELT(*x, len));
p = nvimcom_glbnv_line(&elmt, ename, newenv, p, depth + 1);
UNPROTECT(1);
}
UNPROTECT(1); /* listNames */
}
Expand Down Expand Up @@ -1272,11 +1276,12 @@ static void *client_loop_thread(__attribute__((unused)) void *arg)
*
* @param rinfo Information on R to be passed to nvim.
*/
SEXP nvimcom_Start(SEXP vrb, SEXP anm, SEXP swd, SEXP imd, SEXP szl, SEXP tml,
SEXP dbg, SEXP nvv, SEXP rinfo) {
SEXP nvimcom_Start(SEXP vrb, SEXP anm, SEXP swd, SEXP lsl, SEXP imd, SEXP szl,
SEXP tml, SEXP dbg, SEXP nvv, SEXP rinfo) {
verbose = *INTEGER(vrb);
allnames = *INTEGER(anm);
setwidth = *INTEGER(swd);
maxlslen = *INTEGER(lsl);
maxdepth = *INTEGER(imd);
sizelimit = *INTEGER(szl);
timelimit = (double)*INTEGER(tml);
Expand Down
Loading