diff --git a/UltiSnips/r.snippets b/UltiSnips/r.snippets index 74ecc1d..10c818c 100644 --- a/UltiSnips/r.snippets +++ b/UltiSnips/r.snippets @@ -1,9 +1,42 @@ priority -50 +global !p +import os +from vimsnippets import complete + +FIELD_TYPES = [ +'character', +'data.frame', +'integer', +'list', +'logical', +'matrix', +'numeric', +'vector'] +endglobal + snippet #! "Hashbang for Rscript (#!)" b #!/usr/bin/env Rscript endsnippet +snippet setwd "Set workingdir" b +setwd("${1:`!p snip.rv = os.getcwd()`}") +endsnippet + +snippet as "Apply type on variable" w +as.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL}) +endsnippet + +snippet is "Test type on variable" w +is.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL}) +endsnippet + +snippet dl "Download and install a package" b +download.file("${1:${VISUAL:url to package}}", destfile = "${2:${1/.*\/(\S*)$/(?1:$1)/ga}}") +install.packages("$2", type = "source", repos = NULL) +library("${3:${2/^(\w+)_.*$/(?1:$1)/ga}}") +endsnippet + snippet lib "Import a library" library(${0:package}) endsnippet diff --git a/snippets/_.snippets b/snippets/_.snippets index 6a3d8b2..8561601 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -84,6 +84,24 @@ snippet LGPL3 You should have received a copy of the GNU Lesser General Public License along with this library; if not, see . + ${0} +snippet AGPL3 + ${1:one line to give the program's name and a brief description.} + Copyright (C) `strftime("%Y")` ${2:copyright holder} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + ${0} snippet BSD2 ${1:one line to give the program's name and a brief description} diff --git a/snippets/css.snippets b/snippets/css.snippets index 8886643..c4a74de 100644 --- a/snippets/css.snippets +++ b/snippets/css.snippets @@ -965,3 +965,23 @@ snippet z:a z-index: auto; snippet zoo zoom: 1; +snippet :h + :hover +snippet :fc + :first-child +snippet :lc + :last-child +snippet :nc + :nth-child(${0}) +snippet :nlc + :nth-last-child(${0}) +snippet :oc + :only-child +snippet :a + :after +snippet :b + :before +snippet ::a + ::after +snippet ::b + ::before diff --git a/snippets/java.snippets b/snippets/java.snippets index 1595ffc..e0965f1 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -1,10 +1,10 @@ ## Access Modifiers snippet po - protected + protected ${0} snippet pu - public + public ${0} snippet pr - private + private ${0} ## ## Annotations snippet before @@ -25,7 +25,7 @@ snippet oo ## ## Basic Java packages and import snippet im - import + import ${0} snippet j.b java.beans. snippet j.i @@ -39,17 +39,17 @@ snippet j.u ## ## Class snippet cl - class ${1:`vim_snippets#Filename("", "untitled")`} ${0} + class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0} snippet in - interface ${1:`vim_snippets#Filename("", "untitled")`} ${2:extends Parent} + interface ${1:`vim_snippets#Filename("$1", "untitled")`} ${2:extends Parent} snippet tc - public class ${1:`vim_snippets#Filename()`} extends ${0:TestCase} + public class ${1:`vim_snippets#Filename("$1")`} extends ${0:TestCase} ## ## Class Enhancements snippet ext - extends + extends ${0} snippet imp - implements + implements ${0} ## ## Comments snippet /* @@ -89,15 +89,40 @@ snippet m snippet v ${1:String} ${2:var}${3: = null}${4}; ## +## Declaration for ArrayList +snippet d.al + List<${1:Object}> ${2:list} = new ArrayList<$1>();${0} +## Declaration for HashMap +snippet d.hm + Map<${1:Object}, ${2:Object}> ${3:map} = new HashMap<$1, $2>();${0} +## Declaration for HashSet +snippet d.hs + Set<${1:Object}> ${2:set} = new HashSet<$1>();${0} +## Declaration for Stack +snippet d.st + Stack<${1:Object}> ${2:stack} = new Stack<$1>();${0} +## +## Singleton Pattern +snippet singlet + private static class Holder { + private static final ${1:`vim_snippets#Filename("$1")`} INSTANCE = new $1(); + } + + private $1() { } + + private static $1 getInstance() { + return Holder.INSTANCE; + } +## ## Enhancements to Methods, variables, classes, etc. snippet ab - abstract + abstract ${0} snippet fi - final + final ${0} snippet st - static + static ${0} snippet sy - synchronized + synchronized ${0} ## ## Error Methods snippet err @@ -113,9 +138,9 @@ snippet as snippet ca catch(${1:Exception} ${2:e}) ${0} snippet thr - throw + throw ${0} snippet ths - throws + throws ${0} snippet try try { ${0} @@ -144,7 +169,7 @@ snippet @au snippet @br @brief ${0:Description} snippet @fi - @file ${0:`vim_snippets#Filename()`}.java + @file ${0:`vim_snippets#Filename("$1")`}.java snippet @pa @param ${0:param} snippet @re @@ -206,7 +231,7 @@ snippet get ## ## Terminate Methods or Loops snippet re - return + return ${0} snippet br break; ##