Closed typhooncamel closed 2 months ago
I can not replicate this. You open a second script using :e myscript.R
>
Yes. I should point out I'm using tmux (as opposed to the neovim terminal) to run R in.
I can replicate the issue but in my case, the problem is that my key bindings for sending line and selection are defined only once and, consequently, don't get applied to other buffers opened later.
after_config = function ()
if vim.o.syntax ~= "rbrowser" then
vim.api.nvim_buf_set_keymap(0, "n", "<Enter>", "<Plug>RDSendLine", {})
vim.api.nvim_buf_set_keymap(0, "v", "<Enter>", "<Plug>RSendSelection", {})
end
end,
This is a consequence of line https://github.com/R-nvim/R.nvim/blob/main/lua/r/config.lua#L797 changed in the commit https://github.com/R-nvim/R.nvim/commit/68fdead0306306fba8253b2741de0472ddefa9f4
But I still can use my key binding in the first buffer.
So, perhaps the hook after_config
should be renamed after_global_config
...
I have no idea whether this is related or a separate issue, but occasionally (but not consistently, and not sure how to reproduce), when I quite with <leader>rq
, I get an error that I never used to get:
*** caught segfault ***
address 0x5be816e39f14, cause 'memory not mapped'
Possible actions:
1. abort (with core dump, if enabled)
2. normal R exit
3. exit R without saving workspace
4. exit R saving workspace
Since we can't replicate the issue, please, see https://github.com/R-nvim/R.nvim/wiki/Debugging-C-code-with-Valgrind
Following the Wiki instructions, you will find what line of C code (from nvimcom
or another R package) tries to access unmapped memory.
Thank you. I'll try it, although it might take a few days to get to it. I've noticed that this problem is probably unrelated, and seems to happen systematically when I load package GWmodel
, which in turn loads robustbase
, sp
, and Rcpp
. So just doing library('GWmodel')
and then trying to quit the R session leads to the above error every time (and not when loading a number of other packages).
I still can't replicate the bug. I installed GWmodel
, did library("GWmodel")
, and then <LocalLeader>rq
with R running in an external terminal emulator, and R quitted normally.
I think it's clearly my problem, not R.nvim's. Trying to reinstall the package leads to errors and problems. Sorry for the confusion.
About the original problem on bindings working in multiple buffers, is there anything I should change on my end, or does it require a fix?
The problem that I could confirm is a little different from what you have described, and it requires a new hook function that would be called on the FileType
event. It would be the same result if the user created an auto command, but more convenient because we support five file types (R, Rmd, Quarto, Rnoweb, and RHelp). So, instead of creating five auto commands, it would be enough to set one hook function.
I added a new hook option that fixes the bug described in my last comment.
That fixed it, thanks!
Whenever I start an R session (
<leader>rf
) from a script (say, script 1), open another script (script 2) in the same terminal, and try to send code to the R session, nothing happens. After that, even going back to script 1 I can no longer send code to the R session. Incidentally, from both scripts I can quit the R session (<leader>rq
). The only solution then is to close all scripts, and reopen them.