Closed zhmiao closed 8 months ago
If someone writes the R code necessary for this, I can integrate it into nvimcom and, if necessary, add a key binding to Nvim-R to call it. Does the image display in a Tmux pane? Does it display in Neovim terminal inside iTerm2?
It's also possible to display images in mlterm on Linux using img2sixel
, but it does not work inside of either Neovim terminal or Tmux.
Yes, neovim in iTerm2 don't show images either. This is the related issue https://github.com/neovim/neovim/issues/4349 it is still open. It seems w3m in terminal mode in neovim can show images, but I don't think it is useful for graphs in Nvim-R
w3m
will be useful if we display the image in an html file:
<html><body><img src="image.png"></body></html>
Yeah! if we can view graphs within neovim, that would be so cool
What I don't know is how to make all plot commands to output a png file. If plot(0)
made a png, Nvim-R could start a new terminal, create the html to display the image and call w3m. Unfortunately, it would not work if inside Tmux.
is it possible to integrate :terminal
command?
Yes, Nvim-R already uses termopen()
(which is the same :terminal
called in a different way) to start R.
right, I forgot, it seems to output graphs to neovim terminal need some modifications in R itself
R has many graphics devices (png, jpg, svg, X11, etc...). I think what we need is a new graphics device that do two things:
Nvim-R would react to the message and display the PNG. If there was a image already being displayed, w3m would first be closed and then called again.
Are you familiar with how R markdown works? I am not sure how they show pictures in these markdown files
I don't use markdown. Do you have an link to an example?
Maybe you can check this link R_Markdown And this is their repo
The links are for RStudio, not for Vim. RStudio is a Qt application and it has its own graphics device. Because Qt is a GUI toolkit, it's easy to integrate graphical things in it.
I see. Is making a new graphic device complicated?
I don't know to make one, and I don't have time to look at this. If you can create the new graphic device, I can integrate it into Neovim. However, there is another problem: the size of the window displaying the image would be difficult to control. See: https://github.com/jalvesaq/Nvim-R/issues/33
yes, let me look at this.
I have had a look at this. Creating a new graphics device seems hard. Knitr uses the evaluate
package to watch for changes in the graphics device.
Relevant files:
Relevant commands:
Someone has been thinking about a better way to do this from within R, but has made no progress for a while. https://github.com/pmur002/R-display-list/blob/master/capture.plots.R
The markdown
package is R, not RStudio, though it was developed by the RStudio company.
I think there is a major issue in implementing a new graphic device for imagecat. In R, a graphic is not ready to save/print until dev.off()
is invoked. For knitr/rmarkdown, it is easier for them because they know when a plot is ready.
w3m
0.5.3+git20151119 can display images in tmux
2.1. So, if this feature was implemented it could work in both Mac OS X and Linux.
Nvim-R is being superseded by R.nvim, a new project that will be inaugurated in a week at the R-nvim organization. Please, check out tmp-Nvim-R and help us to find the last remaining bugs before R.nvim inauguration. When the project is officially started, you will be able to open issues there and request new features.
Nvim-R will remain alive as a feature-frozen project for Vim users. If you want to know the reason, please, see this discussion.
Since new iTerm2 supports in-line images, I am wondering whether it is possible to output R graphs directly into iTerm so I don't have to use X11 anymore. iTerm image viewer is imgcat and there is an external matplotlib backend for iterm too. In addition, iTerm can also view pdfs (termpdf), although it is really beta for now.