jalvesaq / Nvim-R

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

Large objects don't seem to be able to fill secondary lists with completions (<C-n><C-o>) #794

Closed shaman-yellow closed 10 months ago

shaman-yellow commented 10 months ago

Large objects don't seem to be able to fill secondary lists with completions (). I know that this seems to involve recursively summarizing the information of all secondary lists. If the data is too large, it seems to be terminated. But I wonder, is there a more lightweight completion method, for example, only completing the next level of information instead of recursively searching for all deep information? I just need it to be as lightweight as normal 'tab' completion (like in the R command line) without the 'summary' content.

jalvesaq commented 10 months ago

The issue can be replicated with this code:

l0 <- list(l1 = list(l2 = list(l3 = list(l4 = list(l5 = list(l6 = list(l7 = list(l8 = 8))))))))

The variable maxdepth in R/nvimcom/src/nvimcom.c defines how many levels in a list will be parsed for creating the completion data. The initial value is 6, but it should increase when the time to build the completion data is not too high.

Could you try the maxdepth branch, please?

shaman-yellow commented 10 months ago

Thank you very much for your prompt reply! I tried checkout to the 'maxdepth' branch you mentioned, but I don't know what is different this branch. The problem I want to solve is actually: I have an S4 object with many data slots, and there is a lot of data in each slot; I want to use completion to help me fill in the name, instead of manually entering those complicated and lengthy names; However, the completion of <c-n><c-o> does not work here. I guess the S4 object data is too large. In fact, I want to try modifying the 'maxdepth' parameter you mentioned in 'nvimcom.c' (for example, if value 6 set as 1, what changes? Can the above S4 object be successfully completed?) , Unfortunately, I lack basic knowledge of C language, and I don't even know how to compile after modifying this parameter. I hope you can give me some more help, thank you!

jalvesaq commented 10 months ago

How did you install Nvim-R? If using a plugin manager, you can configure it to use the maxdepth branch. Example for lazy.nvim in init.lua:

require("lazy").setup({
  {'jalvesaq/Nvim-R', branch = 'maxdepth', lazy = false}
}, { })

If you make changes in R/nvimcom/src/nvimcom.c, you should remove the nvimcom package to force its reinstallation by Nvim-R:

echo 'remove.packages("nvimcom")' | R

Note: most people prefer to get automatic completion than to trigger completion manually. See: cmp-nvim-r.

shaman-yellow commented 10 months ago

I've tried installing maxdepth, but that didn't change anything, and Nvim-R still didn't help me complete it successfully. I also tried modifying maxdepth and then reinstalling Nvim-R as you suggested, with also frustrating results. I may not have made it clear, but I am a vim8 user. I tried using neovim for the past two days, eh, but it didn't change anything. (Not all completions are invalid, just certain objects cannot be triggered).

Another problem, I found that vim8 using the latest version of Nvim-R sometimes takes an unusually long time, even just sending the simplest command: x <- 1. I don't know why this is, so I took the evasive action: use Nvim-R v0.9.17

jalvesaq commented 10 months ago

The long time to send code to R is because there is another key binding that starts with the same key as the one you use to send lines to R. For example, if you use \d to send lines to R and \da to something else when you type \d, Vim will wait 'timeoutlen' for the key a. The command :nmap will show all the current key bindings, and you can use the information to change some of them to avoid conflict between them.

Note: omni completion is done with <c-x><c-o>, not <c-n><c-o>.

The omni completion is working in Vim too.

If you were to change the value of maxdepth manually, you should increase its value, not decrease it. Anyway, I will merge the changes onto the master branch and delete the maxdepth branch. So, you can just try the master branch.