Skip to content

Commit 0addf16

Browse files
jalvesaqvim-scripts
authored andcommitted
Version 1.2.7: * Fix incompatibility with Tmux 2.1.
1 parent a8b28a8 commit 0addf16

8 files changed

Lines changed: 230 additions & 130 deletions

File tree

autoload/rcomplete.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ function BuildROmniList(pattern)
4545
endfunction
4646

4747
fun! rcomplete#CompleteR(findstart, base)
48-
if &filetype == "rnoweb" && RnwIsInRCode(0) == 0 && exists("*LatexBox_Complete")
49-
let texbegin = LatexBox_Complete(a:findstart, a:base)
50-
return texbegin
48+
if (&filetype == "rnoweb" || &filetype == "rmd" || &filetype == "rrst" || &filetype == "rhelp") && b:IsInRCode(0) == 0 && b:rplugin_nonr_omnifunc != ""
49+
let Ofun = function(b:rplugin_nonr_omnifunc)
50+
let thebegin = Ofun(a:findstart, a:base)
51+
return thebegin
5152
endif
5253
if a:findstart
5354
let line = getline('.')

doc/r-plugin.txt

Lines changed: 68 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Authors: Jakson A. Aquino <jalvesaq@gmail.com>
66
Jose Claudio Faria <joseclaudio.faria@gmail.com>
77

8-
Version: 1.2.6
8+
Version: 1.2.7
99
For Vim version 7.4
1010

1111
1. Overview |r-plugin-overview|
@@ -115,7 +115,7 @@ dependencies:
115115

116116
* R's version must be >= 3.0.0: http://www.r-project.org/
117117

118-
* vimcom = 1.2-6: http://www.lepem.ufc.br/jaa/vimcom.html
118+
* vimcom = 1.2-7: http://www.lepem.ufc.br/jaa/vimcom.html
119119

120120
Note: If you cannot build vimcom yourself, you will want to
121121
download and install the zip file.
@@ -152,7 +152,7 @@ Before installing the plugin, you should install its dependencies:
152152

153153
R >= 3.0.0: http://www.r-project.org/
154154

155-
vimcom = 1.2-6: http://www.lepem.ufc.br/jaa/vimcom.html
155+
vimcom = 1.2-7: http://www.lepem.ufc.br/jaa/vimcom.html
156156

157157
Only if you edit Rnoweb files: MacTeX, BasicTeX or other LaTeX system.
158158

@@ -206,7 +206,7 @@ Before installing the plugin, you should install its dependencies:
206206

207207
R >= 3.0.0: http://www.r-project.org/
208208

209-
vimcom = 1.2-6: http://www.lepem.ufc.br/jaa/vimcom.html
209+
vimcom = 1.2-7: http://www.lepem.ufc.br/jaa/vimcom.html
210210

211211
Tmux >= 1.8: http://tmux.sourceforge.net
212212
Tmux is necessary to send commands from Vim to R Console.
@@ -253,23 +253,25 @@ Put the following in your `~/.bashrc`:
253253
Before proceeding, you have to start a new shell session to have the alias
254254
enabled.
255255

256-
If you start either GVim or Vim in a terminal emulator the plugin will start R
257-
in a external terminal emulator. If you start Vim inside of a Tmux session,
258-
the plugin will split the Tmux window in two and start R in the other pane.
259-
260-
The recommended way of running the plugin on Linux is running Vim inside a
261-
Tmux session. Please, read |r-plugin-tmux| for details.
256+
If you start Vim in a terminal emulator, inside of a Tmux session, the plugin
257+
will split the Tmux window in two and start R in the other pane. This is the
258+
recommended way of running the plugin on Linux (read |r-plugin-tmux| for
259+
details). If you either use GVim or Vim not inside a Tmux session the plugin
260+
will start R in a external terminal emulator. This is useful if you have two
261+
monitors.
262262

263263
If you run Vim in a terminal emulator, it must be started with the argument
264-
|--servername|. Please, read the section |r-plugin-bash-setup| to know some
265-
tips on how to configure Bash.
264+
|--servername| to enable the 'clientserver' feature (please, read the section
265+
|r-plugin-bash-setup| to know some tips on how to configure Bash). This is not
266+
necessary with GVim because it always runs with the 'clientserver' feature
267+
enabled.
266268

267269

268270
------------------------------------------------------------------------------
269271
3.4. Plugin installation (instructions for all systems)~
270272

271273
You need to activate plugins and indentation according to 'filetype'. You
272-
should have at least the following options at the top or at near the very top
274+
should have at least the following options at the top or near the very top
273275
of your |vimrc| (but below `set` `runtimepath`, if you have set it):
274276
>
275277
set nocompatible
@@ -512,18 +514,22 @@ line currently under the cursor you should type <LocalLeader>d. If you want to
512514
see what lines are being sourced when sending a selection of lines, you can
513515
use either <LocalLeader>se or <LocalLeader>sa instead of <LocalLeader>ss.
514516

517+
The command <LocalLeader>o runs in the background the R command `print(line)`,
518+
where `line` is the line under cursor, and adds the output as commented lines
519+
to the source code.
520+
515521
If the cursor is over the header of an R chunk with the `child` option (from
516522
Rnoweb, RMarkdown or RreStructuredText document), and you use one of the
517523
commands that send a single line of code to R, then the plugin will send to R
518524
the command to knit the child document.
519525

520526
After the send, sweave and knit commands, Vim will save the current buffer if
521-
it has any pending changes before performing the tasks. After
522-
<LocalLeader>ao, Vim will run "R CMD BATCH --no-restore --no-save" on the
523-
current file and show the resulting .Rout file in a new tab. Please see
524-
|vimrplugin_routnotab| if you prefer that the file is open in a new split
525-
window. Note: The command <LocalLeader>ao, silently writes the current buffer
526-
to its file if it was modified and deletes the .Rout file if it exists.
527+
it has any pending changes before performing the tasks. After <LocalLeader>ao,
528+
Vim will run "R CMD BATCH --no-restore --no-save" on the current file and show
529+
the resulting .Rout file in a new tab. Please see |vimrplugin_routnotab| if
530+
you prefer that the file is open in a new split window. Note: The command
531+
<LocalLeader>ao, silently writes the current buffer to its file if it was
532+
modified and deletes the .Rout file if it exists.
527533

528534
R syntax uses " <- " to assign values to variables which is inconvenient to
529535
type. In insert mode, typing a single underscore, "_", will write " <- ",
@@ -815,9 +821,12 @@ file:
815821
816822
# Options enable mouse support in Tmux
817823
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
824+
# For Tmux < 2.1
818825
set -g mode-mouse on
819826
set -g mouse-select-pane on
820827
set -g mouse-resize-pane on
828+
# For Tmux >= 2.1
829+
set -g mouse on
821830
822831
# Act more like vim:
823832
set-window-option -g mode-keys vi
@@ -999,16 +1008,16 @@ operator. See: https://github.com/jcfaria/Vim-R-plugin/issues/94
9991008
------------------------------------------------------------------------------
10001009
5.4. Wrong message that "R is busy" (Windows only)~
10011010

1002-
On Windows, when code is sent from Vim to R Console, the vimcom library
1003-
sets the value of the internal variable `r_is_busy` to 1. The value is set
1004-
back to 0 when any code is successfully evaluated. If you send invalid code to
1005-
R, there will be no successful evaluation of code and, thus, the value of
1006-
`r_is_busy` will remain set to 1. If you then try to update the Object
1007-
Browser, see the R documentation for any function, or do other tasks that
1008-
require the hidden evaluation of code by R, the vimcom library will
1009-
refuse to do the tasks to avoid any risk of corrupting R's memory. It will
1010-
tell Vim that "R is busy" and Vim will display this message. Everything should
1011-
work as expected again after any valid code is executed in the R Console.
1011+
On Windows, when code is sent from Vim to R Console, the vimcom library sets
1012+
the value of the internal variable `r_is_busy` to 1. The value is set back to
1013+
0 when any code is successfully evaluated. If you send invalid code to R,
1014+
there will be no successful evaluation of code and the value of `r_is_busy`
1015+
will remain set to 1. If you then try to update the Object Browser, see the R
1016+
documentation for any function, or do other tasks that require the hidden
1017+
evaluation of code by R, the vimcom library will refuse to do the tasks to
1018+
avoid any risk of corrupting R's memory. It will tell Vim that "R is busy" and
1019+
Vim will display this message. Everything should work as expected again after
1020+
any valid code is executed in the R Console.
10121021

10131022
The vimcom library is started with the state `busy`.
10141023

@@ -1101,7 +1110,7 @@ VIMINSTANCEID, and VIMRPLUGIN_SECRET. The first one is the path used by the R
11011110
package vimcom to save temporary files used by the Vim-R-plugin to: perform
11021111
omnicompletion, show R documentation in a Vim buffer, and update the Object
11031112
Browser. The two last ones are used by the Vim-R-plugin and by vimcom to know
1104-
that the connections are valid. If you use Vim to start R, but then closes
1113+
that the connections are valid. If you use Vim to start R, but then close
11051114
Vim, some variables will become outdated. Additionally, the Vim-R-plugin sets
11061115
the value of its internal variable SendCmdToR from SendCmdToR_fake to the
11071116
appropriate value when R is successfully started. It is possible to set the
@@ -1400,8 +1409,8 @@ it works, please, read the subsection 6.5.2 below.
14001409
------------------------------------------------------------------------------
14011410
6.5.2. Details and other options:~
14021411

1403-
The plugin key bindings will remain active in the documentation buffer, and,
1404-
thus, you will be able to send commands to R as you do while editing an R
1412+
The plugin key bindings will remain active in the documentation buffer
1413+
allowing you to send commands to R as you would do do while editing an R
14051414
script. You can, for example, use <LocalLeader>rh to jump to another R help
14061415
document.
14071416

@@ -1662,7 +1671,7 @@ this behavior. Examples:
16621671
let vimrplugin_latexcmd = 'latexmk -pdf -pdflatex="xelatex %O -synctex=1 %S"'
16631672
<
16641673
By default, vimrplugin_latexmk is 0 on Windows and 1 on other systems.
1665-
If you want to pass arguments do the `Sweave()` function, set the value of the
1674+
If you want to pass arguments to the `Sweave()` function, set the value of the
16661675
vimrplugin_sweaveargs variable.
16671676

16681677
If the value of `vimrplugin_texerr` is `1`, a summary of LaTeX errors
@@ -2148,7 +2157,7 @@ can type |:map| to see the complete list of current mappings, and below is the
21482157
list of the names for custom key bindings (the prefix RE means "echo";
21492158
RD, "cursor down"; RED, both "echo" and "down"):
21502159

2151-
Star/Close R~
2160+
Start/Close R~
21522161
RStart
21532162
RCustomStart
21542163
RClose
@@ -2282,7 +2291,7 @@ later version.
22822291

22832292
The Vim-R-plugin is distributed in the hope that it will be useful, but
22842293
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2285-
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2294+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22862295
details.
22872296

22882297
A copy of the GNU General Public License is available at
@@ -2553,9 +2562,9 @@ develop a better algorithm in the future.
25532562
9.10. Highlight chunk header as R code~
25542563

25552564
By default, Vim will highlight chunk headers of RMarkdown and
2556-
RreStructuredText with a single color. When the code is processed by knitr,
2557-
chunk headers should contain valid R code and, thus, you may want to highlight
2558-
them as such. You can do this by putting in your |vimrc|:
2565+
RreStructuredText with a single color. Chunk headers should contain valid R
2566+
code when the code is processed by knitr, so you may want to highlight them as
2567+
such. You can do this by putting in your |vimrc|:
25592568
>
25602569
let rrst_syn_hl_chunk = 1
25612570
let rmd_syn_hl_chunk = 1
@@ -2586,13 +2595,7 @@ Vim breaks the R code automatically put in your |vimrc|:
25862595

