Nvim-R
Nvim-R copied to clipboard
Annoyance: Nvim-R prints out escape sequence at startup in Vim
I use vim and nvim interchangeable. In both Nvim-R works without issues.
However I noticed an annoying behavior: if I open a file from command line in vim an escape sequence is printed at cursor position. Once I redraw (<C-L>
) the buffer is displayed correctly and if I open further files no unwanted output happens. This doesn't happen in files not affected by Nvim-R and also not in nvim, and disappears once I remove the nvim-r plugin.
For reproducibility I created a copy of the Nvim-R and start the command like this so that none of my user config is used:
/usr/bin/vim --clean --cmd "set rtp+=Nvim-R" test.R
I see following screen (and see the cursor jumping from the escpape sequence to the left of the line):
^[[?12;4$y
#
print("hello world")
~
~
1,1 All
When I do the same in nvim it does not print the sequence: /opt/homebrew/bin/nvim --clean --cmd "set rtp+=Nvim-R" test.R
# test.R
#
print("hello world")
~
~
test.R 1,1 All
The sequence printed out appears to be the output of :echo v:termblinkresp
. The vim versions I tried were 8.2 and 9.0. The Nvim-R version I use is a current clone of the master branch (from what I can tell the issue is occurred for at least a month, and the issue doesn't appear on the stable branch). I'm on OS X 12.4 and Terminal iTerm2 (so no GUI).
I'm sorry, but I can't replicate the issue. I'm on Linux (Ubuntu 22.04, gnome-terminal), and v:termblinkresp
is empty.
Weird. For me it's empty in neovim, but always set in regular vim. The only thing I could imagine this is somehow related with the termcap on mac. I played around with various settings for $TERM and it really altered esc sequences printed at the cursor. But maybe that's mac specific, just curious that it doesn't affect other filetypes.
Anyway it's an issue I can easily work around. Thanks for checking.
I am using linux (5.10.131-1-MANJARO) and vim, and I am getting a similar problem. When I start vim on a RMD file I get some gibberish text. But it clears when I refresh the screen. I uninstalled Nvim-R and the problem goes away.
I am using kitty for the terminal. I just checked, and the problem does not show up when I use alacritty.
I installed kitty
on Ubuntu 22.04 and now I can see the escape sequences. They appear and quickly disappear if either Nvim-R or zotcite are installed, but only in Vim, not Neovim. I had to record the screen and play the video to see the printed characters. There are much more characters printed by Nvim-R than by zotcite.
Since the problem only happens in some terminal emulators, and only with Vim, not Neovim, I'm not going to try to fix it. I would accept a pull request, though.
I did a bisect and it appears 76a8d66 is the commit where the issue first appeared. So far didn't find anything that might cause it.
Too many lines of code have changed in this commit to find exactly what is causing the problem, but, certainly, it is code running asynchronously. It seems that Neovim is better than Vim running jobs asynchronously.
I'm trying to come up with a pull request.
I try follow the escape sequence. Vim somehow fills t_RC
with the wrong sequence. I was able to have the symptom disappear by putting set t_RC=
in my vimrc (unsetting it). The purpose of this sequence is to make the cursor blinking - so I doubt changing it will have dramatic effects.
I was also able to find following info in the vim help:
When prepended by |:silent| the terminal will not be set to
cooked mode. This is meant to be used for commands that do
not need the user to type. It avoids stray characters showing
up on the screen which require |CTRL-L| to remove.
:silent let f = system('ls *.vim')
so my next experiment will be to add silent
to to the vim system calls and see if it disappears. I suspect the calls in R/start_ncs.vim
.
I narrowed it down (at least for my output) to line 36 in R/start_ncs.vim
.
Changing the line to
silent let rversion = system(g:rplugin.Rcmd . ' --version')
(placing silent before) makes the output disappear. Could any of you confirm for your output?
Thanks for your work! I prepended silent
to commands running system()
and I can no longer see the escape sequences in Vim on Kitty.
I'm closing the issue. Please, reopen it if not fixed for you.