Nvim-R
Nvim-R copied to clipboard
Autocomplete with non-loaded library
I often use helper functions, like janitor::clean_names(), when processing data. I have looked in the documentation and I could not find if it was possible to trigger autocomplete from non-loaded library using :: .
Thank you
Currently, it's not possible to autocomplete the names of objects from non-loaded libraries because nvimrserver only loads from Nvim-R's cache directory data from loaded libraries. Moreover, Nvim-R only builds the cache files when a library is loaded.
Ok thank you!
Just noticed that it works if R is closed and if I am using this:
vim.g.R_start_libs = 'base,stats,graphics,grDevices,utils,methods,janitor'
However, it stops working when R starts
Yes, this is documented in section 6.3. of doc/Nvim-R.txt (Omnicompletion and syntax highlighting). It will even work for libraries that were never loaded because their data will be cached at Nvim-R initialization.
The implementation of what you requested when opened the issue is:
- Build or update the cache data of all installed libraries on Nvim-R startup.
- In addition to the currently existing list of loaded libraries, create in
nvimrservera list of unloaded libraries. - When the completion of the kind
package::is required, load the library data on the list of unloaded libraries and do the completion from this data.
Notes:
- Because caching the data of all installed libraries is going to be slow, it should happen asynchronously.
- It would be necessary some kind of lock file to prevent
nvimrserverfrom loading incomplete data. - If a library's data is not cached yet when the completion is requested, the completion should simply fail (silently?).
- Lock files are problematic because they will linger around if the R process creating them is killed before finishing its job (for example, if you reboot the computer). That's why I prefer to build the chance data synchronously.
This is an issue for our new R.vim when it's inaugurated...