25872596
If you want 256 colors support in Vim, install the package ncurses-term. Then
25882597
put in your `~/.bashrc` the lines suggested at |r-plugin-bash-setup|.
2589-
Finally, put in your |vimrc|:
2590-
>
2591-
if &term =~ "xterm" || &term =~ "256" || $DISPLAY != ""
2592-
set t_Co=256
2593-
endif
2594-
colorscheme your_preferred_color_scheme
2595-
<
2598+
25962599
You have to search the internet for color schemes supporting 256 colors,
25972600
download and copy them to ~/.vim/colors. You may use the command
25982601
|:colorscheme| to try them one by one before setting your preference in your
@@ -2738,11 +2741,6 @@ please read this document from the beginning.
27382741
" schemes that supports 256 colors in the terminal emulator. Then,
27392742
" uncomment the code below to set you color scheme:
27402743
"colorscheme not_defined
2741-
2742-
" Use 256 colors even if in a terminal emulator:
2743-
if &term =~ "xterm" || &term =~ "256" || $DISPLAY != ""
2744-
set t_Co=256
2745-
endif
27462744
<
27472745

27482746
*r-plugin-R-setup*
@@ -2763,25 +2761,30 @@ please read this document from the beginning.
27632761
<
27642762

27652763
*r-plugin-bash-setup*
2766-
~/.bashrc for Vim (Unix):~
2764+
~/.bashrc (Linux, Mac OS X, and other Unix systems):~
27672765
>
2768-
# Change the TERM environment variable (to get 256 colors) and make Vim
2769-
# connecting to X Server even if running in a terminal emulator (many of
2770-
# the plugin features depend on this).
2766+
# Change the TERM environment variable (to get 256 colors) even if you are
2767+
# accessing your system through ssh and using either Tmux or GNU Screen:
2768+
if [ "$TERM" = "xterm" ] || [ "$TERM" = "xterm-256color" ]
2769+
then
2770+
export TERM=xterm-256color
2771+
export HAS_256_COLORS=yes
2772+
fi
2773+
if [ "$TERM" = "screen" ] && [ "$HAS_256_COLORS" = "yes" ]
2774+
then
2775+
export TERM=screen-256color
2776+
fi
2777+
2778+
# Make Vim connect to X Server even if the gui is not running (many of the
2779+
# plugin features depend on this).
27712780
if [ "x$DISPLAY" != "x" ]
27722781
then
2773-
if [ "screen" = "$TERM" ]
2774-
then
2775-
export TERM=screen-256color
2776-
else
2777-
export TERM=xterm-256color
2778-
fi
27792782
alias vim='vim --servername VIM'
27802783
fi
27812784
<
27822785

27832786

2784-
Finally, if you want to use vi key bindings in Bash:
2787+
Finally, if you want to use vi key bindings in Bash or other shell:
27852788

27862789
~/.inputrc~
27872790
>
@@ -2830,6 +2833,10 @@ put in your |vimrc|:
28302833
*r-plugin-news*
28312834
10. News~
28322835

2836+
1.2.7 (2015-11-27)
2837+
2838+
* Fix incompatibility with Tmux 2.1.
2839+
28332840
1.2.6 (2015-06-12)
28342841

28352842
* Improve support for lazy load objects in the Object Browser.

ftplugin/rbrowser.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ function! UpdateOB(what)
9595
if bufname("%") =~ "Object_Browser" || b:rplugin_extern_ob
9696
setlocal nomodifiable
9797
endif
98-
redraw
9998
if rplugin_switchedbuf
10099
exe "sil noautocmd sb " . g:rplugin_curbuf
101100
exe "set switchbuf=" . savesb

