-
Notifications
You must be signed in to change notification settings - Fork 18
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
Paste vs bracketed paste vs source; echo vs silent. #23
Comments
I like the idea of |
It's a good idea, but I don't know how to implement it with
Yes, except if the number of lines is |
Actually, this could be done inside |
Should send functions work at the moment? I am trying to use the tmp-R-Nvim and I keep getting R is not ready yet, coming from this line
|
I was testing the external terminal, and introduced this bug for the built-in terminal. I will fix it in a couple of minutes. |
No rush :) |
I can't replicate the bug. |
Could you try this: echo 'remove.packages("nvimcom")' | R Maybe nvimcom needs to be rebuilt... |
WIll investigate and report back. |
Looks like it is coming from |
When an environment variable doesn't exist, the |
If indeed the problem was the environment variable being |
Super, working perfectly fine! |
The so We can fix that later when we decide what to do with the |
What is your opinion on this? I prefer to eliminate the "echo" parameter from the send functions because users can set the value of |
If you do |
Make total sens. I up to remove echo. |
Oh this is nice. Open a nanosecond after the terminal. Tx! |
So, please, feel free to remove the "echo" parameter if you have time. |
all right, will do it right now |
I uploaded some bug fixes in many files. So, please, do |
I'm implementing the option |
Great! The project is taking shape! |
I already tried most features, and they are working. One problem is some key bindings not being activated. When the same function is mapped twice, one with argument |
Meaning that -- Paragraph
create_maps("ni", "RSendParagraph", "pp", "<Cmd>lua require('r.send').paragraph(false)")
create_maps("ni", "RDSendParagraph", "pd", "<Cmd>lua require('r.send').paragraph(true)") Is only mapping the last one? |
Thanks for looking at that! I found the problem: it was my configuration! I was setting custom key bindings and they were preventing My default mapping to send lines of code to R, |
oh cool! |
My configuration now is (commented lines ommited): return {
dir = '~/src/tmp-R-Nvim',
config = {
R_args = {'--quiet', '--no-save'},
hook = {
after_config = function ()
vim.api.nvim_buf_set_keymap(0, "n", "<Enter>", "<Plug>RDSendLine", {})
vim.api.nvim_buf_set_keymap(0, "v", "<Enter>", "<Plug>RSendSelection", {})
end
},
-- user_maps_only = true,
auto_start = 1,
objbr_auto_start = true,
},
lazy = false
} |
Great, I will try that when I am back at home in few hours. |
I have had to create some maps conditionally: {
dir = '~/src/tmp-R-Nvim',
opts = {
R_args = {'--quiet', '--no-save'},
hook = {
after_config = function ()
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rq', '<Plug>RClose', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>ss', '<Plug>RSendSelection', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>sp', '<Plug>RDSendParagraph', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rl', '<Plug>RListSpace', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rm', '<Plug>RClearAll', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rp', '<Plug>RObjectPr', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rn', '<Plug>RObjectNames', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rt', '<Plug>RObjectStr', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rv', '<Plug>RViewDF', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>ra', '<Plug>RShowArgs', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rh', '<Plug>RHelp', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rs', '<Plug>RSummary', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>ro', '<Plug>RUpdateObjBrowser', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>r=', '<Plug>ROpenLists', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>r-', '<Plug>RCloseLists', {})
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", {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>sb', '<Plug>RSendMBlock', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rf', '<Plug>RStart', {})
end
if vim.o.filetype == "rmd" or vim.o.filetype == "quarto" then
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>kn', '<Plug>RKnit', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>kr', '<Plug>RMakeRmd', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>gn', '<Plug>RNextRChunk', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>gN', '<Plug>RPreviousRChunk', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>sc', '<Plug>RSendChunk', {})
vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>sh', '<Plug>RSendChunkFH', {})
end
end
},
user_maps_only = true,
-- clear_line = false,
auto_start = 1,
-- bracketed_paste = false,
objbr_auto_start = true,
term_title = "tmux",
-- external_term = "foot",
},
lazy = false
}, |
You have to do it to avoid duplicated map? On my side all works fine (maybe I missed something) |
The main reason was that when I pressed |
Good to know! |
In the past, when sending multiple lines to RConsole, if the total number of bytes was over 4 Kb, the text was incompletely pasted by Tmux (required to run R in an external terminal on Unix). To test if the problem persists, I converted a PDF book to txt and then converted each line into a
cat()
:The result was a file with 500 Kb.
There was no problem sending all the lines concatenated with
"\n"
directly to R if it was running in Neovim's built-in terminal. Also, there was no problem sending the code to Tmux.However, a bracketed paste didn't work with Neovim's built-in terminal or Tmux.
Considering these results we may consider that we no longer need to source multiple lines if running R on a local Linux system. However, it is prudent to keep the option to source code at least in some circumstances, for example, when running R in a remote machine. We also have to keep the bracketed paste option for Python code in Quarto documents.
Although it's possible, I can't see any usefulness of pasting hundreds of lines on the R Console since the code will scroll up and be out of sight anyway. So, I'm trying to figure out what should be the default behavior. Perhaps: Paste the code directly if the number of lines is below
max_lines_to_paste
; otherwise, source it.Another problem is the number of key bindings created by default: four for each source operation, combining "echo" and "movement". I think we can get rid at least of the "echo" option because
echo=TRUE
can be added tosource_args
.@PMassicotte , @she3o, any suggestions?
The text was updated successfully, but these errors were encountered: