-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathrhelp_rplugin.vim
More file actions
99 lines (87 loc) · 3.79 KB
/
rhelp_rplugin.vim
File metadata and controls
99 lines (87 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
if exists("g:disable_r_ftplugin") || has("nvim")
finish
endif
" Source scripts common to R, Rnoweb, Rhelp and rdoc files:
runtime r-plugin/common_global.vim
if exists("g:rplugin_failed")
finish
endif
" Some buffer variables common to R, Rnoweb, Rhelp and rdoc file need be
" defined after the global ones:
runtime r-plugin/common_buffer.vim
if !exists("b:did_ftplugin") && !exists("g:rplugin_runtime_warn")
runtime ftplugin/rhelp.vim
if !exists("b:did_ftplugin")
call RWarningMsgInp("Your runtime files seems to be outdated.\nSee: https://github.com/jalvesaq/R-Vim-runtime")
let g:rplugin_runtime_warn = 1
endif
endif
function! RhelpIsInRCode(vrb)
let lastsec = search('^\\[a-z][a-z]*{', "bncW")
let secname = getline(lastsec)
if line(".") > lastsec && (secname =~ '^\\usage{' || secname =~ '^\\examples{' || secname =~ '^\\dontshow{' || secname =~ '^\\dontrun{' || secname =~ '^\\donttest{' || secname =~ '^\\testonly{')
return 1
else
if a:vrb
call RWarningMsg("Not inside an R section.")
endif
return 0
endif
endfunction
function! RhelpComplete(findstart, base)
if a:findstart
let line = getline('.')
let start = col('.') - 1
while start > 0 && (line[start - 1] =~ '\w' || line[start - 1] == '\')
let start -= 1
endwhile
return start
else
let resp = []
let hwords = ['\Alpha', '\Beta', '\Chi', '\Delta', '\Epsilon',
\ '\Eta', '\Gamma', '\Iota', '\Kappa', '\Lambda', '\Mu', '\Nu',
\ '\Omega', '\Omicron', '\Phi', '\Pi', '\Psi', '\R', '\Rdversion',
\ '\Rho', '\S4method', '\Sexpr', '\Sigma', '\Tau', '\Theta', '\Upsilon',
\ '\Xi', '\Zeta', '\acronym', '\alias', '\alpha', '\arguments',
\ '\author', '\beta', '\bold', '\chi', '\cite', '\code', '\command',
\ '\concept', '\cr', '\dQuote', '\delta', '\deqn', '\describe',
\ '\description', '\details', '\dfn', '\docType', '\dontrun', '\dontshow',
\ '\donttest', '\dots', '\email', '\emph', '\encoding', '\enumerate',
\ '\env', '\epsilon', '\eqn', '\eta', '\examples', '\file', '\format',
\ '\gamma', '\ge', '\href', '\iota', '\item', '\itemize', '\kappa',
\ '\kbd', '\keyword', '\lambda', '\ldots', '\le',
\ '\link', '\linkS4class', '\method', '\mu', '\name', '\newcommand',
\ '\note', '\nu', '\omega', '\omicron', '\option', '\phi', '\pi',
\ '\pkg', '\preformatted', '\psi', '\references', '\renewcommand', '\rho',
\ '\sQuote', '\samp', '\section', '\seealso', '\sigma', '\source',
\ '\special', '\strong', '\subsection', '\synopsis', '\tab', '\tabular',
\ '\tau', '\testonly', '\theta', '\title', '\upsilon', '\url', '\usage',
\ '\value', '\var', '\verb', '\xi', '\zeta']
for word in hwords
if word =~ '^' . escape(a:base, '\')
call add(resp, {'word': word})
endif
endfor
return resp
endif
endfunction
let b:IsInRCode = function("RhelpIsInRCode")
let b:rplugin_nonr_omnifunc = "RhelpComplete"
"==========================================================================
" Key bindings and menu items
call RCreateStartMaps()
call RCreateEditMaps()
call RCreateSendMaps()
call RControlMaps()
call RCreateMaps("nvi", '<Plug>RSetwd', 'rd', ':call RSetWD()')
" Menu R
if has("gui_running")
runtime r-plugin/gui_running.vim
call MakeRMenu()
endif
call RSourceOtherScripts()
if exists("b:undo_ftplugin")
let b:undo_ftplugin .= " | unlet! b:IsInRCode"
else
let b:undo_ftplugin = "unlet! b:IsInRCode"
endif