ftplugin/rhelp_rplugin.vim

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,46 @@ function! RhelpIsInRCode(vrb)
3434
endif
3535
endfunction
3636

37+
function! RhelpComplete(findstart, base)
38+
if a:findstart
39+
let line = getline('.')
40+
let start = col('.') - 1
41+
while start > 0 && (line[start - 1] =~ '\w' || line[start - 1] == '\')
42+
let start -= 1
43+
endwhile
44+
return start
45+
else
46+
let resp = []
47+
let hwords = ['\Alpha', '\Beta', '\Chi', '\Delta', '\Epsilon',
48+
\ '\Eta', '\Gamma', '\Iota', '\Kappa', '\Lambda', '\Mu', '\Nu',
49+
\ '\Omega', '\Omicron', '\Phi', '\Pi', '\Psi', '\R', '\Rdversion',
50+
\ '\Rho', '\S4method', '\Sexpr', '\Sigma', '\Tau', '\Theta', '\Upsilon',
51+
\ '\Xi', '\Zeta', '\acronym', '\alias', '\alpha', '\arguments',
52+
\ '\author', '\beta', '\bold', '\chi', '\cite', '\code', '\command',
53+
\ '\concept', '\cr', '\dQuote', '\delta', '\deqn', '\describe',
54+
\ '\description', '\details', '\dfn', '\docType', '\dontrun', '\dontshow',
55+
\ '\donttest', '\dots', '\email', '\emph', '\encoding', '\enumerate',
56+
\ '\env', '\epsilon', '\eqn', '\eta', '\examples', '\file', '\format',
57+
\ '\gamma', '\ge', '\href', '\iota', '\item', '\itemize', '\kappa',
58+
\ '\kbd', '\keyword', '\lambda', '\ldots', '\le',
59+
\ '\link', '\linkS4class', '\method', '\mu', '\name', '\newcommand',
60+
\ '\note', '\nu', '\omega', '\omicron', '\option', '\phi', '\pi',
61+
\ '\pkg', '\preformatted', '\psi', '\references', '\renewcommand', '\rho',
62+
\ '\sQuote', '\samp', '\section', '\seealso', '\sigma', '\source',
63+
\ '\special', '\strong', '\subsection', '\synopsis', '\tab', '\tabular',
64+
\ '\tau', '\testonly', '\theta', '\title', '\upsilon', '\url', '\usage',
65+
\ '\value', '\var', '\verb', '\xi', '\zeta']
66+
for word in hwords
67+
if word =~ '^' . escape(a:base, '\')
68+
call add(resp, {'word': word})
69+
endif
70+
endfor
71+
return resp
72+
endif
73+
endfunction
74+
3775
let b:IsInRCode = function("RhelpIsInRCode")
76+
let b:rplugin_nonr_omnifunc = "RhelpComplete"
3877

3978
"==========================================================================
4079
" Key bindings and menu items

ftplugin/rnoweb_rplugin.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ endfunction
244244

245245
if g:vimrplugin_rnowebchunk == 1
246246
" Write code chunk in rnoweb files
247-
imap <buffer><silent> < <Esc>:call RWriteChunk()<CR>a
247+
inoremap <buffer><silent> < <Esc>:call RWriteChunk()<CR>a
248248
endif
249249

250250
" Pointers to functions whose purposes are the same in rnoweb, rrst, rmd,

r-plugin/common_buffer.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
" Set completion with CTRL-X CTRL-O to autoloaded function.
2727
if exists('&ofu')
28+
if &filetype == "rnoweb" || &filetype == "rrst" || &filetype == "rmd"
29+
let b:rplugin_nonr_omnifunc = &omnifunc
30+
endif
2831
if &filetype == "r" || &filetype == "rnoweb" || &filetype == "rdoc" || &filetype == "rhelp" || &filetype == "rrst" || &filetype == "rmd"
2932
setlocal omnifunc=rcomplete#CompleteR
3033
endif

0 commit comments

Comments
 (0)