Nvim-R
Nvim-R copied to clipboard
Support for Neovim Float Windows
Thanks for such a great plugin!
Is there any chance we could direct the output of some of the commands to a floating window in neovim instead of a new tab or split so that one can quickly reference and hide the information? Such applications could be viewing the help documentation (\rh) or viewing a dataframe (\vh).
For RHelp maybe allow a "float" option for "R_nvimpager"
For RViewDF it looks like 'terminal:' is hardcoded in when supplied by "R_csv_app", maybe allow a switch to call another user supplied vim command. For instance, a user could call "TermExec vd" to open the dataframe in visidata in a floating terminal.
Thanks again!
Displaying help pages on float windows would be easy. We would have to decide the float windows' position, width, and height. And, what about the ability to send code from the Examples
section to R? If the floating window overlaps the R console, the output might not be visible.
For RViewDF, it might be enough to add another condition:
elseif g:R_csv_app =~# '^:'
exe g:R_csv_app . ' ' . substitute(tsvnm, ' ', '\\ ', 'g')
For floats the default in neovim is to open under the cursor, the buffer of the float window is able to be entered if you issue the command that spawned the float a second time i.e. K
opens the float and K
again enters it for vim.lsp.buf.hover(). I would imagine if you set the buff type to R_doc
the existing autocommands for that filetype would apply allowing code from the Examples
section to be sent to the R console.
Perhaps it would be better if we contributed to the development of the languageserver
package until we couldn't see any advantage of specific Nvim-R's functionalities. Then, I could drop these features from Nvim-R. In the end, only features depending on R's workspace and features that take advantage of Neovim features would remain in Nvim-R (Object Browser, highlighting of function names, completion of data.frame
columns, etc).
It seems that the languageserver
team doesn't want to cache information, and we need this for high speed and low CPU usage during automatic omni completion and while updating the Object Browser. However, we only display R documentation under user demand. So, we don't need ultra-high speed. That is, the ability to show R documentation is one of the features that could be dropped in the future in favor of the languageserver
.
You can now put this in your init.vim:
let R_csv_app = ':TermExec cmd="vd %s"'
%s
indicates the position of the tsv
file name in the command.
Awesome, thanks! I agree on languageserver since it provides the help files already, wish it had better formatting, NVim-R's docs look much nicer.
Nvim-R gets R documentation as text, makes some changes in the document (ftplugin/rdoc.vim) and, then, applies a specific highlighting (syntax/rdoc.vim). This is a solution tailored specifically for Vim/Neovim. The languageserver has to use a more generic approach since it is used by a variety of text editors and IDEs. The Language Server Protocol uses markdown for reach-text contents. So, the languageserver gets R documentation as HTML and converts it to markdown.
You can try the branch rd2md from my fork of the languageserver
. R documentation is converted directly to markdown. The result might be better for Neovim, but possibly not for text editors that are capable of displaying HTML.
Another approach would be what you have suggested: request plain text to the language server and treat it as Nvim-R does with R documentation. However, it seems that Neovim's lsp
is hard coded to syntax highlight the documents as lsp_markdown
.
Hey guys thanks a lot for this help. just on question regarding this command.
let R_csv_app = ':TermExec cmd="vd %s"'
This command works great, but the floating window is not that great. (usually I want to keep the df open while working on the r script)
is there a way to open vd
in a new tab or like horizontal term?
I found this command to be working:
let R_csv_app = ':terminal vd'
thanks a lot
Those interested in better use of Neovim features might want to look at this: https://github.com/jalvesaq/Nvim-R/discussions
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.
I started using the new version and it's kinda work differently, so I'm a little bit getting used to it. two quick observations:
- the console got so much cleaner and colorful.
- it feels so much faster, I'm not sure if this is true though.
- The option to colorize the output was introduced in 2015 (you can search for "hl_term" in the log of commits), but perhaps it is configured in Nvim-R in such a way that becomes disabled on your system.
- Possibly a bit faster at some operations because, without Vim, we are free to use the
nvim_
functions which are designed to not disturb the editor.
Thank you for the comprehensive response. So, I've been using it without colors all these years. Nice!
I've encountered some issues and have some feedback. I'll probably open an issue in the repo today.
- The option to colorize the output was introduced in 2015 (you can search for "hl_term" in the log of commits), but perhaps it is configured in Nvim-R in such a way that becomes disabled on your system.
Note: only in Neovim. Vim never implemented syntax highlighting of the terminal.