Comments (35)
We could also echo like the first n and the last n lines of the block.
It's a good idea, but I don't know how to implement it with base::source()
.
So, if I understand correctly, we could simply send the lines to the console without sourcing a temp file (except for some use case you describe)?
Yes, except if the number of lines is > max_lines_paste
. I suggest a default value close to 20 for this option. Of course, users would be free to change it to any value between 1 and inf
.
from r.nvim.
We could also echo like the first n and the last n lines of the block.
Actually, this could be done inside nvimcom:::NvimR.source()
from r.nvim.
If indeed the problem was the environment variable being nil
, it should be fixed now.
from r.nvim.
I uploaded some bug fixes in many files. So, please, do git pull
before pushing new changes. I intended to do a pull request, but I forgot to create a branch and pushed the changes to the main branch.
from r.nvim.
The main reason was that when I pressed <leader>gd
over a function name in a Lua buffer, the LSP opened a quickfix window with two lines and, then, when I pressed <Enter>
nothing happened. The problem was that I mapped <Enter>
to send lines to R, and the map was active in all buffers. The hooks are very cheap to add; just 2 lines of code: one in the table config
and the other where the function should be called.
from r.nvim.
I like the idea of max_line_to_paste
. We could also echo like the first n and the last n lines of the block. So, if I understand correctly, we could simply send the lines to the console without sourcing a temp file (except for some use case you describe)?
from r.nvim.
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
rf
indeed opens the R terminal, but when I try to send a function I get the R not ready.
from r.nvim.
I was testing the external terminal, and introduced this bug for the built-in terminal. I will fix it in a couple of minutes.
from r.nvim.
No rush :)
from r.nvim.
I can't replicate the bug.
from r.nvim.
Could you try this:
echo 'remove.packages("nvimcom")' | R
Maybe nvimcom needs to be rebuilt...
from r.nvim.
I removed nvimcom and it re-install when I open a R file in nvimr. But I still have that same issue.
from r.nvim.
WIll investigate and report back.
from r.nvim.
Actually, I am getting some lua errors. Do you get some if you type :messages
from r.nvim.
Looks like it is coming from exec_stdout_cmd
from r.nvim.
When an environment variable doesn't exist, the vim.env.VAR
is nil
...
I will grep 'vim.env.*\.\.'
and fix the cases when the environment variable might not exist.
from r.nvim.
Super, working perfectly fine!
from r.nvim.
The echo/silent
and down/stay
are inverted in function call:
so m
is equall to either echo/silent
.
We can fix that later when we decide what to do with the echo/silent
options.
from r.nvim.
We can fix that later when we decide what to do with the echo/silent options.
What is your opinion on this? I prefer to eliminate the "echo" parameter from the send functions because users can set the value of source_args
as ", echo=TRUE"
. It's redundant to have both maps for echoing what is being sourced and the option to do this with source_args
. I prefer to simplify the functions and reduce the number of key bindings. But if you like the parameter we can keep it.
from r.nvim.
Super, working perfectly fine!
If you do git pull
now the Object Browser will auto start faster because I removed the 1 second delay on Unix.
from r.nvim.
We can fix that later when we decide what to do with the echo/silent options.
What is your opinion on this? I prefer to eliminate the "echo" parameter from the send functions because users can set the value of
source_args
as", echo=TRUE"
. It's redundant to have both maps for echoing what is being sourced and the option to do this withsource_args
. I prefer to simplify the functions and reduce the number of key bindings. But if you like the parameter we can keep it.
Make total sens. I up to remove echo.
from r.nvim.
Super, working perfectly fine!
If you do
git pull
now the Object Browser will auto start faster because I removed the 1 second delay on Unix.
Oh this is nice. Open a nanosecond after the terminal. Tx!
from r.nvim.
So, please, feel free to remove the "echo" parameter if you have time.
from r.nvim.
all right, will do it right now
from r.nvim.
I'm implementing the option max_paste_lines
...
from r.nvim.
Great! The project is taking shape!
from r.nvim.
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 false
and the other with true
, only the second one is active, as we can see with :nmap
. This happens at least with SendParagraph, and SendSelection.
from r.nvim.
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?
from r.nvim.
Thanks for looking at that!
I found the problem: it was my configuration! I was setting custom key bindings and they were preventing maps.lua
to do its job.
My default mapping to send lines of code to R, <Enter>
is also preventing me from using the LSP quickfix list. I will create a new hook to overcome this problem.
from r.nvim.
oh cool!
from r.nvim.
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
}
from r.nvim.
Great, I will try that when I am back at home in few hours.
from r.nvim.
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
},
from r.nvim.
You have to do it to avoid duplicated map? On my side all works fine (maybe I missed something)
from r.nvim.
Good to know!
from r.nvim.
Related Issues (20)
- Can't send code from R documentation to R Console HOT 1
- [`pdfviewer`] Add support for or make default: `vim.ui.open` HOT 3
- Can not get arguments completion use `devtools::load_all` of functions which are not export in NAMESPACE HOT 21
- setting object browser and console verticallly HOT 2
- Failure to build nvimcom HOT 4
- Setting pipe_keymap not working HOT 2
- Open R console in a new tmux pane HOT 23
- clear_line not working with R console in tmux HOT 5
- Possible resource to add to the wiki HOT 6
- Why build nvimcom: Nvimcom not installed HOT 6
- Breaking changes introduced by the latest version of treesitter? HOT 27
- Issue from LSP? HOT 3
- Upcoming R version might break nvimcom HOT 7
- nvimcom fails to compile since 4f28bfd HOT 3
- Has function of `<Leader>l` and `<Leader>d` been changed? HOT 9
- In tmux RDSendLine does not work when opening a second buffer HOT 3
- Running R in a ToggleTerm HOT 4
- .Rnw does not highlight latex syntax until I do :e HOT 3
- renv is ignored when using external_term HOT 10
- R code lines incorrectly identified HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from r.nvim.