File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1
1
priority -50
2
2
3
+ global !p
4
+ import os
5
+ from vimsnippets import complete
6
+
7
+ FIELD_TYPES = [
8
+ ' character' ,
9
+ ' data.frame' ,
10
+ ' integer' ,
11
+ ' list' ,
12
+ ' logical' ,
13
+ ' matrix' ,
14
+ ' numeric' ,
15
+ ' vector' ]
16
+ endglobal
17
+
3
18
snippet #! " Hashbang for Rscript (#!)" b
4
19
#!/usr/bin/env Rscript
5
20
endsnippet
6
21
22
+ snippet setwd " Set workingdir" b
23
+ setwd("${1: `!p snip.rv = os.getcwd()` } ")
24
+ endsnippet
25
+
26
+ snippet as " Apply type on variable" w
27
+ as.$1 `!p snip.rv = complete(t[1 ], FIELD_TYPES ) ` (${2} ${VISUAL})
28
+ endsnippet
29
+
30
+ snippet is " Test type on variable" w
31
+ is.$1 `!p snip.rv = complete(t[1 ], FIELD_TYPES ) ` (${2} ${VISUAL})
32
+ endsnippet
33
+
34
+ snippet dl " Download and install a package" b
35
+ download.file("${1: ${VISUAL:url to package } }", destfile = "${2: ${1 / . * \/ (\S * )$ / (? 1:$ 1) / ga } } ")
36
+ install.packages("$2 ", type = "source", repos = NULL)
37
+ library("${3: ${2 / ^ (\w + )_. * $ / (? 1:$ 1) / ga } } ")
38
+ endsnippet
39
+
7
40
snippet lib " Import a library"
8
41
library(${0: package } )
9
42
endsnippet
You can’t perform that action at this time.
0 commit comments