-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not get arguments completion use devtools::load_all
of functions which are not export in NAMESPACE
#147
Comments
The completion data includes only functions from libraries listed by the Line 816 in dc4eb50
I don't use |
But |
I don't know. Could you describe simple steps that I could copy and paste to see what happens? Anyway, I will not have free time in the next few days. |
Just a random idea: if you have installed your package in the past as a normal library, Nvim-R might have built the necessary cache files at |
We can use usethis::create_package("~/ATestPackage")
writeLines("ATestFun <- function(x) {\n print('Test this') \n}", "~/ATestPackage/R/test.R")
list.files("~/ATestPackage/", recursive = T)
# [1] "DESCRIPTION" "NAMESPACE" "R/test.R"
# The `NAMESPACE` is empty
readLines("~/ATestPackage/NAMESPACE")
# [1] "# Generated by roxygen2: do not edit by hand"
# [2] ""
# Now we load it
devtools::load_all("~/ATestPackage")
# The `ATestPackage` exists in `search()` results
search()[grep("ATestPackage", search())]
# [1] "package:ATestPackage"
# we can directly call it without prefix `ATestPackage::`
ATestFun()
# [1] "Test this" However, I can't get completion with Next we try to build a complete package. writeLines(
c("#' This is title for R help of this function",
"#' ",
"#' This is description.",
"#' ",
"#' @param x this is a test parameter",
"#' @export",
"ATestFun <- function(x) {\n print('Test this') \n}"),
"~/ATestPackage/R/test.R")
roxygen2::roxygenize("~/ATestPackage")
devtools::load_all("~/ATestPackage")
# It still can't get completion
devtools::install_local("~/ATestPackage")
library(ATestPackage)
# Oh, It still can't get completion
ATestFun() |
If we start a new R, without executing library(ATestPackage)
# completion work fine
ATestFun() |
With |
It seems that the package is not available yet when R.nvim tries to build its completion data. |
|
Note: I tested Nvim-R in Vim (9.1.377) and R.nvim in Neovim (0.11.0-dev). |
With the "complete" package, there is an attempt of completion right after
Perhaps you don't see the warning in Insert mode, but you can see it with the |
Strangely, my
|
Trying again... It only worked because I have installed the package from the terminal: R CMD INSTALL ~/ATestPackage It doesn't work if I use devtools. |
R.nvim runs an external R instance to build the completion data. So, the package must be installed as a normal package to be found. |
If this is not available in |
This seems to work: devtools::install_local("~/ATestPackage")
library(ATestPackage) I removed the package from R, and manually removed its files from |
I can't understand why Nvim-R works with Neovim (I tested it only with Vim and it doesn't work) because since 2021 the cache files are built by another R instance run by the |
Do you mean that starting a new R example will load the same packages in that example using |
Is it possible that it has something to do with other vim plugins, like if (0)
let g:use_old_nvim_r = 0
Plug 'R-nvim/R.nvim', {'do': ':TSUpdate'}
Plug 'R-nvim/cmp-r'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
else
let g:use_old_nvim_r = 1
Plug 'jalvesaq/Nvim-R'
Plug 'jalvesaq/cmp-nvim-r'
endif |
Packages loaded using However, if you install a package (with either |
This may not be a issue, but is a different feature from Nvim-R.
devtools::load_all
has parameter ofexport_all
, theoretically the functions were exported, but I can't get argument completion unless I specify inNAMESPACE
that the function is exported.For me, since my package may not be shared with others, I will not specifically indicate in NAMESPACE that the function needs to be exported.
devtools::load_all
makes all these functions exported. This is very convenient.The text was updated successfully, but these errors were encountered: