jalvesaq / Nvim-R

Vim plugin to work with R
GNU General Public License v2.0
968 stars 126 forks source link

Autocomplete with non-loaded library #788

Closed PMassicotte closed 9 months ago

PMassicotte commented 11 months ago

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 :: .

Peek 2023-12-21 07-17

Thank you

jalvesaq commented 11 months ago

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.

PMassicotte commented 11 months ago

Ok thank you!

PMassicotte commented 11 months ago

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

Peek 2023-12-22 09-13

jalvesaq commented 11 months ago

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:

  1. Build or update the cache data of all installed libraries on Nvim-R startup.
  2. In addition to the currently existing list of loaded libraries, create in nvimrserver a list of unloaded libraries.
  3. 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:

jalvesaq commented 9 months ago

This is an issue for our new R.vim when it's inaugurated...