Closed PMassicotte closed 4 months ago
An option to send the current object to the terminal:
if rcmd == "print" then
send.cmd(vim.fn.expand("<cword>"))
return
end
An option to send the current object to the terminal:
The problem is that vim.fn.expand("<cword>")
will not catch strings such as listname$element
.
But we could try to change the value of vim.o.iskeywords
temporarily. It will be much simpler than the complicated algorithm that I have written.
nvimcom
and rnvimserver
now send Lua tables to R.nvim. You have to update cmp-nvim-r
.
There are some bugs when completing functions from .GlobalEnv
, but I will fix them later.
The problem while running <LocalLeader>rp
is the function get_first_obj()
. It has to be rewritten from scratch.
Has something about terminal color changed this recently? Looks like a new config is coloring my terminal. Nevermind, I just set hl_term = false
and it is all good.
Yes, hl_term
is being defined as true
, but nvimcom/R/nvimcom.R
should detect radian
:
if (length(find.package("colorout", quiet = TRUE, verbose = FALSE)) > 0 || Sys.getenv("RADIAN_VERSION") != "")
hascolor <- TRUE
It was opening radian, but my console was all green-ish.
I did a minor improvement in get_first_obj
. With the following code:
x <- rnorm(100)
y <- rnorm(100)
m <- lm(y ~ x)
summary(x)
summary(m)
If you press <LocalLeader>rp
over summary
, you should get different results for each summary()
I moved the check for radian to the config. It's working there.
I did a minor improvement in
get_first_obj
. With the following code:x <- rnorm(100) y <- rnorm(100) m <- lm(y ~ x) summary(x) summary(m)
If you press
<LocalLeader>rp
oversummary
, you should get different results for eachsummary()
Is it works if my cursor is either on x
or m
!
I rewrote get_first_obj()
and now it is as good and as bad as Nvim-R's version. I don't want to improve it any further because perhaps it will be possible (and better) to rewrite it using tree-sitter in the future. To quickly test the function, I have put this in my init.lua
:
vim.keymap.set("n", "T", function ()
vim.api.nvim_echo({
{"{"},
{require("r.run").get_keyword(), "Function"},
{"} {"},
{require("r.cursor").get_first_obj(), "Type"},
{"}"}}, false, {})
end, { expr = true})
rh
(for help) is not working for a namespaced function. For examplepack::fun()
I can't replicate this. It works for me, for example doing <LocalLeader>rh
over the word vi
:
vi
nvimcom::vi
utils::vi
Placing my cursor on library
and hitting <LocalLeader>rh
does nothing. With the older nrim-r, it opens the help file for the library()
function.
Now, placing my cursor on vi
indeed brings me a topic menu. Then, If I select either 1 for nvimcom or 2 for utils, nothing happens.
Maybe you have set options("pager")
in your ~/.Rprofile
... I couldn't think of another explanation.
Also: \rh
only works if R is running, but, if not, R.nvim displays a warning message.
No option about pager in my rprofile.
Even typing ?lm
in the console does nothing.
So it looks like that tmp-R-Nvim
is not opening a new window properly.
The only pager option I have is this config:
opts = {
...
nvimpager = "horizontal",
...
}
With this option, I receive a warning message:
Invalid nvimpager
value: "horizontal". Valid values are: "tab", "split", "float", and "no".
And nothing more happens. Hence, we have to investigate why you are not receiving this warning.
You are right, it works as before when using 'split'. I probably missed the change of the parameter (i.e. using an old value that was working with nvim-r).
What is supposed to be the file type of rdoc?
For me, :set filetype?
returns nothing
Hence, sending example code in the terminal is not working because not recognized as r code.
The warning should be wrapped by vim.schedule()
. This is fixed now.
The filetype rdoc
no longer exists; only the syntax is being used.
It was a filetype that I created to display R documentation. Its functions are now in lua/r/rdoc.lua
.
The filetype
rdoc
no longer exists; only the syntax is being used.
Do you have a good strategy to send example code to the console? I found it was a nice thing to do while browsing code example and have the ability to send it to the console.
Yes, please, do git pull
to get the warnings. I didn't see the warn bug because I had this in my lazy.nvim config:
{
'rcarriga/nvim-notify',
config = function ()
-- Overriding vim.notify with fancy notify
local notify = require("notify")
vim.notify = notify
notify.setup()
vim.keymap.set('', '<Esc>', "<ESC>:noh<CR>:lua require('notify').dismiss()<CR>", {silent = true})
end
},
\re
to get the "Examples" section in an R buffer.
Another thing I am just facing is that sending above code does not always work. In this example, moving the cursor 2 lines below give me an error cannot open the connection. Moving back the cursor up, make it works again.
Maybe we can just grab all the lines above and send them directly to the console instead of writing a tmp file.
But you can also send lines from the Example section to R. The rdoc is modifiable to allow you to edit the examples. There was a bug that I fixed just now.
But you can also send lines from the Example section to R. The rdoc is modifiable to allow you to edit the examples. There was a bug that I fixed just now.
You are on fire :)
Another thing I am just facing is that sending above code does not always work. In this example, moving the cursor 2 lines below give me an error cannot open the connection. Moving back the cursor up, make it works again.
Two lines above you were below the threshold of 20 lines to source lines and the lines were sent directly. I introduced the bug yesterday when fixing user config variables not being recognized. It should be fixed now.
All perfect now!
Just listing issues I am finding so we can fix them :)
rh
(for help) is not working for a namespaced function. For examplepack::fun()
rp
for printing an object is not always working (see attached GIF). Might usevim.fn.expand("<cword>")
I think it is coming from these lines:
https://github.com/jalvesaq/tmp-R-Nvim/blob/7fd9fffcc870652bdad1e3e7dd0fee66e879a40a/lua/r/run.lua#L601-L605