It is tricky to provide completion without attaching to the R session being used by user. One simplified approach that I believe can serve most of the purposes is parse the currently editing document and find top-level source functions, and parse those files recursively.
For example, the following code is from several R scripts:
main.R:
library(data.table)
library(glmnet)
source("my_plot.R")
source("data/utils.R")
my_plot.R:
data/utils.R:
library(DBI)
requireNamespace("RMariaDB")
When main.R is being edited, those library expressions are captured. If those source expressions are captured and my_plot.R and data/utils.R are analyzed, where library and source expressions in these files are also captured, the completion will be much better and no less accurate, especially when #19 is implemented.
Also those top-level library(), require(), loadNamespace(), requireNamespace() calls can be used to provide diagnostics when required package is not installed.
It is tricky to provide completion without attaching to the R session being used by user. One simplified approach that I believe can serve most of the purposes is parse the currently editing document and find top-level
sourcefunctions, and parse those files recursively.For example, the following code is from several R scripts:
main.R:my_plot.R:library(ggplot2)data/utils.R:When
main.Ris being edited, thoselibraryexpressions are captured. If thosesourceexpressions are captured andmy_plot.Randdata/utils.Rare analyzed, wherelibraryandsourceexpressions in these files are also captured, the completion will be much better and no less accurate, especially when #19 is implemented.Also those top-level
library(),require(),loadNamespace(),requireNamespace()calls can be used to provide diagnostics when required package is not installed.