Browse Source

Wget all the snippets I care about from the ultisnips repository

master
Taylor Bockman 7 years ago
parent
commit
89ffb46117
  1. 6
      README.md
  2. 15
      dotfiles/config/nvim/init.vim
  3. 103
      dotfiles/config/nvim/snippets/all.snippets
  4. 99
      dotfiles/config/nvim/snippets/c.snippets
  5. 110
      dotfiles/config/nvim/snippets/cpp.snippets
  6. 493
      dotfiles/config/nvim/snippets/css.snippets
  7. 115
      dotfiles/config/nvim/snippets/go.snippets
  8. 244
      dotfiles/config/nvim/snippets/html.snippets
  9. 435
      dotfiles/config/nvim/snippets/java.snippets
  10. 51
      dotfiles/config/nvim/snippets/javascript-jsdoc.snippets
  11. 65
      dotfiles/config/nvim/snippets/javascript-node.snippets
  12. 140
      dotfiles/config/nvim/snippets/javascript.snippets
  13. 51
      dotfiles/config/nvim/snippets/json.snippets
  14. 92
      dotfiles/config/nvim/snippets/markdown.snippets
  15. 174
      dotfiles/config/nvim/snippets/ocaml.snippets
  16. 712
      dotfiles/config/nvim/snippets/python.snippets
  17. 178
      dotfiles/config/nvim/snippets/r.snippets
  18. 894
      dotfiles/config/nvim/snippets/rails.snippets
  19. 329
      dotfiles/config/nvim/snippets/ruby.snippets
  20. 106
      dotfiles/config/nvim/snippets/rust.snippets
  21. 99
      dotfiles/config/nvim/snippets/sh.snippets
  22. 16
      dotfiles/config/nvim/snippets/xml.snippets

6
README.md

@ -54,7 +54,7 @@ background to show the wallpaper. If you use sh instead of zsh, change it approp
3. i3
## Screen Locking
1. Physlock
1. Physlock
## Fonts
1. infinality-bundle
@ -70,3 +70,7 @@ background to show the wallpaper. If you use sh instead of zsh, change it approp
## Browsing
1. Google Chrome
# Neovim Configuration Notes
1. Make sure to run `:GoInstallBinaries` if you want to use `vim-go`. Make sure Go and `$GOPATH` are available.

15
dotfiles/config/nvim/init.vim

@ -53,6 +53,7 @@ Plug 'wavded/vim-stylus'
Plug 'raichoo/haskell-vim'
Plug 'OCamlPro/ocp-indent'
Plug 'slim-template/vim-slim'
Plug 'fatih/vim-go'
" Org Mode
Plug 'jceb/vim-orgmode'
@ -87,6 +88,20 @@ endif
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
" Snippet Support/Configuration
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
let g:UltiSnipsExpandTrigger="<c-s>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:UltiSnipsSnippetsDir="~/.config/nvim/snippets"
" Allow UltiSnips to split the window vertically
let g:UltiSnipssEditSplit="vertical"
"""""""""""""""""""""""""""""""
" end plugin list
call plug#end()

103
dotfiles/config/nvim/snippets/all.snippets

@ -0,0 +1,103 @@
# This file contains snippets that are always defined. I personally
# have snippets for signatures and often needed texts
# sligthly lower priority than everything else since specialized versions
# should overwrite. The user needs to adjust her priority in her snippets to
# ~-55 so that other filetypes will still overwrite.
priority -60
##############
# NICE BOXES #
##############
global !p
from vimsnippets import foldmarker, make_box, get_comment_format
endglobal
snippet box "A nice box with the current comment symbol" b
`!p
box = make_box(len(t[1]))
snip.rv = box[0]
snip += box[1]
`${1:${VISUAL:content}}`!p
box = make_box(len(t[1]))
snip.rv = box[2]
snip += box[3]`
$0
endsnippet
snippet bbox "A nice box over the full width" b
`!p
if not snip.c:
width = int(vim.eval("&textwidth - (virtcol('.') == 1 ? 0 : virtcol('.'))")) or 71
box = make_box(len(t[1]), width)
snip.rv = box[0]
snip += box[1]
`${1:${VISUAL:content}}`!p
box = make_box(len(t[1]), width)
snip.rv = box[2]
snip += box[3]`
$0
endsnippet
snippet fold "Insert a vim fold marker" b
`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = get_comment_format()[2]`
endsnippet
snippet foldc "Insert a vim fold close marker" b
`!p snip.rv = get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = get_comment_format()[2]`
endsnippet
snippet foldp "Insert a vim fold marker pair" b
`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = get_comment_format()[2]`
${2:${VISUAL:Content}}
`!p snip.rv = get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = get_comment_format()[2]`
endsnippet
##########################
# LOREM IPSUM GENERATORS #
##########################
snippet lorem "Lorem Ipsum - 50 Words" b
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
endsnippet
##########################
# VIM MODELINE GENERATOR #
##########################
# See advice on `:help 'tabstop'` for why these values are set. Uses second
# modeline form ('set') to work in languages with comment terminators
# (/* like C */).
snippet modeline "Vim modeline"
vim`!v ':set '. (&expandtab ? printf('et sw=%i ts=%i', &sw, &ts) : printf('noet sts=%i sw=%i ts=%i', &sts, &sw, &ts)) . (&tw ? ' tw='. &tw : '') . ':'`
endsnippet
#########
# DATES #
#########
snippet date "YYYY-MM-DD" w
`!v strftime("%F")`
endsnippet
snippet ddate "Month DD, YYYY" w
`!v strftime("%b %d, %Y")`
endsnippet
snippet diso "ISO format datetime" w
`!v strftime("%F %H:%M:%S%z")`
endsnippet
snippet time "hh:mm" w
`!v strftime("%H:%M")`
endsnippet
snippet datetime "YYYY-MM-DD hh:mm" w
`!v strftime("%Y-%m-%d %H:%M")`
endsnippet
snippet todo "TODO comment" bw
`!p snip.rv=get_comment_format()[0]` ${2:TODO}: $0${3: <${4:`!v strftime('%d-%m-%y')`}${5:, `!v g:snips_author`}>} `!p snip.rv=get_comment_format()[2]`
endsnippet
# vim:ft=snippets:

99
dotfiles/config/nvim/snippets/c.snippets

@ -0,0 +1,99 @@
###########################################################################
# TextMate Snippets #
###########################################################################
priority -50
snippet def "#define ..."
#define $1
endsnippet
snippet #ifndef "#ifndef ... #define ... #endif"
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
#define ${1:SYMBOL} ${2:value}
#endif /* ifndef $1 */
endsnippet
snippet #if "#if #endif" b
#if ${1:0}
${VISUAL}$0
#endif
endsnippet
snippet mark "#pragma mark (mark)"
#if 0
${1:#pragma mark -
}#pragma mark $2
#endif
$0
endsnippet
snippet main "main() (main)"
int main(int argc, char *argv[])
{
${VISUAL}$0
return 0;
}
endsnippet
snippet for "for loop (for)"
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
${VISUAL}$0
}
endsnippet
snippet fori "for int loop (fori)"
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
${VISUAL}$0
}
endsnippet
snippet once "Include header once only guard"
#ifndef ${1:`!p
if not snip.c:
import random, string
name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper()
rand = ''.join(random.sample(string.ascii_letters+string.digits, 8))
snip.rv = ('%s_%s' % (name,rand)).upper()
else:
snip.rv = snip.c`}
#define $1
${VISUAL}$0
#endif /* end of include guard: $1 */
endsnippet
snippet fprintf "fprintf ..."
fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet
snippet eli "else if .. (eli)"
else if (${1:/* condition */}) {
${VISUAL}$0
}
endsnippet
snippet printf "printf .. (printf)"
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet
snippet st "struct"
struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} {
${0:/* data */}
};
endsnippet
snippet fun "function" b
${1:void} ${2:function_name}($3)
{
${VISUAL}$0
}
endsnippet
snippet fund "function declaration" b
${1:void} ${2:function_name}($3);
endsnippet
# vim:ft=snippets:

110
dotfiles/config/nvim/snippets/cpp.snippets

@ -0,0 +1,110 @@
priority -50
extends c
# We want to overwrite everything in parent ft.
priority -49
###########################################################################
# Global functions #
###########################################################################
global !p
def write_docstring_args(arglist, snip):
args = str(arglist).split(',')
if len(args) > 1:
c = 0
for arg in args:
if c == 0:
snip.rv += arg
c = 1
else:
snip += '* : %s' % arg.strip()
else:
snip.rv = args[0]
endglobal
###########################################################################
# TextMate Snippets #
###########################################################################
snippet beginend "$1.begin(), $1.end() (beginend)"
${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), $1${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end()
endsnippet
snippet cl "class .. (class)"
class ${1:`!p snip.rv = snip.basename or "name"`}
{
public:
${1/(\w+).*/$1/} (${2:arguments});
virtual ~${1/(\w+).*/$1/} ();
private:
${0:/* data */}
};
endsnippet
snippet ns "namespace .. (namespace)"
namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`}
{
${VISUAL}$0
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
endsnippet
snippet readfile "read file (readF)"
std::vector<char> v;
if (FILE *fp = fopen(${1:"filename"}, "r"))
{
char buf[1024];
while(size_t len = fread(buf, 1, sizeof(buf), fp))
v.insert(v.end(), buf, buf + len);
fclose(fp);
}
endsnippet
snippet map "std::map (map)"
std::map<${1:key}, ${2:value}> map$0;
endsnippet
snippet vector "std::vector (v)"
std::vector<${1:char}> v$0;
endsnippet
snippet tp "template <typename ..> (template)"
template <typename ${1:_InputIter}>
endsnippet
snippet cla "An entire .h generator" b
#ifndef ${2:`!v substitute(vim_snippets#Filename('$1_H','ClassName'),'.*','\U&\E','')`}
#define $2
class ${1:`!v substitute(substitute(vim_snippets#Filename('$1','ClassName'),'^.','\u&',''), '_\(\w\)', '\u\1', 'g')`}
{
private:
$3
public:
$1();
virtual ~$1();
};
#endif /* $2 */
endsnippet
snippet fnc "Basic c++ doxygen function template" b
/**
* @brief: ${4:brief}
*
* @param: `!p write_docstring_args(t[3],snip)`
*
* @return: `!p snip.rv = t[1]`
*/
${1:ReturnType} ${2:FunctionName}(${3:param})
{
${0:FunctionBody}
}
endsnippet
# vim:ft=snippets:

493
dotfiles/config/nvim/snippets/css.snippets

@ -0,0 +1,493 @@
priority -50
snippet p "padding"
padding: ${1:0};$0
endsnippet
snippet m "margin"
margin: ${1:0};$0
endsnippet
snippet bd "border"
border: ${1:0};$0
endsnippet
snippet d "display"
display: ${1:none};$0
endsnippet
snippet bg "background"
background: ${1:none};$0
endsnippet
snippet ff "font-family"
font-family: ${1:"Helvetica Neue", Helvetica, Arial, sans-serif};$0
endsnippet
snippet h "height"
height: ${1:auto};$0
endsnippet
snippet w "width"
width: ${1:auto};$0
endsnippet
snippet pos "position"
position: ${1:relative};$0
endsnippet
snippet tt "text-transform"
text-transform: ${1:none};$0
endsnippet
snippet ! "!important CSS (!)"
!important
endsnippet
snippet tsh "text-shadow: color-hex x y blur (text)"
text-shadow: ${1:${2:color} ${3:offset-x} ${4:offset-y} ${5:blur}};$0
endsnippet
snippet bxsh "box-shadow: color-hex x y blur (text)"
box-shadow: ${1:${2:offset-x} ${3:offset-y} ${4:blur} ${5:spread} ${6:color}};$0
endsnippet
#
# Colors
#
snippet rgb "color rgb"
rgb(${1:255}, ${2:255}, ${3:255})$0
endsnippet
snippet rgba "color rgba"
rgba(${1:255}, ${2:255}, ${3:255}, ${4:0.5})$0
endsnippet
snippet hsl "color hsl"
hsl(${1:360}, ${2:100}%, ${3:100}%)$0
endsnippet
snippet hsla "color hsla"
hsla(${1:360}, ${2:100}%, ${3:100}%, ${4:0.5})$0
endsnippet
#
# Selectors
#
snippet :fc
:first-child
endsnippet
snippet :lc
:last-child
endsnippet
snippet :nc
:nth-child($0)
endsnippet
snippet :nlc
:nth-last-child($0)
endsnippet
snippet :oc
:only-child
endsnippet
#
# Pseudo-elements
#
snippet :a
:after
endsnippet
snippet :b
:before
endsnippet
snippet ::a
::after
endsnippet
snippet ::b
::before
endsnippet
###########################################################################
# Most of these came from TextMate #
###########################################################################
snippet background "background-attachment: scroll:fixed (background)"
background-attachment: ${1:scroll/fixed};$0
endsnippet
snippet background "background-color: color-hex (background)"
background-color: #${1:DDD};$0
endsnippet
snippet background "background-color: color-name (background)"
background-color: ${1:red};$0
endsnippet
snippet background "background-color: color-rgb (background)"
background-color: rgb(${1:255},${2:255},${3:255});$0
endsnippet
snippet background "background-color: transparent (background)"
background-color: transparent;$0
endsnippet
snippet background "background-image: none (background)"
background-image: none;$0
endsnippet
snippet background "background-image: url (background)"
background-image: url($1);$0
endsnippet
snippet background "background-position: position (background)"
background-position: ${1:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0
endsnippet
snippet background "background-repeat: r:r-x:r-y:n-r (background)"
background-repeat: ${1:repeat/repeat-x/repeat-y/no-repeat};$0
endsnippet
snippet background "background: color image repeat attachment position (background)"
background:${6: #${1:DDD}} url($2) ${3:repeat/repeat-x/repeat-y/no-repeat} ${4:scroll/fixed} ${5:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0
endsnippet
snippet border "border-bottom-color: size style color (border)"
border-bottom-color: #${1:999};$0
endsnippet
snippet border "border-bottom-style: size style color (border)"
border-bottom-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-bottom-width: size style color (border)"
border-bottom-width: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-bottom: size style color (border)"
border-bottom: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-color: color (border)"
border-color: ${1:999};$0
endsnippet
snippet border "border-left-color: color (border)"
border-right-color: #${1:999};$0
endsnippet
snippet border "border-left-style: style (border)"
border-left-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-left-width: size (border)"
border-left-width: ${1:1}px
endsnippet
snippet border "border-left: size style color (border)"
border-left: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-right-color: color (border)"
border-right-color: #${1:999};$0
endsnippet
snippet border "border-right-style: style (border)"
border-right-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-right-width: size (border)"
border-right-width: ${1:1}px
endsnippet
snippet border "border-right: size style color (border)"
border-right: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-style: style (border)"
border-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-top-color: color (border)"
border-top-color: #${1:999};$0
endsnippet
snippet border "border-top-style: style (border)"
border-top-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-top-width: size (border)"
border-top-width: ${1:1}px
endsnippet
snippet border "border-top: size style color (border)"
border-top: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-width: width (border)"
border-width: ${1:1px};$0
endsnippet
snippet border "border: size style color (border)"
border: ${1:1px} ${2:solid} #${3:999};$0
endsnippet
snippet clear "clear: value (clear)"
clear: ${1:left/right/both/none};$0
endsnippet
snippet color "color: color-hex (color)"
color: #${1:DDD};$0
endsnippet
snippet color "color: color-name (color)"
color: ${1:red};$0
endsnippet
snippet color "color: color-rgb (color)"
color: rgb(${1:255},${2:255},${3:255});$0
endsnippet
snippet cursor "cursor: type (cursor)"
cursor: ${1:default/auto/crosshair/pointer/move/*-resize/text/wait/help};$0
endsnippet
snippet cursor "cursor: url (cursor)"
cursor: url($1);$0
endsnippet
snippet direction "direction: ltr|rtl (direction)"
direction: ${1:ltr|rtl};$0
endsnippet
snippet display "display: block (display)"
display: block;$0
endsnippet
snippet display "display: common-types (display)"
display: ${1:none/inline/block/list-item/run-in/compact/marker};$0
endsnippet
snippet display "display: inline (display)"
display: inline;$0
endsnippet
snippet display "display: table-types (display)"
display: ${1:table/inline-table/table-row-group/table-header-group/table-footer-group/table-row/table-column-group/table-column/table-cell/table-caption};$0
endsnippet
snippet float "float: left:right:none (float)"
float: ${1:left/right/none};$0
endsnippet
snippet font "font-family: family (font)"
font-family: ${1:Arial, "MS Trebuchet"}, ${2:sans-}serif;$0
endsnippet
snippet font "font-size: size (font)"
font-size: ${1:100%};$0
endsnippet
snippet font "font-style: normal:italic:oblique (font)"
font-style: ${1:normal/italic/oblique};$0
endsnippet
snippet font "font-variant: normal:small-caps (font)"
font-variant: ${1:normal/small-caps};$0
endsnippet
snippet font "font-weight: weight (font)"
font-weight: ${1:normal/bold};$0
endsnippet
snippet font "font: style variant weight size:line-height font -family (font)"
font: ${1:normal/italic/oblique} ${2:normal/small-caps} ${3:normal/bold} ${4:1em/1.5em} ${5:Arial}, ${6:sans-}serif;$0
endsnippet
snippet font "font: size font (font)"
font: ${1:75%} ${2:"Lucida Grande", "Trebuchet MS", Verdana,} ${3:sans-}serif;$0
endsnippet
snippet letter "letter-spacing: length-em (letter)"
letter-spacing: $1em;$0
endsnippet
snippet letter "letter-spacing: length-px (letter)"
letter-spacing: $1px;$0
endsnippet
snippet list "list-style-image: url (list)"
list-style-image: url($1);$0
endsnippet
snippet list "list-style-position: pos (list)"
list-style-position: ${1:inside/outside};$0
endsnippet
snippet list "list-style-type: asian (list)"
list-style-type: ${1:cjk-ideographic/hiragana/katakana/hiragana-iroha/katakana-iroha};$0
endsnippet
snippet list "list-style-type: marker(list)"
list-style-type: ${1:none/disc/circle/square};$0
endsnippet
snippet list "list-style-type: numeric (list)"
list-style-type: ${1:decimal/decimal-leading-zero/zero};$0
endsnippet
snippet list "list-style-type: other (list)"
list-style-type: ${1:hebrew/armenian/georgian};$0
endsnippet
snippet list "list-style-type: roman-alpha-greek (list)"
list-style-type: ${1:lower-roman/upper-roman/lower-alpha/upper-alpha/lower-greek/lower-latin/upper-latin};$0
endsnippet
snippet list "list-style: type position image (list)"
list-style: ${1:none/disc/circle/square/decimal/zero} ${2:inside/outside} url($3);$0
endsnippet
snippet margin "margin-bottom: length (margin)"
margin-bottom: ${1:20px};$0
endsnippet
snippet margin "margin-left: length (margin)"
margin-left: ${1:20px};$0
endsnippet
snippet margin "margin-right: length (margin)"
margin-right: ${1:20px};$0
endsnippet
snippet margin "margin-top: length (margin)"
margin-top: ${1:20px};$0
endsnippet
snippet margin "margin: all (margin)"
margin: ${1:20px};$0
endsnippet
snippet margin "margin: T R B L (margin)"
margin: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0
endsnippet
snippet margin "margin: V H (margin)"
margin: ${1:20px} ${2:0px};$0
endsnippet
snippet marker "marker-offset: auto (marker)"
marker-offset: auto;$0
endsnippet
snippet marker "marker-offset: length (marker)"
marker-offset: ${1:10px};$0
endsnippet
snippet overflow "overflow: type (overflow)"
overflow: ${1:visible/hidden/scroll/auto};$0
endsnippet
snippet padding "padding-bottom: length (margin)"
padding-bottom: ${1:20px};$0
endsnippet
snippet padding "padding-left: length (margin)"
padding-left: ${1:20px};$0
endsnippet
snippet padding "padding-right: length (margin)"
padding-right: ${1:20px};$0
endsnippet
snippet padding "padding-top: length (margin)"
padding-top: ${1:20px};$0
endsnippet
snippet padding "padding: T R B L (padding)"
padding: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0
endsnippet
snippet padding "padding: V H (padding)"
padding: ${1:20px} ${2:0px};$0
endsnippet
snippet padding "padding: all (padding)"
padding: ${1:20px};$0
endsnippet
snippet position "position: type (position)"
position: ${1:static/relative/absolute/fixed};$0
endsnippet
snippet { "properties { } ( } )"
{
/* $1 */
$0
endsnippet
snippet scrollbar "scrollbar"
scrollbar-base-color: ${1:#CCCCCC};${2:
scrollbar-arrow-color: ${3:#000000};
scrollbar-track-color: ${4:#999999};
scrollbar-3dlight-color: ${5:#EEEEEE};
scrollbar-highlight-color: ${6:#FFFFFF};
scrollbar-face-color: ${7:#CCCCCC};
scrollbar-shadow-color: ${9:#999999};
scrollbar-darkshadow-color: ${8:#666666};}
endsnippet
snippet selection "selection"
$1::-moz-selection,
$1::selection {
color: ${2:inherit};
background: ${3:inherit};
}
endsnippet
snippet text "text-align: left:center:right (txt)"
text-align: ${1:left/right/center/justify};$0
endsnippet
snippet text "text-decoration: none:underline:overline:line-through:blink (text)"
text-decoration: ${1:none/underline/overline/line-through/blink};$0
endsnippet
snippet text "text-indent: length (text)"
text-indent: ${1:10}px;$0
endsnippet
snippet text "text-transform: capitalize:upper:lower (text)"
text-transform: ${1:capitalize/uppercase/lowercase};$0
endsnippet
snippet vertical "vertical-align: type (vertical)"
vertical-align: ${1:baseline/sub/super/top/text-top/middle/bottom/text-bottom/length/%};$0
endsnippet
snippet visibility "visibility: type (visibility)"
visibility: ${1:visible/hidden/collapse};$0
endsnippet
snippet white "white-space: normal:pre:nowrap (white)"
white-space: ${1:normal/pre/nowrap};$0
endsnippet
snippet word "word-spacing: length (word)"
word-spacing: ${1:10px};$0
endsnippet
snippet z "z-index: index (z)"
z-index: $1;$0
endsnippet
# vim:ft=snippets:

115
dotfiles/config/nvim/snippets/go.snippets

@ -0,0 +1,115 @@
# Snippets for Go
priority -50
# when to abbriviate and when not?
# b doesn't work here, because it ignores whitespace
# optional local name?
snippet /^import/ "Import declaration" r
import (
"${1:package}"
)
endsnippet
snippet /^package/ "Package declaration" r
// Package $1 provides ...
package ${1:main}
endsnippet
# Mostly converted from: https://github.com/AlanQuatermain/go-tmbundle
snippet /^cons/ "Constants declaration" r
const (
${1:constant}${2/(.+)/ /}${2:type} = ${0:value}
)
endsnippet
snippet /^con/ "Constant declaration" r
const ${1:name}${2/(.+)/ /}${2:type} = ${0:value}
endsnippet
snippet iota "Iota constant generator" b
const (
${1:constant}${2/(.+)/ /}${2:type} = iota
)
endsnippet
snippet struct "Struct declaration" b
type ${1:Struct} struct {
${0:${VISUAL}}
}
endsnippet
snippet interface "Interface declaration" b
type ${1:Interface} interface {
${0:${VISUAL}}
}
endsnippet
snippet if "If statement" b
if ${1:condition}${1/(.+)/ /}{
${0:${VISUAL}}
}
endsnippet
snippet switch "Switch statement" b
switch ${1:expression}${1/(.+)/ /}{
case$0
}
endsnippet
# functions
snippet /^main/ "Main function" r
func main() {
${0:${VISUAL}}
}
endsnippet
snippet /^meth/ "Method" r
func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} {
${0:${VISUAL}}
}
endsnippet
snippet func "Function" b
func ${1:name}(${2:params})${3/(.+)/ /}${3:type} {
${0:${VISUAL}}
}
endsnippet
snippet funch "HTTP handler" b
func ${1:handler}(${2:w} http.ResponseWriter, ${3:r} *http.Request) {
${0:${VISUAL}}
}
endsnippet
# types and variables
snippet map "Map type" b
map[${1:keytype}]${2:valtype}
endsnippet
snippet : "Variable declaration :=" b
${1:name} := ${0:value}
endsnippet
snippet var "Variable declaration" b
var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}}
endsnippet
snippet vars "Variables declaration" b
var (
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
)
endsnippet
snippet json "JSON field"
\`json:"${1:displayName}"\`
endsnippet
# vim:ft=snippets:
# error handling
snippet err "Basic error handling" b
if err != nil {
log.${1:Fatal}(err)
}
endsnippet

244
dotfiles/config/nvim/snippets/html.snippets

@ -0,0 +1,244 @@
priority -50
###########################################################################
# TextMate Snippets #
###########################################################################
global !p
def x(snip):
if snip.ft.startswith("x"):
snip.rv = '/'
else:
snip.rv = ""
endglobal
snippet doctype "HTML - 5.0 (doctype)" b
<!DOCTYPE html>
endsnippet
#############
# Shortcuts #
#############
snippet down "Down (down)"
&#x2193;
endsnippet
snippet enter "Enter (enter)"
&#x2305;
endsnippet
snippet escape "Escape (escape)"
&#x238B;
endsnippet
snippet shift "Shift (shift)"
&#x21E7;
endsnippet
snippet tab "Tab (tab)"
&#x21E5;
endsnippet
snippet up "Up (up)"
&#x2191;
endsnippet
snippet return "Return (return)"
&#x21A9;
endsnippet
snippet right "Right (right)"
&#x2192;
endsnippet
snippet left "Left (left)"
&#x2190;
endsnippet
#############
# HTML TAGS #
#############
snippet input "Input with Label" w
<label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}`!p x(snip)`>
endsnippet
snippet input "HTML <input>" w
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}`!p x(snip)`>
endsnippet
snippet option "Option" w
<option${1: value="${2:option}"}>${3:$2}</option>
endsnippet
snippet select "Select Box" w
<select name="${1:some_name}" id="${2:$1}"${3:${4: multiple}${5: onchange="${6:}"}${7: size="${8:1}"}}>
${0:${VISUAL}}
</select>
endsnippet
snippet textarea "HTML <textarea>" w
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea>
endsnippet
snippet mailto "HTML <a mailto: >" w
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
endsnippet
snippet base "HTML <base>" w
<base href="$1"${2: target="$3"}`!p x(snip)`>
endsnippet
snippet body "<body>"
<body>
${0:${VISUAL}}
</body>
endsnippet
snippet div "<div>" w
<div>
${0:${VISUAL}}
</div>
endsnippet
snippet div. "<div> with class" w
<div`!p snip.rv=' class="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""`>
${0:${VISUAL}}
</div>
endsnippet
snippet div# "<div> with ID & class" w
<div`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""``!p snip.rv=' class="' if t[2] else ""`${2:name}`!p snip.rv = '"' if t[2] else ""`>
${0:${VISUAL}}
</div>
endsnippet
snippet form "XHTML <form>" w
<form action="${1:`!p
snip.rv = (snip.basename or 'unnamed') + '_submit'
`}" method="${2:get}" accept-charset="utf-8">
${0:${VISUAL}}
</form>
endsnippet
snippet h1 "XHTML <h1>" w
<h1>${0:${VISUAL}}</h1>
endsnippet
snippet h2 "XHTML <h2>" w
<h2>${0:${VISUAL}}</h2>
endsnippet
snippet h3 "XHTML <h3>" w
<h3>${0:${VISUAL}}</h3>
endsnippet
snippet h4 "XHTML <h4>" w
<h4>${0:${VISUAL}}</h4>
endsnippet
snippet h5 "XHTML <h5>" w
<h5>${0:${VISUAL}}</h5>
endsnippet
snippet h6 "XHTML <h6>" w
<h6>${0:${VISUAL}}</h6>
endsnippet
snippet head "XHTML <head>"
<head>
<meta charset="utf-8">
<title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title>
${0:${VISUAL}}
</head>
endsnippet
snippet link "XHTML <link>" w
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"`!p x(snip)`>
endsnippet
snippet meta "XHTML <meta>" w
<meta name="${1:name}" content="${2:content}"`!p x(snip)`>
endsnippet
snippet scriptsrc "HTML <script src...>" w
<script src="$1" charset="${3:utf-8}"></script>
endsnippet
snippet script "HTML <script>" w
<script charset="utf-8">
${0:${VISUAL}}
</script>
endsnippet
snippet span "<span>" w
<span> ${0:${VISUAL}} </span>
endsnippet
snippet span. "<span> with class" w
<span`!p snip.rv=' class="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""`> ${0:${VISUAL}} </span>
endsnippet
snippet span# "<span> with ID & class" w
<span`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""``!p snip.rv=' class="' if t[2] else ""`${2:name}`!p snip.rv = '"' if t[2] else ""`> ${0:${VISUAL}} </span>
endsnippet
snippet style "XHTML <style>" w
<style type="text/css" media="screen">
${0:${VISUAL}}
</style>
endsnippet
snippet table "XHTML <table>" w
<table>
${0:${VISUAL}}
</table>
endsnippet
snippet a "Link" w
<a href="${1:http://www.${2:url.com}}"${3: target="_blank"}>${4:Anchor Text}</a>
endsnippet
snippet p "paragraph" w
<p>${0:${VISUAL}}</p>
endsnippet
snippet li "list item" w
<li>${0:${VISUAL}}</li>
endsnippet
snippet ul "unordered list" w
<ul>
${0:${VISUAL}}
</ul>
endsnippet
snippet td "table cell" w
<td>${0:${VISUAL}}</td>
endsnippet
snippet th "table header" w
<th>${0:${VISUAL}}</th>
endsnippet
snippet tr "table row" w
<tr>${0:${VISUAL}}</tr>
endsnippet
snippet title "XHTML <title>" w
<title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title>
endsnippet
snippet fieldset "Fieldset" w
<fieldset id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}" ${2:class="${3:}"}>
<legend>$1</legend>
${0:${VISUAL}}
</fieldset>
endsnippet
snippet viewport "Responsive viewport meta" w
<meta name="viewport" content="width=device-width, initial-scale=1">
endsnippet
# vim:ft=snippets:

435
dotfiles/config/nvim/snippets/java.snippets

@ -0,0 +1,435 @@
priority -50
# Many of the snippets here use a global option called
# "g:ultisnips_java_brace_style" which, if set to "nl" will put a newline
# before '{' braces.
# Setting "g:ultisnips_java_junit" will change how the test method snippet
# looks, it is defaulted to junit4, setting this option to 3 will remove the
# @Test annotation from the method
global !p
def junit(snip):
if snip.opt("g:ultisnips_java_junit", "") == "3":
snip += ""
else:
snip.rv += "@Test\n\t"
def nl(snip):
if snip.opt("g:ultisnips_java_brace_style", "") == "nl":
snip += ""
else:
snip.rv += " "
def getArgs(group):
import re
word = re.compile('[a-zA-Z0-9><.]+ \w+')
return [i.split(" ") for i in word.findall(group) ]
def camel(word):
if not word: return ''
return word[0].upper() + word[1:]
def mixedCase(word):
if not word: return ''
return word[0].lower() + word[1:]
endglobal
snippet sleep "try sleep catch" b
try {
Thread.sleep(${1:1000});
} catch (InterruptedException e){
e.printStackTrace();
}
endsnippet
snippet /i|n/ "new primitive or int" br
${1:int} ${2:i} = ${3:1};
$0
endsnippet
snippet /o|v/ "new Object or variable" br
${1:Object} ${2:var} = new $1($3);
endsnippet
snippet f "field" b
${1:private} ${2:String} ${3:`!p snip.rv = t[2].lower()`};
endsnippet
snippet ab "abstract" b
abstract $0
endsnippet
snippet as "assert" b
assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};
endsnippet
snippet at "assert true" b
assertTrue(${1:actual});
endsnippet
snippet af "assert false" b
assertFalse(${1:actual});
endsnippet
snippet ae "assert equals" b
assertEquals(${1:expected}, ${2:actual});
endsnippet
snippet br "break"
break;
endsnippet
snippet cs "case" b
case $1:
$2
$0
endsnippet
snippet ca "catch" b
catch (${1:Exception} ${2:e})`!p nl(snip)`{
$0
}
endsnippet
snippet cle "class extends" b
public class ${1:`!p
snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements ${5:Interface} }{
$0
}
endsnippet
snippet clc "class with constructor, fields, setter and getters" b
public class `!p
snip.rv = snip.basename or "untitled"` {
`!p
args = getArgs(t[1])
if len(args) == 0: snip.rv = ""
for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) {`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] + ";"
if len(args) == 0:
snip.rv += "\n"`
}$0
`!p
args = getArgs(t[1])
if len(args) == 0: snip.rv = ""
for i in args:
snip.rv += "\n\tpublic void set" + camel(i[1]) + "(" + i[0] + " " + i[1] + ") {\n" + "\
\tthis." + i[1] + " = " + i[1] + ";\n\t}\n"
snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\n\
\treturn " + i[1] + ";\n\t}\n"
`
}
endsnippet
snippet clc "class with constructor, with field names" b
public class `!p
snip.rv = snip.basename or "untitled"` {
`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) {`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1])
if len(args) == 0:
snip.rv += "\n"`
}
}
endsnippet
snippet clc "class and constructor" b
public class `!p
snip.rv = snip.basename or "untitled"` {
public `!p snip.rv = snip.basename or "untitled"`($2) {
$0
}
}
endsnippet
snippet cl "class" b
public class ${1:`!p
snip.rv = snip.basename or "untitled"`} {
$0
}
endsnippet
snippet cos "constant string" b
public static final String ${1:var} = "$2";$0
endsnippet
snippet co "constant" b
public static final ${1:String} ${2:var} = $3;$0
endsnippet
snippet de "default" b
default:
$0
endsnippet
snippet elif "else if"
else if ($1)`!p nl(snip)`{
$0${VISUAL}
}
endsnippet
snippet el "else" w
else`!p nl(snip)`{
$0${VISUAL}
}
endsnippet
snippet fi "final" b
final $0
endsnippet
snippet fore "for (each)" b
for ($1 : $2)`!p nl(snip)`{
$0
}
endsnippet
snippet fori "for" b
for (int ${1:i} = 0; $1 < ${2:10}; $1++)`!p nl(snip)`{
$0
}
endsnippet
snippet for "for" b
for ($1; $2; $3)`!p nl(snip)`{
$0
}
endsnippet
snippet if "if" b
if ($1)`!p nl(snip)`{
$0${VISUAL}
}
endsnippet
snippet imt "import junit_framework_TestCase;" b
import junit.framework.TestCase;
$0
endsnippet
snippet im "import" b
import ${1:java}.${2:util}.$0;
endsnippet
snippet in "interface" b
interface ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }{
$0
}
endsnippet
snippet cc "constructor call or setter body"
this.${1:var} = $1;
endsnippet
snippet list "Collections List" b
List<${1:String}> ${2:list} = new ${3:Array}List<$1>();
endsnippet
snippet map "Collections Map" b
Map<${1:String}, ${2:String}> ${3:map} = new ${4:Hash}Map<$1, $2>();
endsnippet
snippet set "Collections Set" b
Set<${1:String}> ${2:set} = new ${3:Hash}Set<$1>();
endsnippet
snippet /Str?|str/ "String" br
String $0
endsnippet
snippet cn "Constructor" b
public `!p snip.rv = snip.basename or "untitled"`(${1:}) {
$0
}
endsnippet
snippet cn "constructor, \w fields + assigments" b
`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) {`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1])
if len(args) == 0:
snip.rv += "\n"`
}
endsnippet
snippet j.b "java_beans_" i
java.beans.
endsnippet
snippet j.i "java_io" i
java.io.
endsnippet
snippet j.m "java_math" i
java.math.
endsnippet
snippet j.n "java_net_" i
java.net.
endsnippet
snippet j.u "java_util_" i
java.util.
endsnippet
snippet main "method (main)" b
public static void main(String[] args)`!p nl(snip)`{
$0
}
endsnippet
snippet try "try/catch" b
try {
$1${VISUAL}
} catch(${2:Exception} ${3:e}){
${4:e.printStackTrace();}
}
endsnippet
snippet mt "method throws" b
${1:private} ${2:void} ${3:method}($4) ${5:throws $6 }{
$0
}
endsnippet
snippet m "method" b
${1:private} ${2:void} ${3:method}($4) {
$0
}
endsnippet
snippet md "Method With javadoc" b
/**
* ${7:Short Description}`!p
for i in getArgs(t[4]):
snip.rv += "\n\t * @param " + i[1] + " usage..."`
*`!p
if "throws" in t[5]:
snip.rv = "\n\t * @throws " + t[6]
else:
snip.rv = ""``!p
if not "void" in t[2]:
snip.rv = "\n\t * @return object"
else:
snip.rv = ""`
**/
${1:public} ${2:void} ${3:method}($4) ${5:throws $6 }{
$0
}
endsnippet
snippet /get(ter)?/ "getter" br
public ${1:String} get${2:Name}() {
return `!p snip.rv = mixedCase(t[2])`;
}
endsnippet
snippet /set(ter)?/ "setter" br
public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
}
endsnippet
snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br
public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
}`!p snip.rv += "\n"`
public $2 get$1() {
return `!p snip.rv = mixedCase(t[1])`;
}
endsnippet
snippet pa "package" b
package $0
endsnippet
snippet p "print" b
System.out.print($1);$0
endsnippet
snippet pl "println" b
System.out.println($1);$0
endsnippet
snippet pr "private" b
private $0
endsnippet
snippet po "protected" b
protected $0
endsnippet
snippet pu "public" b
public $0
endsnippet
snippet re "return" b
return $0
endsnippet
snippet st "static"
static $0
endsnippet
snippet sw "switch" b
switch ($1)`!p nl(snip)`{
case $2: $0
}
endsnippet
snippet sy "synchronized"
synchronized $0
endsnippet
snippet tc "test case"
public class ${1:`!p snip.rv = snip.basename or "untitled"`} extends ${2:TestCase}`!p nl(snip)`{
$0
}
endsnippet
snippet t "test" b
`!p junit(snip)`public void test${1:Name}() {
$0
}
endsnippet
snippet tt "test throws" b
`!p junit(snip)`public void test${1:Name}() ${2:throws Exception }{
$0
}
endsnippet
snippet th "throw" b
throw new $0
endsnippet
snippet wh "while" b
while ($1)`!p nl(snip)`{
$0
}
endsnippet
# vim:ft=snippets:

51
dotfiles/config/nvim/snippets/javascript-jsdoc.snippets

@ -0,0 +1,51 @@
priority -50
# JSDoc snippets
snippet /* "A JSDoc comment" b
/**
* ${1:${VISUAL}}$0
*/
endsnippet
snippet @au "@author email (First Last)"
@author ${1:`!v g:snips_author`} [${2:`!v g:snips_author_email`}]
endsnippet
snippet @li "@license Description"
@license ${1:MIT}$0
endsnippet
snippet @ver "@version Semantic version"
@version ${1:0.1.0}$0
endsnippet
snippet @fileo "@fileoverview Description" b
/**
* @fileoverview ${1:${VISUAL:A description of the file}}$0
*/
endsnippet
snippet @constr "@constructor"
@constructor
endsnippet
snippet @p "@param {Type} varname Description"
@param {${1:Type}} ${2:varname} ${3:Description}
endsnippet
snippet @ret "@return {Type} Description"
@return {${1:Type}} ${2:Description}
endsnippet
snippet @pri "@private"
@private
endsnippet
snippet @over "@override"
@override
endsnippet
snippet @pro "@protected"
@protected
endsnippet

65
dotfiles/config/nvim/snippets/javascript-node.snippets

@ -0,0 +1,65 @@
priority -50
snippet #! "shebang"
#!/usr/bin/env node
endsnippet
snippet vreq "assign a CommonJS-style module to a var"
var ${0:${1/(.+\/)*(\w+)(-|\b|$)(\..+$)?/\u$2/g}} = require('$1');
endsnippet
snippet ex "module.exports"
module.exports = $1;
endsnippet
snippet hcs "http.createServer"
http.createServer($1).listen($2);
endsnippet
snippet ncs "net.createServer"
net.createServer(function(${1:socket}){
$1.on('data', function(${3:data}){
$4
});
$1.on('end', function(){
$5
});
}).listen(${6:8124});
endsnippet
snippet pipe "pipe"
pipe(${1:stream})$2
endsnippet
# Express snippets
snippet eget "express GET"
${1:app}.get('$2', $3);
endsnippet
snippet epost "express POST"
${1:app}.post('$2', $3);
endsnippet
snippet eput "express PUT"
${1:app}.put('$2', $3);
endsnippet
snippet edelete "express DELETE"
${1:app}.delete('$2', $3);
endsnippet
# process snippets
snippet stdout "stdout"
process.stdout
endsnippet
snippet stdin "stdin"
process.stdin
endsnippet
snippet stderr "stderr"
process.stderr
endsnippet

140
dotfiles/config/nvim/snippets/javascript.snippets

@ -0,0 +1,140 @@
priority -50
############
# COMMON #
############
# The smart snippets use a global options called
# "g:ultisnips_javascript.{option}" which can control the format
# of trailing semicolon, space before function paren, etc.
global !p
from javascript_snippets import (
semi, space_before_function_paren, keyword_spacing
)
endglobal
###########################################################################
# TextMate Snippets #
###########################################################################
snippet get "Get Elements"
getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2')
endsnippet
snippet '':f "object method string"
'${1:${2:#thing}:${3:click}}': function`!p snip.rv = space_before_function_paren(snip)`(element) {
${VISUAL}$0
}${10:,}
endsnippet
snippet :f "Object Method"
${1:method_name}: function`!p snip.rv = space_before_function_paren(snip)`(${3:attribute}) {
${VISUAL}$0
}${10:,}
endsnippet
snippet :, "Object Value JS"
${1:value_name}: ${0:value},
endsnippet
snippet : "Object key key: 'value'"
${1:key}: ${2:"${3:value}"}${4:, }
endsnippet
snippet proto "Prototype (proto)"
${1:class_name}.prototype.${2:method_name} = function`!p snip.rv = space_before_function_paren(snip)`(${3:first_argument}) {
${VISUAL}$0
}`!p snip.rv = semi(snip)`
endsnippet
snippet fun "function (fun)" w
function ${1:function_name}`!p snip.rv = space_before_function_paren(snip)`(${2:argument}) {
${VISUAL}$0
}
endsnippet
snippet vf "Function assigned to var"
${1:var }${2:function_name} = function $2`!p snip.rv = space_before_function_paren(snip)`($3) {
${VISUAL}$0
}`!p snip.rv = semi(snip)`
endsnippet
snippet af "Anonymous Function" i
function`!p snip.rv = space_before_function_paren(snip)`($1) {
${VISUAL}$0
}
endsnippet
snippet iife "Immediately-Invoked Function Expression (iife)"
(function`!p snip.rv = space_before_function_paren(snip)`(${1:window}) {
${VISUAL}$0
}(${2:$1}))`!p snip.rv = semi(snip)`
endsnippet
snippet ;fe "Minify safe iife"
;(function`!p snip.rv = space_before_function_paren(snip)`(${1}) {
${VISUAL}$0
}(${2}))
endsnippet
snippet timeout "setTimeout function"
setTimeout(function`!p snip.rv = space_before_function_paren(snip)`() {
${VISUAL}$0
}${2:.bind(${3:this})}, ${1:10})`!p snip.rv = semi(snip)`
endsnippet
snippet fi "for prop in obj using hasOwnProperty" b
for`!p snip.rv = keyword_spacing(snip)`(${1:prop} in ${2:obj}){
if`!p snip.rv = keyword_spacing(snip)`($2.hasOwnProperty($1)) {
${VISUAL}$0
}
}
endsnippet
snippet if "if (condition) { ... }"
if`!p snip.rv = keyword_spacing(snip)`(${1:true}) {
${VISUAL}$0
}
endsnippet
snippet ife "if (condition) { ... } else { ... }"
if`!p snip.rv = keyword_spacing(snip)`(${1:true}) {
${VISUAL}$0
}`!p snip.rv = keyword_spacing(snip)`else`!p snip.rv = keyword_spacing(snip)`{
${2}
}
endsnippet
snippet switch
switch`!p snip.rv = keyword_spacing(snip)`(${VISUAL}${1:expression}) {
case '${VISUAL}${3:case}':
${4}
break`!p snip.rv = semi(snip)`
${0}
default:
${2}
}
endsnippet
snippet case "case 'xyz': ... break"
case`!p snip.rv = keyword_spacing(snip)`'${VISUAL}${1:case}':
${VISUAL}$0
break`!p snip.rv = semi(snip)`
endsnippet
snippet do "do { ... } while (condition)"
do`!p snip.rv = keyword_spacing(snip)`{
${VISUAL}$0
}`!p snip.rv = keyword_spacing(snip)`while`!p snip.rv = keyword_spacing(snip)`(${1:/* condition */})`!p snip.rv = semi(snip)`
endsnippet
snippet ret "Return statement"
return ${VISUAL}$0`!p snip.rv = semi(snip)`
endsnippet
snippet us
'use strict'`!p snip.rv = semi(snip)`
endsnippet
# vim:ft=snippets:

51
dotfiles/config/nvim/snippets/json.snippets

@ -0,0 +1,51 @@
priority -50
snippet s "String" b
"${1:key}": "${0:value}",
endsnippet
snippet n "Number" b
"${1:key}": ${0:value},
endsnippet
snippet a "Array" b
[
${VISUAL}$0
],
endsnippet
snippet na "Named array" b
"${1:key}": [
${VISUAL}$0
],
endsnippet
snippet o "Object" b
{
${VISUAL}$0
},
endsnippet
snippet no "Named object" b
"${1:key}": {
${VISUAL}$0
},
endsnippet
snippet null "Null" b
"${0:key}": null,
endsnippet
global !p
def compB(t, opts):
if t:
opts = [m[len(t):] for m in opts if m.startswith(t)]
if len(opts) == 1:
return opts[0]
return "(" + '|'.join(opts) + ')'
endglobal
snippet b "Bool" b
"${1:key}": $2`!p snip.rv=compB(t[2], ['true', 'false'])`,
endsnippet

92
dotfiles/config/nvim/snippets/markdown.snippets

@ -0,0 +1,92 @@
priority -50
global !p
def create_table(snip):
# retrieving single line from current string and treat it like tabstops count
placeholders_string = snip.buffer[snip.line].strip().split("x",1)
rows_amount = int(placeholders_string[0])
columns_amount = int(placeholders_string[1])
# erase current line
snip.buffer[snip.line] = ''
# create anonymous snippet with expected content and number of tabstops
anon_snippet_title = ' | '.join(['$' + str(col) for col in range(1,columns_amount+1)]) + "\n"
anon_snippet_delimiter = ':-|' * (columns_amount-1) + ":-\n"
anon_snippet_body = ""
for row in range(1,rows_amount+1):
anon_snippet_body += ' | '.join(['$' + str(row*columns_amount+col) for col in range(1,columns_amount+1)]) + "\n"
anon_snippet_table = anon_snippet_title + anon_snippet_delimiter + anon_snippet_body
# expand anonymous snippet
snip.expand_anon(anon_snippet_table)
endglobal
###########################
# Sections and Paragraphs #
###########################
snippet sec "Section" b
# ${1:Section Name} #
$0
endsnippet
snippet ssec "Sub Section" b
## ${1:Section Name} ##
$0
endsnippet
snippet sssec "SubSub Section" b
### ${1:Section Name} ###
$0
endsnippet
snippet par "Paragraph" b
#### ${1:Paragraph Name} ####
$0
endsnippet
snippet spar "Paragraph" b
##### ${1:Paragraph Name} #####
$0
endsnippet
################
# Common stuff #
################
snippet link "Link to something"
[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0
endsnippet
snippet img "Image"
![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0
endsnippet
snippet ilc "Inline Code" i
\`$1\`$0
endsnippet
snippet cbl "Codeblock" b
\`\`\`
$1
\`\`\`
$0
endsnippet
snippet refl "Reference Link"
[${1:${VISUAL:Text}}][${2:id}]$0
[$2]:${4:http://${3:www.url.com}} "${5:$4}"
endsnippet
snippet fnt "Footnote"
[^${1:${VISUAL:Footnote}}]$0
[^$1]:${2:Text}
endsnippet
post_jump "create_table(snip)"
snippet "tb(\d+x\d+)" "Customizable table" br
`!p snip.rv = match.group(1)`
endsnippet
# vim:ft=snippets:

174
dotfiles/config/nvim/snippets/ocaml.snippets

@ -0,0 +1,174 @@
priority -50
snippet rs "raise" b
raise (${1:Not_found})
endsnippet
snippet open "open"
let open ${1:module} in
${2:e}
endsnippet
snippet try "try"
try ${1:e}
with ${2:Not_found} -> ${3:()}
endsnippet
snippet ref "ref"
let ${1:name} = ref ${2:val} in
${3:e}
endsnippet
snippet matchl "pattern match on a list"
match ${1:list} with
| [] -> ${2:()}
| x::xs -> ${3:()}
endsnippet
snippet matcho "pattern match on an option type"
match ${1:x} with
| Some(${2:y}) -> ${3:()}
| None -> ${4:()}
endsnippet
snippet fun "anonymous function"
(fun ${1:x} -> ${2:x})
endsnippet
snippet cc "commment"
(* ${1:comment} *)
endsnippet
snippet let "let .. in binding"
let ${1:x} = ${2:v} in
${3:e}
endsnippet
snippet lr "let rec"
let rec ${1:f} =
${2:expr}
endsnippet
snippet if "if"
if ${1:(* condition *)} then
${2:(* A *)}
else
${3:(* B *)}
endsnippet
snippet If "If"
if ${1:(* condition *)} then
${2:(* A *)}
endsnippet
snippet while "while"
while ${1:(* condition *)} do
${2:(* A *)}
done
endsnippet
snippet for "for"
for ${1:i} = ${2:1} to ${3:10} do
${4:(* BODY *)}
done
endsnippet
snippet match "match"
match ${1:(* e1 *)} with
| ${2:p} -> ${3:e2}
endsnippet
snippet Match "match"
match ${1:(* e1 *)} with
| ${2:p} -> ${3:e2}
endsnippet
snippet class "class"
class ${1:name} = object
${2:methods}
end
endsnippet
snippet obj "obj"
object
${2:methods}
end
endsnippet
snippet Obj "object"
object (self)
${2:methods}
end
endsnippet
snippet {{ "object functional update"
{< ${1:x} = ${2:y} >}
endsnippet
snippet beg "beg"
begin
${1:block}
end
endsnippet
snippet ml "module instantiantion with functor"
module ${1:Mod} = ${2:Functor}(${3:Arg})
endsnippet
snippet mod "module - no signature"
module ${1:(* Name *)} = struct
${2:(* BODY *)}
end
endsnippet
snippet Mod "module with signature"
module ${1:(* Name *)} : ${2:(* SIG *)} = struct
${3:(* BODY *)}
end
endsnippet
snippet sig "anonymous signature"
sig
${2:(* BODY *)}
end
endsnippet
snippet sigf "functor signature or anonymous functor"
functor (${1:Arg} : ${2:ARG}) -> ${3:(* BODY *)}
endsnippet
snippet func "define functor - no signature"
module ${1:M} (${2:Arg} : ${3:ARG}) = struct
${4:(* BODY *)}
end
endsnippet
snippet Func "define functor - with signature"
module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct
${5:(* BODY *)}
end
endsnippet
snippet mot "Declare module signature"
module type ${1:(* Name *)} = sig
${2:(* BODY *)}
end
endsnippet
snippet module "Module with anonymous signature"
module ${1:(* Name *)} : sig
${2:(* SIGNATURE *)}
end = struct
${3:(* BODY *)}
end
endsnippet
snippet oo "odoc"
(** ${1:odoc} *)
endsnippet
snippet qt "inline qtest"
(*$T ${1:name}
${2:test}
*)
endsnippet

712
dotfiles/config/nvim/snippets/python.snippets

@ -0,0 +1,712 @@
priority -50
###########################################################################
# TEXTMATE SNIPPETS #
###########################################################################
#! header
snippet #! "Shebang header for python scripts" b
#!/usr/bin/env python
# -*- coding: utf-8 -*-
$0
endsnippet
snippet ifmain "ifmain" b
if __name__ == `!p snip.rv = get_quoting_style(snip)`__main__`!p snip.rv = get_quoting_style(snip)`:
${1:${VISUAL:main()}}
endsnippet
snippet with "with" b
with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}:
${3:${VISUAL:pass}}
$0
endsnippet
snippet for "for loop" b
for ${1:item} in ${2:iterable}:
${3:${VISUAL:pass}}
endsnippet
##########
# COMMON #
##########
# The smart def and smart class snippets use a global option called
# "g:ultisnips_python_style" which, if set to "doxygen" will use doxygen
# style comments in docstrings.
global !p
NORMAL = 0x1
DOXYGEN = 0x2
SPHINX = 0x3
GOOGLE = 0x4
NUMPY = 0x5
JEDI = 0x6
SINGLE_QUOTES = "'"
DOUBLE_QUOTES = '"'
class Arg(object):
def __init__(self, arg):
self.arg = arg
self.name = arg.split('=')[0].strip()
def __str__(self):
return self.name
def __unicode__(self):
return self.name
def is_kwarg(self):
return '=' in self.arg
def get_args(arglist):
args = [Arg(arg) for arg in arglist.split(',') if arg]
args = [arg for arg in args if arg.name != 'self']
return args
def get_quoting_style(snip):
style = snip.opt("g:ultisnips_python_quoting_style", "double")
if style == 'single':
return SINGLE_QUOTES
return DOUBLE_QUOTES
def triple_quotes(snip):
style = snip.opt("g:ultisnips_python_triple_quoting_style")
if not style:
return get_quoting_style(snip) * 3
return (SINGLE_QUOTES if style == 'single' else DOUBLE_QUOTES) * 3
def triple_quotes_handle_trailing(snip, quoting_style):
"""
Generate triple quoted strings and handle any trailing quote char,
which might be there from some autoclose/autopair plugin,
i.e. when expanding ``"|"``.
"""
if not snip.c:
# Do this only once, otherwise the following error would happen:
# RuntimeError: The snippets content did not converge: …
_, col = vim.current.window.cursor
line = vim.current.line
# Handle already existing quote chars after the trigger.
_ret = quoting_style * 3
while True:
try:
nextc = line[col]
except IndexError:
break
if nextc == quoting_style and len(_ret):
_ret = _ret[1:]
col = col+1
else:
break
snip.rv = _ret
else:
snip.rv = snip.c
def get_style(snip):
style = snip.opt("g:ultisnips_python_style", "normal")
if style == "doxygen": return DOXYGEN
elif style == "sphinx": return SPHINX
elif style == "google": return GOOGLE
elif style == "numpy": return NUMPY
elif style == "jedi": return JEDI
else: return NORMAL
def format_arg(arg, style):
if style == DOXYGEN:
return "@param %s TODO" % arg
elif style == SPHINX:
return ":param %s: TODO" % arg
elif style == NORMAL:
return ":%s: TODO" % arg
elif style == GOOGLE:
return "%s (TODO): TODO" % arg
elif style == JEDI:
return ":type %s: TODO" % arg
elif style == NUMPY:
return "%s : TODO" % arg
def format_return(style):
if style == DOXYGEN:
return "@return: TODO"
elif style in (NORMAL, SPHINX, JEDI):
return ":returns: TODO"
elif style == GOOGLE:
return "Returns: TODO"
def write_docstring_args(args, snip):
if not args:
snip.rv += ' {0}'.format(triple_quotes(snip))
return
snip.rv += '\n' + snip.mkline('', indent='')
style = get_style(snip)
if style == GOOGLE:
write_google_docstring_args(args, snip)
elif style == NUMPY:
write_numpy_docstring_args(args, snip)
else:
for arg in args:
snip += format_arg(arg, style)
def write_google_docstring_args(args, snip):
kwargs = [arg for arg in args if arg.is_kwarg()]
args = [arg for arg in args if not arg.is_kwarg()]
if args:
snip += "Args:"
snip.shift()
for arg in args:
snip += format_arg(arg, GOOGLE)
snip.unshift()
snip.rv += '\n' + snip.mkline('', indent='')
if kwargs:
snip += "Kwargs:"
snip.shift()
for kwarg in kwargs:
snip += format_arg(kwarg, GOOGLE)
snip.unshift()
snip.rv += '\n' + snip.mkline('', indent='')
def write_numpy_docstring_args(args, snip):
if args:
snip += "Parameters"
snip += "----------"
kwargs = [arg for arg in args if arg.is_kwarg()]
args = [arg for arg in args if not arg.is_kwarg()]
if args:
for arg in args:
snip += format_arg(arg, NUMPY)
if kwargs:
for kwarg in kwargs:
snip += format_arg(kwarg, NUMPY) + ', optional'
snip.rv += '\n' + snip.mkline('', indent='')
def write_init_body(args, parents, snip):
parents = [p.strip() for p in parents.split(",")]
parents = [p for p in parents if p != 'object']
for p in parents:
snip += p + ".__init__(self)"
if parents:
snip.rv += '\n' + snip.mkline('', indent='')
for arg in args:
snip += "self._%s = %s" % (arg, arg)
def write_slots_args(args, snip):
args = ['"_%s"' % arg for arg in args]
snip += '__slots__ = (%s,)' % ', '.join(args)
def write_function_docstring(t, snip):
"""
Writes a function docstring with the current style.
:param t: The values of the placeholders
:param snip: UltiSnips.TextObjects.SnippetUtil object instance
"""
snip.rv = ""
snip >> 1
args = get_args(t[2])
if args:
write_docstring_args(args, snip)
style = get_style(snip)
if style == NUMPY:
snip += 'Returns'
snip += '-------'
snip += 'TODO'
else:
snip += format_return(style)
snip.rv += '\n' + snip.mkline('', indent='')
snip += triple_quotes(snip)
def get_dir_and_file_name(snip):
return os.getcwd().split(os.sep)[-1] + '.' + snip.basename
endglobal
########################################
# Class & Special Method Name Snippets #
########################################
snippet class "class with docstrings" b
class ${1:MyClass}(${2:object}):
`!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`
def __init__(self$4):
`!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined1.}`!p
snip.rv = ""
snip >> 2
args = get_args(t[4])
write_docstring_args(args, snip)
if args:
snip.rv += '\n' + snip.mkline('', indent='')
snip += '{0}'.format(triple_quotes(snip))
write_init_body(args, t[2], snip)
`
$0
endsnippet
snippet slotclass "class with slots and docstrings" b
class ${1:MyClass}(${2:object}):
`!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`
`!p
snip >> 1
args = get_args(t[4])
write_slots_args(args, snip)
`
def __init__(self$4):
`!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined.}`!p
snip.rv = ""
snip >> 2
args = get_args(t[4])
write_docstring_args(args, snip)
if args:
snip.rv += '\n' + snip.mkline('', indent='')
snip += triple_quotes(snip)
write_init_body(args, t[2], snip)
`
$0
endsnippet
snippet contain "methods for emulating a container type" b
def __len__(self):
${1:pass}
def __getitem__(self, key):
${2:pass}
def __setitem__(self, key, value):
${3:pass}
def __delitem__(self, key):
${4:pass}
def __iter__(self):
${5:pass}
def __reversed__(self):
${6:pass}
def __contains__(self, item):
${7:pass}
endsnippet
snippet context "context manager methods" b
def __enter__(self):
${1:pass}
def __exit__(self, exc_type, exc_value, traceback):
${2:pass}
endsnippet
snippet attr "methods for customizing attribute access" b
def __getattr__(self, name):
${1:pass}
def __setattr__(self, name, value):
${2:pass}
def __delattr__(self, name):
${3:pass}
endsnippet
snippet desc "methods implementing descriptors" b
def __get__(self, instance, owner):
${1:pass}
def __set__(self, instance, value):
${2:pass}
def __delete__(self, instance):
${3:pass}
endsnippet
snippet cmp "methods implementing rich comparison"
def __eq__(self, other):
${1:pass}
def __ne__(self, other):
${2:pass}
def __lt__(self, other):
${3:pass}
def __le__(self, other):
${4:pass}
def __gt__(self, other):
${5:pass}
def __ge__(self, other):
${6:pass}
def __cmp__(self, other):
${7:pass}
endsnippet
snippet repr "methods implementing string representation"
def __repr__(self):
${1:pass}
def __str__(self):
${2:pass}
def __unicode__(self):
${3:pass}
endsnippet
# note: reflected operands and augmented arithmeitc assignements have been
# intentionally ommited to reduce verbosity.
snippet numeric "methods for emulating a numeric type" b
def __add__(self, other):
${1:pass}
def __sub__(self, other):
${2:pass}
def __mul__(self, other):
${3:pass}
def __div__(self, other):
${4:pass}
def __truediv__(self, other):
${5:pass}
def __floordiv__(self, other):
${6:pass}
def __mod__(self, other):
${7:pass}
def __divmod__(self, other):
${8:pass}
def __pow__(self, other):
${9:pass}
def __lshift__(self, other):
${10:pass}
def __rshift__(self, other):
${11:pass}
def __and__(self, other):
${12:pass}
def __xor__(self, other):
${13:pass}
def __or__(self, other):
${14:pass}
def __neg__(self):
${15:pass}
def __pos__(self):
${16:pass}
def __abs__(self):
${17:pass}
def __invert__(self):
${18:pass}
def __complex__(self):
${19:pass}
def __int__(self):
${20:pass}
def __long__(self):
${21:pass}
def __float__(self):
${22:pass}
def __oct__(self):
${22:pass}
def __hex__(self):
${23:pass}
def __index__(self):
${24:pass}
def __coerce__(self, other):
${25:pass}
endsnippet
snippet deff
def ${1:fname}(`!p snip.rv = vim.eval('indent(".") ? "self" : ""')`$2):
$0
endsnippet
snippet def "function with docstrings" b
def ${1:function}(`!p
if snip.indent:
snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}):
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
write_function_docstring(t, snip) `
${5:${VISUAL:pass}}
endsnippet
snippet defc "class method with docstrings" b
@classmethod
def ${1:function}(`!p
if snip.indent:
snip.rv = 'cls' + (", " if len(t[2]) else "")`${2:arg1}):
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
write_function_docstring(t, snip) `
${5:${VISUAL:pass}}
endsnippet
snippet defs "static method with docstrings" b
@staticmethod
def ${1:function}(${2:arg1}):
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
write_function_docstring(t, snip) `
${5:${VISUAL:pass}}
endsnippet
# doesn't expand when there is a word in front
snippet /(^|(?<=\W))\./ "self." r
self.
endsnippet
snippet from "from module import name" b
from ${1:module} import ${2:Stuff}
endsnippet
##############
# PROPERTIES #
##############
snippet roprop "Read Only Property" b
@property
def ${1:name}(self):
${2:return self._$1}$0
endsnippet
snippet rwprop "Read write property" b
def ${1:name}():
`!p snip.rv = triple_quotes(snip) if t[2] else ''
`${2:TODO: Docstring for $1.}`!p
if t[2]:
snip >> 1
style = get_style(snip)
snip.rv += '\n' + snip.mkline('', indent='')
snip += format_return(style)
snip.rv += '\n' + snip.mkline('', indent='')
snip += triple_quotes(snip)
else:
snip.rv = ""`
def fget(self):
return self._$1$0
def fset(self, value):
self._$1 = value
return locals()
$1 = property(**$1(), doc=$1.__doc__)
endsnippet
####################
# If / Else / Elif #
####################
snippet if "If" b
if ${1:condition}:
${2:${VISUAL:pass}}
endsnippet
snippet ife "If / Else" b
if ${1:condition}:
${2:${VISUAL:pass}}
else:
${3:pass}
endsnippet
snippet ifee "If / Elif / Else" b
if ${1:condition}:
${2:${VISUAL:pass}}
elif ${3:condition}:
${4:pass}
else:
${5:pass}
endsnippet
##########################
# Try / Except / Finally #
##########################
snippet try "Try / Except" b
try:
${1:${VISUAL:pass}}
except ${2:Exception} as ${3:e}:
${4:raise $3}
endsnippet
snippet trye "Try / Except / Else" b
try:
${1:${VISUAL:pass}}
except ${2:Exception} as ${3:e}:
${4:raise $3}
else:
${5:pass}
endsnippet
snippet tryf "Try / Except / Finally" b
try:
${1:${VISUAL:pass}}
except ${2:Exception} as ${3:e}:
${4:raise $3}
finally:
${5:pass}
endsnippet
snippet tryef "Try / Except / Else / Finally" b
try:
${1:${VISUAL:pass}}
except${2: ${3:Exception} as ${4:e}}:
${5:raise}
else:
${6:pass}
finally:
${7:pass}
endsnippet
######################
# Assertions & Tests #
######################
snippet ae "Assert equal" b
self.assertEqual(${1:${VISUAL:first}},${2:second})
endsnippet
snippet at "Assert True" b
self.assertTrue(${1:${VISUAL:expression}})
endsnippet
snippet af "Assert False" b
self.assertFalse(${1:${VISUAL:expression}})
endsnippet
snippet aae "Assert almost equal" b
self.assertAlmostEqual(${1:${VISUAL:first}},${2:second})
endsnippet
snippet ar "Assert raises" b
self.assertRaises(${1:exception}, ${2:${VISUAL:func}}${3/.+/, /}${3:arguments})
endsnippet
snippet an "Assert is None" b
self.assertIsNone(${1:${VISUAL:expression}})
endsnippet
snippet ann "Assert is not None" b
self.assertIsNotNone(${1:${VISUAL:expression}})
endsnippet
snippet testcase "pyunit testcase" b
class Test${1:Class}(${2:unittest.TestCase}):
`!p snip.rv = triple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = triple_quotes(snip)`
def setUp(self):
${4:pass}
def tearDown(self):
${5:pass}
def test_${6:name}(self):
${7:${VISUAL:pass}}
endsnippet
snippet " "triple quoted string (double quotes)" b
"""
${1:${VISUAL:doc}}
`!p triple_quotes_handle_trailing(snip, '"')`
endsnippet
snippet ' "triple quoted string (single quotes)" b
'''
${1:${VISUAL:doc}}
`!p triple_quotes_handle_trailing(snip, "'")`
endsnippet
snippet doc "doc block (triple quotes)"
`!p snip.rv = triple_quotes(snip)`
${1:${VISUAL:doc}}
`!p snip.rv = triple_quotes(snip)`
endsnippet
snippet pmdoc "pocoo style module doc string" b
# -*- coding: utf-8 -*-
"""
`!p snip.rv = get_dir_and_file_name(snip)`
`!p snip.rv = '~' * len(get_dir_and_file_name(snip))`
${1:DESCRIPTION}
:copyright: (c) `date +%Y` by ${2:YOUR_NAME}.
:license: ${3:LICENSE_NAME}, see LICENSE for more details.
"""
$0
endsnippet
# vim:ft=snippets:

178
dotfiles/config/nvim/snippets/r.snippets

@ -0,0 +1,178 @@
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
snippet req "Require a file"
require(${0:package})
endsnippet
snippet source "Source a file"
source('${0:file}')
endsnippet
snippet if "If statement"
if ($1) {
$0
}
endsnippet
snippet eif "Else-If statement"
else if ($1) {
$0
}
endsnippet
snippet el "Else statement"
else {
$0
}
endsnippet
snippet ife "if .. else"
if ($1) {
$2
} else {
$3
}
endsnippet
snippet wh "while loop"
while($1) {
$2
}
endsnippet
snippet for "for loop"
for (${1:item} in ${2:list}) {
$3
}
endsnippet
snippet fun "Function definition"
${1:name} <- function ($2) {
$0
}
endsnippet
snippet ret "Return call"
return($0)
endsnippet
snippet df "Data frame"
${1:name}[${2:rows}, ${0:cols}]
endsnippet
snippet c "c function"
c(${0:items})
endsnippet
snippet li "list function"
list(${0:items})
endsnippet
snippet mat "matrix function"
matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols})
endsnippet
snippet apply "apply function"
apply(${1:array}, ${2:margin}, ${0:function})
endsnippet
snippet lapply "lapply function"
lapply(${1:list}, ${0:function})
endsnippet
snippet sapply "sapply function"
sapply(${1:list}, ${0:function})
endsnippet
snippet vapply "vapply function"
vapply(${1:list}, ${2:function}, ${0:type})
endsnippet
snippet mapply "mapply function"
mapply(${1:function}, ${0:...})
endsnippet
snippet tapply "tapply function"
tapply(${1:vector}, ${2:index}, ${0:function})
endsnippet
snippet rapply "rapply function"
rapply(${1:list}, ${0:function})
endsnippet
snippet pl "Plot function"
plot(${1:x}, ${0:y})
endsnippet
snippet ggp "ggplot2 plot"
ggplot(${1:data}, aes(${0:aesthetics}))
endsnippet
snippet fis "Fisher test"
fisher.test(${1:x}, ${0:y})
endsnippet
snippet chi "Chi Squared test"
chisq.test(${1:x}, ${0:y})
endsnippet
snippet tt "t-test"
t.test(${1:x}, ${0:y})
endsnippet
snippet wil "Wilcox test"
wilcox.test(${1:x}, ${0:y})
endsnippet
snippet cor "Correlation test"
cor.test(${1:x}, ${0:y})
endsnippet
snippet fte "FTE test"
var.test(${1:x}, ${0:y})
endsnippet
snippet kvt "KV test"
kv.test(${1:x}, ${0:y})
endsnippet

894
dotfiles/config/nvim/snippets/rails.snippets

@ -0,0 +1,894 @@
priority -50
snippet anaf "accepts_nested_attributes_for"
accepts_nested_attributes_for :${1:association_name}${2:${3:, :allow_destroy => true}${4:, :reject_if => proc \{ |obj| ${5:obj.blank?} \}}}
endsnippet
snippet tcbi "Create binary column"
t.binary :${1:title}${2:, :limit => ${3:2}.megabytes}
$0
endsnippet
snippet tcb "Create boolean column"
t.boolean :${1:title}
$0
endsnippet
snippet clac "Create controller class"
class ${1:Model}Controller < ApplicationController
before_filter :find_${2:model}
$0
private
def find_$2
@$2 = ${3:$1}.find(params[:id]) if params[:id]
end
end
endsnippet
snippet tcda "Create date column"
t.date :${1:title}
$0
endsnippet
snippet tcdt "Create datetime column"
t.datetime :${1:title}
$0
endsnippet
snippet tcd "Create decimal column"
t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}}
$0
endsnippet
snippet tcf "Create float column"
t.float :${1:title}
$0
endsnippet
snippet clact "Create functional test class"
require 'test_helper'
class ${1:Model}ControllerTest < ActionController::TestCase
test$0
end
endsnippet
snippet tci "Create integer column"
t.integer :${1:title}
$0
endsnippet
snippet tcl "Create lock_version column"
t.integer :lock_version, :null => false, :default => 0
$0
endsnippet
# FIXME: handling literal bracket pair inside of nested tab groups?
snippet tcr "Create references column"
t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}}
$0
endsnippet
snippet resources "Create resources controller class"
class ${1:Model}sController < ApplicationController
before_filter :find_${1/./\l$0/}, :only => [:show, :edit, :update, :destroy]
# GET /${1/./\l$0/}s
# GET /${1/./\l$0/}s.xml
def index
@${1/./\l$0/}s = ${1:Model}.all
respond_to do |wants|
wants.html # index.html.erb
wants.xml { render :xml => @${1/./\l$0/}s }
end
end
# GET /${1/./\l$0/}s/1
# GET /${1/./\l$0/}s/1.xml
def show
respond_to do |wants|
wants.html # show.html.erb
wants.xml { render :xml => @${1/./\l$0/} }
end
end
# GET /${1/./\l$0/}s/new
# GET /${1/./\l$0/}s/new.xml
def new
@${1/./\l$0/} = ${1:Model}.new
respond_to do |wants|
wants.html # new.html.erb
wants.xml { render :xml => @${1/./\l$0/} }
end
end
# GET /${1/./\l$0/}s/1/edit
def edit
end
# POST /${1/./\l$0/}s
# POST /${1/./\l$0/}s.xml
def create
@${1/./\l$0/} = ${1:Model}.new(params[:${1/./\l$0/}])
respond_to do |wants|
if @${1/./\l$0/}.save
flash[:notice] = '${1:Model} was successfully created.'
wants.html { redirect_to(@${1/./\l$0/}) }
wants.xml { render :xml => @${1/./\l$0/}, :status => :created, :location => @${1/./\l$0/} }
else
wants.html { render :action => "new" }
wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity }
end
end
end
# PUT /${1/./\l$0/}s/1
# PUT /${1/./\l$0/}s/1.xml
def update
respond_to do |wants|
if @${1/./\l$0/}.update(params[:${1/./\l$0/}])
flash[:notice] = '${1:Model} was successfully updated.'
wants.html { redirect_to(@${1/./\l$0/}) }
wants.xml { head :ok }
else
wants.html { render :action => "edit" }
wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /${1/./\l$0/}s/1
# DELETE /${1/./\l$0/}s/1.xml
def destroy
@${1/./\l$0/}.destroy
respond_to do |wants|
wants.html { redirect_to(${1/./\l$0/}s_url) }
wants.xml { head :ok }
end
end
private
def find_${1/./\l$0/}
@${1/./\l$0/} = ${1:Model}.find(params[:id])
end
end
endsnippet
snippet tcs "Create string column"
t.string :${1:title}
$0
endsnippet
snippet tct "Create text column"
t.text :${1:title}
$0
endsnippet
snippet tcti "Create time column"
t.time :${1:title}
$0
endsnippet
snippet tcts "Create timestamp column"
t.timestamp :${1:title}
$0
endsnippet
snippet tctss "Create timestamps columns"
t.timestamps
$0
endsnippet
snippet mcol "Migration Create Column (mcc)"
t.column ${1:title}, :${2:string}
$0
endsnippet
snippet mccc "Migration Create Column Continue (mccc)"
t.column ${1:title}, :${2:string}
mccc$0
endsnippet
snippet mtab "Migration Drop Create Table (mdct)"
drop_table :${1:table}${2: [press tab twice to generate create_table]}
endsnippet
snippet mcol "Migration Remove and Add Column (mrac)"
remove_column :${1:table}, :${2:column}${3: [press tab twice to generate add_column]}
endsnippet
snippet rdb "RAILS_DEFAULT_LOGGER.debug (rdb)"
RAILS_DEFAULT_LOGGER.debug "${1:message}"$0
endsnippet
snippet tre "Table column(s) rename"
t.rename(:${1:old_column_name}, :${2:new_column_name})
$0
endsnippet
snippet art "Test Assert Redirected To (art)"
assert_redirected_to ${2::action => "${1:index}"}
endsnippet
snippet asre "Test Assert Response (are)"
assert_response :${1:success}, @response.body$0
endsnippet
snippet aftc "after_create"
after_create $0
endsnippet
snippet aftd "after_destroy"
after_destroy $0
endsnippet
snippet afts "after_save"
after_save $0
endsnippet
snippet aftu "after_update"
after_update $0
endsnippet
snippet aftv "after_validation"
after_validation $0
endsnippet
snippet aftvoc "after_validation_on_create"
after_validation_on_create $0
endsnippet
snippet aftvou "after_validation_on_update"
after_validation_on_update $0
endsnippet
snippet asg "assert(var = assigns(:var))"
assert(${1:var} = assigns(:$1), "Cannot find @$1")
$0
endsnippet
snippet asd "assert_difference"
assert_difference "${1:Model}.${2:count}", ${3:1} do
$0
end
endsnippet
snippet asnd "assert_no_difference"
assert_no_difference "${1:Model}.${2:count}" do
$0
end
endsnippet
snippet artnpp "assert_redirected_to (nested path plural)"
assert_redirected_to ${10:${2:parent}_${3:child}_path(${4:@}${5:$2})}
endsnippet
snippet artnp "assert_redirected_to (nested path)"
assert_redirected_to ${2:${12:parent}_${13:child}_path(${14:@}${15:$12}, ${16:@}${17:$13})}
endsnippet
snippet artpp "assert_redirected_to (path plural)"
assert_redirected_to ${10:${2:model}s_path}
endsnippet
snippet artp "assert_redirected_to (path)"
assert_redirected_to ${2:${12:model}_path(${13:@}${14:$12})}
endsnippet
snippet asrj "assert_rjs"
assert_rjs :${1:replace}, ${2:"${3:dom id}"}
endsnippet
snippet ass "assert_select"
assert_select '${1:path}'${2:, :${3:text} => ${4:'${5:inner_html}'}}${6: do
$0
end}
endsnippet
snippet befc "before_create"
before_create $0
endsnippet
snippet befd "before_destroy"
before_destroy $0
endsnippet
snippet befs "before_save"
before_save $0
endsnippet
snippet befu "before_update"
before_update $0
endsnippet
snippet befv "before_validation"
before_validation $0
endsnippet
snippet befvoc "before_validation_on_create"
before_validation_on_create $0
endsnippet
snippet befvou "before_validation_on_update"
before_validation_on_update
endsnippet
snippet bt "belongs_to (bt)"
belongs_to :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:$1_id}"}
endsnippet
snippet crw "cattr_accessor"
cattr_accessor :${0:attr_names}
endsnippet
snippet defcreate "def create - resource"
def create
@${1:model} = ${2:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}.new(params[:$1])
$0
respond_to do |wants|
if @$1.save
flash[:notice] = '$2 was successfully created.'
wants.html { redirect_to(@$1) }
wants.xml { render :xml => @$1, :status => :created, :location => @$1 }
else
wants.html { render :action => "new" }
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
end
end
end
endsnippet
snippet test "test do..end"
test "${1:something interesting}" do
$0
end
endsnippet
snippet deftg "def get request"
def test_should_get_${1:action}
${2:@${3:model} = ${4:$3s}(:${5:fixture_name})
}get :$1${6:, :id => @$3.to_param}
assert_response :success
$0
end
endsnippet
snippet deftp "def post request"
def test_should_post_${1:action}
${3:@$2 = ${4:$2s}(:${5:fixture_name})
}post :$1${6:, :id => @$2.to_param}, :${2:model} => { $0 }
assert_response :redirect
end
endsnippet
snippet fina "find(:all)"
find(:all${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]})
endsnippet
snippet finf "find(:first)"
find(:first${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]})
endsnippet
snippet fini "find(id)"
find(${1:id})
endsnippet
snippet fine "find_each"
find_each(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}|
$0
end
endsnippet
snippet finb "find_in_batches"
find_in_batches(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}s|
$4s.each do |$4|
$0
end
end
endsnippet
snippet habtm "has_and_belongs_to_many (habtm)"
has_and_belongs_to_many :${1:object}${2:, :join_table => "${3:table_name}", :foreign_key => "${4:$1_id}"}
endsnippet
snippet hm "has_many (hm)"
has_many :${1:object}s${2:, :class_name => "$1", :foreign_key => "${4:reference}_id"}
endsnippet
snippet hmt "has_many (through)"
has_many :${1:objects}, :through => :${2:join_association}${3:, :source => :${4:$2_table_foreign_key_to_$1_table}}
endsnippet
snippet hmd "has_many :dependent => :destroy"
has_many :${1:object}s${2:, :class_name => "$1", :foreign_key => "${4:reference}_id"}, :dependent => :destroy$0
endsnippet
snippet ho "has_one (ho)"
has_one :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:$1_id}"}
endsnippet
snippet logd "logger.debug"
${1:Rails.}logger.debug { "${1:message}" }$0
endsnippet
snippet loge "logger.error"
logger.error { "${1:message}" }$0
endsnippet
snippet logf "logger.fatal"
logger.fatal { "${1:message}" }$0
endsnippet
snippet logi "logger.info"
logger.info { "${1:message}" }$0
endsnippet
snippet logw "logger.warn"
logger.warn { "${1:message}" }$0
endsnippet
snippet mp "map(&:sym_proc)"
map(&:${1:id})
endsnippet
snippet mapca "map.catch_all"
${1:map}.catch_all "*${2:anything}", :controller => "${3:default}", :action => "${4:error}"
endsnippet
snippet map "map.named_route"
${1:map}.${2:connect} '${3::controller/:action/:id}'
endsnippet
snippet mapr "map.resource"
${1:map}.resource :${2:resource}${10: do |${11:$2}|
$0
end}
endsnippet
snippet maprs "map.resources"
${1:map}.resources :${2:resource}${10: do |${11:$2}|
$0
end}
endsnippet
snippet mapwo "map.with_options"
${1:map}.with_options :${2:controller} => '${3:thing}' do |${4:$3}|
$0
end
endsnippet
snippet mrw "mattr_accessor"
mattr_accessor :${0:attr_names}
endsnippet
snippet ncl "named_scope lambda"
named_scope :name, lambda { |${1:param}| { :conditions => ${3:['${4:${5:field} = ?}', ${6:$1}]} } }
endsnippet
snippet nc "named_scope"
named_scope :name${1:, :joins => :${2:table}}, :conditions => ${3:['${4:${5:field} = ?}', ${6:true}]}
endsnippet
snippet dscope "default_scope"
default_scope ${1:order(${2:'${3:created_at DESC}'})}
endsnippet
snippet flash "flash[...]"
flash[:${1:notice}] = "${2:Successfully created...}"$0
endsnippet
snippet rea "redirect_to (action)"
redirect_to :action => "${1:index}"
endsnippet
snippet reai "redirect_to (action, id)"
redirect_to :action => "${1:show}", :id => ${0:@item}
endsnippet
snippet rec "redirect_to (controller)"
redirect_to :controller => "${1:items}"
endsnippet
snippet reca "redirect_to (controller, action)"
redirect_to :controller => "${1:items}", :action => "${2:list}"
endsnippet
snippet recai "redirect_to (controller, action, id)"
redirect_to :controller => "${1:items}", :action => "${2:show}", :id => ${0:@item}
endsnippet
snippet renpp "redirect_to (nested path plural)"
redirect_to(${2:${10:parent}_${11:child}_path(${12:@}${13:$10})})
endsnippet
snippet renp "redirect_to (nested path)"
redirect_to(${2:${12:parent}_${13:child}_path(${14:@}${15:$12}, ${16:@}${17:$13})})
endsnippet
snippet repp "redirect_to (path plural)"
redirect_to(${2:${10:model}s_path})
endsnippet
snippet rep "redirect_to (path)"
redirect_to(${2:${12:model}_path(${13:@}${14:$12})})
endsnippet
snippet reb "redirect_to :back"
redirect_to :back
endsnippet
snippet ra "render (action)... (ra)"
render :action => "${1:action}"
endsnippet
snippet ral "render (action,layout) (ral)"
render :action => "${1:action}", :layout => "${2:layoutname}"
endsnippet
snippet rf "render (file) (rf)"
render :file => "${1:filepath}"
endsnippet
snippet rfu "render (file,use_full_path) (rfu)"
render :file => "${1:filepath}", :use_full_path => ${2:false}
endsnippet
snippet ri "render (inline) (ri)"
render :inline => "${1:<%= 'hello' %>}"
endsnippet
snippet ril "render (inline,locals) (ril)"
render :inline => "${1:<%= 'hello' %>}", :locals => { ${2::name} => "${3:value}"$4 }
endsnippet
snippet rit "render (inline,type) (rit)"
render :inline => "${1:<%= 'hello' %>}", :type => ${2::rxml}
endsnippet
snippet rl "render (layout) (rl)"
render :layout => "${1:layoutname}"
endsnippet
snippet rn "render (nothing) (rn)"
render :nothing => ${1:true}
endsnippet
snippet rns "render (nothing,status) (rns)"
render :nothing => ${1:true}, :status => ${2:401}
endsnippet
snippet rt "render (text) (rt)"
render :text => "${1:text to render...}"
endsnippet
snippet rtl "render (text,layout) (rtl)"
render :text => "${1:text to render...}", :layout => "${2:layoutname}"
endsnippet
snippet rtlt "render (text,layout => true) (rtlt)"
render :text => "${1:text to render...}", :layout => ${2:true}
endsnippet
snippet rts "render (text,status) (rts)"
render :text => "${1:text to render...}", :status => ${2:401}
endsnippet
snippet ru "render (update)"
render :update do |${2:page}|
$2.$0
end
endsnippet
snippet rest "respond_to"
respond_to do |wants|
wants.${1:html}${2: { $0 \}}
end
endsnippet
# FIXME
snippet returning "returning do |variable| ... end"
returning ${1:variable} do${2/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1: |)/}${2:v}${2/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:|)/}
$0
end
endsnippet
snippet t. "t.binary (tcbi)"
t.binary :${1:title}${2:, :limit => ${3:2}.megabytes}
t.$0
endsnippet
snippet t. "t.boolean (tcb)"
t.boolean :${1:title}
t.$0
endsnippet
snippet t. "t.date (tcda)"
t.date :${1:title}
t.$0
endsnippet
snippet t. "t.datetime (tcdt)"
t.datetime :${1:title}
t.$0
endsnippet
snippet t. "t.decimal (tcd)"
t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}}
t.$0
endsnippet
snippet t. "t.float (tcf)"
t.float :${1:title}
t.$0
endsnippet
snippet t. "t.integer (tci)"
t.integer :${1:title}
t.$0
endsnippet
snippet t. "t.lock_version (tcl)"
t.integer :lock_version, :null => false, :default => 0
t.$0
endsnippet
snippet t. "t.references (tcr)"
t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}}
t.$0
endsnippet
snippet t. "t.rename (tre)"
t.rename(:${1:old_column_name}, :${2:new_column_name})
t.$0
endsnippet
snippet t. "t.string (tcs)"
t.string :${1:title}
t.$0
endsnippet
snippet t. "t.text (tct)"
t.text :${1:title}
t.$0
endsnippet
snippet t. "t.time (tcti)"
t.time :${1:title}
t.$0
endsnippet
snippet t. "t.timestamp (tcts)"
t.timestamp :${1:title}
t.$0
endsnippet
snippet t. "t.timestamps (tctss)"
t.timestamps
t.$0
endsnippet
snippet vaoif "validates_acceptance_of if"
validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}}, :if => proc { |obj| ${7:obj.condition?} }}
endsnippet
snippet vao "validates_acceptance_of"
validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}}
endsnippet
snippet va "validates_associated (va)"
validates_associated :${1:attribute}${2:, :on => :${3:create}}
endsnippet
snippet vaif "validates_associated if (vaif)"
validates_associated :${1:attribute}${2:, :on => :${3:create}, :if => proc { |obj| ${5:obj.condition?} }}
endsnippet
snippet vc "validates_confirmation_of (vc)"
validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}"}
endsnippet
snippet vcif "validates_confirmation_of if (vcif)"
validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}", :if => proc { |obj| ${5:obj.condition?} }}
endsnippet
snippet ve "validates_exclusion_of (ve)"
validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"}
endsnippet
snippet veif "validates_exclusion_of if (veif)"
validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"}, :if => proc { |obj| ${7:obj.condition?} }}
endsnippet
snippet vfif "validates_format_of if"
validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"}, :if => proc { |obj| ${7:obj.condition?} }}
endsnippet
snippet vf "validates_format_of"
validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"}
endsnippet
snippet viif "validates_inclusion_of if"
validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"}, :if => proc { |obj| ${7:obj.condition?} }}
endsnippet
snippet vi "validates_inclusion_of"
validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"}
endsnippet
snippet vl "validates_length_of (vl)"
validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"}
endsnippet
snippet vlif "validates_length_of if"
validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"}, :if => proc { |obj| ${6:obj.condition?} }}
endsnippet
snippet vnif "validates_numericality_of if"
validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"}, :if => proc { |obj| ${5:obj.condition?} }}
endsnippet
snippet vn "validates_numericality_of"
validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"}
endsnippet
snippet vp "validates_presence_of (vp)"
validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"}
endsnippet
snippet vpif "validates_presence_of if (vpif) 2"
validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"}, :if => proc { |obj| ${5:obj.condition?} }}
endsnippet
snippet vu "validates_uniqueness_of (vu)"
validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}"}
endsnippet
snippet vuif "validates_uniqueness_of if (vuif)"
validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}", :if => proc { |obj| ${6:obj.condition?} }}
endsnippet
snippet verify "verify -- render"
verify :only => [:$1], :method => :post, :render => {:status => 500, :text => "use HTTP-POST"}
endsnippet
snippet verify "verify -- redirect"
verify :only => [:$1], :session => :user, :params => :id, :redirect_to => {:action => '${2:index}'}
endsnippet
snippet wants "wants_format"
wants.${1:js|xml|html}${2: { $0 \}}
endsnippet
snippet xdelete "xhr delete"
xhr :delete, :${1:destroy}, :id => ${2:1}$0
endsnippet
snippet xget "xhr get"
xhr :get, :${1:show}${2:, :id => ${3:1}}$0
endsnippet
snippet xpost "xhr post"
xhr :post, :${1:create}, :${2:object} => { $3 }
endsnippet
snippet xput "xhr put"
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { $4 }$0
endsnippet
snippet sweeper "Create sweeper class"
class ${1:Model}Sweeper < ActionController::Caching::Sweeper
observe ${1:Model}
def after_save(${1/./\l$0/})
expire_cache(${1/./\l$0/})
end
def after_destroy(${1/./\l$0/})
expire_cache(${1/./\l$0/})
end
private
def expire_cache(${1/./\l$0/})
${0:expire_page ${1/./\l$0/}s_path
expire_page ${1/./\l$0/}_path(${1/./\l$0/})}
end
end
endsnippet
snippet col "collection routes"
collection do
${1:get :${2:action}}
${3:put :${4:action}}
${5:post :${6:action}}
${7:delete :${8:action}}
end
endsnippet
snippet format "format (respond_with)"
format.${1:html|xml|json|js|any} { $0 }
endsnippet
snippet gem "gem"
gem '${1:name}'${2:${3:, "${4:1.0}"}${5:${6:, :require => ${7:"${8:$1}"}}${9:, :group => :${10:test}}}}
endsnippet
snippet gemg "gem :git"
gem '${1:paperclip}', :git => "${2:git://github.com/thoughtbot/paperclip.git}"${3:, :branch => "${4:rails3}"}
endsnippet
snippet match "match"
match '${1:${2::controller}${3:/${4::action}${5:/${6::id}${7:(.:format)}}}}'${8: => '${9:$2}#${10:$4}'${11:, :as => :${12:$10}}}
endsnippet
snippet member "member routes"
member do
${1:get :${2:action}}
${3:put :${4:action}}
${5:post :${6:action}}
${7:delete :${8:action}}
end
endsnippet
snippet res "resources"
resources :${1:posts}${2: do
$3
end}
endsnippet
snippet scope "scope"
scope :${1:name}, ${2:joins(:${3:table}).}where(${4:'${5:$3.${6:field}} = ?', ${7:'${8:value}'}})
endsnippet
snippet scopel "scope lambda"
scope :${1:name}, lambda { |${2:param}| ${3:where(${4::${5:field} => ${6:"${7:value}"}})} }
endsnippet
snippet scopee "scope with extension"
scope :${1:name}, ${2:where(${3::${4:field} => ${5:'${6:value}'}})} do
def ${7:method_name}
$0
end
end
endsnippet
snippet sb "scoped_by"
scoped_by_${1:attribute}(${2:id})
endsnippet
snippet setup "setup do..end"
setup do
$0
end
endsnippet
snippet trans "Translation snippet"
I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}$3', :default => "${1:some_text}"$4)${5:$0}
endsnippet
snippet route_spec
it 'routes to #${1:action}' do
${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})$6
end
endsnippet
# vim:ft=snippets:

329
dotfiles/config/nvim/snippets/ruby.snippets

@ -0,0 +1,329 @@
priority -50
#
# Global functions
#
global !p
def write_instance_vars(arglist, snip):
args = str(arglist).split(',')
for arg in args:
name = arg.strip().replace(':', ' ').split(' ', 1)[0]
if name:
snip += ' @{} = {}'.format(name, name)
else:
snip += ''
endglobal
#
# Snippets
#
snippet "^#!" "#!/usr/bin/env ruby" r
#!/usr/bin/env ruby
$0
endsnippet
snippet "^# ?[uU][tT][fF]-?8" "# encoding: UTF-8" r
# encoding: UTF-8
$0
endsnippet
snippet "\b(de)?f" "def <name>..." r
def ${1:function_name}${2:(${3:*args})}
$0
end
endsnippet
snippet defi "def initialize ..."
def initialize($1)`!p write_instance_vars(t[1],snip)`$0
end
endsnippet
snippet defr "def <name> ... rescue ..."
def ${1:function_name}${2:(${3:*args})}
$4
rescue
$0
end
endsnippet
snippet For "(<from>..<to>).each { |<i>| <block> }"
(${1:from}..${2:to}).each { |${3:i}| $0 }
endsnippet
snippet "(\S+)\.Merge!" ".merge!(<other_hash>) { |<key>,<oldval>,<newval>| <block> }" r
`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) { |${2:key},${3:oldval},${4:newval}| ${5:block} }
endsnippet
snippet "(\S+)\.merge!" ".merge!(<other_hash>) do |<key>,<oldval>,<newval>| <block> end" r
`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) do |${2:key},${3:oldval},${4:newval}|
${0:block}
end
endsnippet
snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| $0 }
endsnippet
snippet "(\S+)\.del(ete)?_?if" ".delete_if do |<key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}|
$0
end
endsnippet
snippet "(\S+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| $0 }
endsnippet
snippet "(\S+)\.keep_?if" ".keep_if do <key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}|
$0
end
endsnippet
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| $0 }
endsnippet
snippet "(\S+)\.reject" ".reject do <key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}|
$0
end
endsnippet
snippet "(\S+)\.Select" ".select { |<item>| <block>}" r
`!p snip.rv=match.group(1)`.select { |${1:item}| ${2:block} }
endsnippet
snippet "(\S+)\.select" ".select do |<item>| <block> end" r
`!p snip.rv=match.group(1)`.select do |${1:item}|
${0:block}
end
endsnippet
snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| $0 }
endsnippet
snippet "(\S+)\.sort" ".sort do |<a>,<b>| <block> end" r
`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}|
$0
end
endsnippet
snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r
`!p snip.rv=match.group(1)`.each_key { |${1:key}| $0 }
endsnippet
snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| <block> end" r
`!p snip.rv=match.group(1)`.each_key do |${1:key}|
$0
end
endsnippet
snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r
`!p snip.rv=match.group(1)`.each_value { |${1:value}| $0 }
endsnippet
snippet "(\S+)\.each_?val(ue)?" ".each_value do |<value>| <block> end" r
`!p snip.rv=match.group(1)`.each_value do |${1:value}|
$0
end
endsnippet
snippet "(\S+)\.ea" "<elements>.each do |<element>| <block> end" r
`!p snip.rv=match.group(1)`.each { |${1:e}| $0 }
endsnippet
snippet "(\S+)\.ead" "<elements>.each do |<element>| <block> end" r
`!p snip.rv=match.group(1)`.each do |${1:e}|
$0
end
endsnippet
snippet "each_?s(lice)?" "<array>.each_slice(n) do |slice| <block> end" r
${1:elements}.each_slice(${2:2}) do |${3:slice}|
$0
end
endsnippet
snippet "Each_?s(lice)?" "<array>.each_slice(n) { |slice| <block> }" r
${1:elements}.each_slice(${2:2}) { |${3:slice}| $0 }
endsnippet
snippet "(\S+)\.Map" ".map { |<element>| <block> }" r
`!p snip.rv=match.group(1)`.map { |${1:`!p
element_name = match.group(1).lstrip('$@')
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
try:
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}| $0 }
endsnippet
snippet "(\S+)\.map" ".map do |<element>| <block> end" r
`!p snip.rv=match.group(1)`.map do |${1:`!p
element_name = match.group(1).lstrip('$@')
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
try:
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}|
$0
end
endsnippet
snippet "(\S+)\.Rev(erse)?_?each" ".reverse_each { |<element>| <block> }" r
`!p snip.rv=match.group(1)`.reverse_each { |${1:`!p
element_name = match.group(1).lstrip('$@')
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
try:
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}| $0 }
endsnippet
snippet "(\S+)\.rev(erse)?_?each" ".reverse_each do |<element>| <block> end" r
`!p snip.rv=match.group(1)`.reverse_each do |${1:`!p
element_name = match.group(1).lstrip('$@')
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
try:
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}|
$0
end
endsnippet
snippet "(\S+)\.Each" ".each { |<element>| <block> }" r
`!p snip.rv=match.group(1)`.each { |${1:`!p
element_name = match.group(1).lstrip('$@')
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
try:
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}| $0 }
endsnippet
snippet "(\S+)\.each" ".each do |<element>| <block> end" r
`!p snip.rv=match.group(1)`.each do |${1:`!p
element_name = match.group(1).lstrip('$@')
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
try:
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}|
$0
end
endsnippet
snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| $0 }
endsnippet
snippet "(\S+)\.each_?p(air)?" ".each_pair do |<key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}|
$0
end
endsnippet
snippet "(\S+)\.sub" ".sub(<expression>) { <block> }" r
`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"replace_with"} }
endsnippet
snippet "(\S+)\.gsub" ".gsub(<expression>) { <block> }" r
`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"replace_with"} }
endsnippet
snippet "(\S+)\.index" ".index { |item| <block> }" r
`!p snip.rv=match.group(1)`.index { |${1:item}| ${2:block} }
endsnippet
snippet "(\S+)\.Index" ".index do |item| ... end" r
`!p snip.rv=match.group(1)`.index do |${1:item}|
${0:block}
end
endsnippet
snippet until "until <expression> ... end"
until ${1:expression}
$0
end
endsnippet
snippet Until "begin ... end until <expression>"
begin
$0
end until ${1:expression}
endsnippet
snippet while "while <expression> ... end"
while ${1:expression}
$0
end
endsnippet
snippet While "begin ... end while <expression>"
begin
$0
end while ${1:expression}
endsnippet
snippet begin "begin ... rescue ... end"
begin
$1
rescue
$0
end
endsnippet
snippet rescue
rescue Exception => e
puts e.message
puts e.backtrace.inspect
${0:# Rescue}
endsnippet
snippet "\b(case|sw(itch)?)" "case <variable> when <expression> ... end" r
case ${1:variable}
when ${2:expression}
$0
end
endsnippet
snippet class "class <class_name> def initialize ... end end"
class ${1:class_name}
def initialize(${2:*args})
$0
end
end
endsnippet
snippet module "module"
module ${1:module_name}
$0
end
endsnippet
snippet ###
=begin
$0
=end
endsnippet
# vim: set ts=2 sw=2 expandtab:

106
dotfiles/config/nvim/snippets/rust.snippets

@ -0,0 +1,106 @@
#######################################################################
# Rust Snippets #
#######################################################################
priority -50
snippet let "let variable declaration" b
let ${1:name}${2:: ${3:type}} = $4;
endsnippet
snippet letm "let mut variable declaration" b
let mut ${1:name}${2:: ${3:type}} = $4;
endsnippet
snippet fn "A function, optionally with arguments and return type."
fn ${1:function_name}($2)${3/..*/ -> /}$3 {
${VISUAL}$0
}
endsnippet
snippet pfn "A public function, optionally with arguments and return type."
pub fn ${1:function_name}($2)${3/..*/ -> /}$3 {
${VISUAL}$0
}
endsnippet
snippet arg "Function Arguments" i
${1:a}: ${2:T}${3:, arg}
endsnippet
snippet || "Closure, anonymous function (inline)" i
${1:move }|$2| { $3 }
endsnippet
snippet |} "Closure, anonymous function (block)" i
${1:move }|$2| {
$3
}
endsnippet
snippet pri "print!(..)" b
print!("$1"${2/..*/, /}$2);
endsnippet
snippet pln "println!(..)" b
println!("$1"${2/..*/, /}$2);
endsnippet
snippet fmt "format!(..)"
format!("$1"${2/..*/, /}$2);
endsnippet
snippet macro "macro_rules!" b
macro_rules! ${1:name} {
(${2:matcher}) => (
$3
)
}
endsnippet
snippet mod "A module" b
mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} {
${VISUAL}$0
}
endsnippet
snippet for "for .. in .." b
for ${1:i} in $2 {
${VISUAL}$0
}
endsnippet
snippet todo "A Todo comment"
// [TODO]: ${1:Description} - `!v strftime("%Y-%m-%d %I:%M%P")`
endsnippet
snippet st "Struct" b
struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
${VISUAL}$0
}
endsnippet
# TODO: fancy dynamic field mirroring like Python slotclass
snippet stn "Struct with new constructor." b
pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
fd$0
}
impl $1 {
pub fn new($2) -> $1 {
$1 { $3 }
}
}
endsnippet
snippet fd "Struct field definition" w
${1:name}: ${2:Type},
endsnippet
snippet impl "Struct/Trait implementation" b
impl ${1:Type/Trait}${2: for ${3:Type}} {
$0
}
endsnippet
# vim:ft=snippets:

99
dotfiles/config/nvim/snippets/sh.snippets

@ -0,0 +1,99 @@
priority -50
global !p
import vim
# Tests for the existence of a variable declared by Vim's filetype detection
# suggesting the type of shell script of the current file
def testShell(scope, shell):
return vim.eval("exists('" + scope + ":is_" + shell + "')")
# Loops over the possible variables, checking for global variables
# first since they indicate an override by the user.
def getShell():
for scope in ["g", "b"]:
for shell in ["bash", "posix", "sh", "kornshell"]:
if testShell(scope, shell) == "1":
if shell == "kornshell":
return "ksh"
if shell == "posix":
return "sh"
return shell
return "sh"
endglobal
###########################################################################
# TextMate Snippets #
###########################################################################
snippet #!
`!p snip.rv = '#!/bin/' + getShell() + "\n\n" `
endsnippet
snippet !env "#!/usr/bin/env (!env)"
`!p snip.rv = '#!/usr/bin/env ' + getShell() + "\n\n" `
endsnippet
snippet sbash "safe bash options"
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
`!p snip.rv ='\n\n' `
endsnippet
snippet temp "Tempfile"
${1:TMPFILE}="$(mktemp -t ${2:`!p
snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled"
`})"
${3:${4/(.+)/trap "/}${4:rm -f '$${1/.*\s//}'}${4/(.+)/" 0 # EXIT\n/}${5/(.+)/trap "/}${5:rm -f '$${1/.*\s//}'; exit 1}${5/(.+)/" 2 # INT\n/}${6/(.+)/trap "/}${6:rm -f '$${1/.*\s//}'; exit 1}${6/(.+)/" 1 15 # HUP TERM\n/}}
endsnippet
snippet case "case .. esac (case)"
case ${1:word} in
${2:pattern} )
$0;;
esac
endsnippet
snippet elif "elif .. (elif)"
elif ${2:[[ ${1:condition} ]]}; then
${0:#statements}
endsnippet
snippet for "for ... done (for)"
for (( i = 0; i < ${1:10}; i++ )); do
${0:#statements}
done
endsnippet
snippet forin "for ... in ... done (forin)"
for ${1:i}${2/.+/ in /}${2:words}; do
${0:#statements}
done
endsnippet
snippet here "here document (here)"
<<-${2:'${1:TOKEN}'}
$0
${1/['"`](.+)['"`]/$1/}
endsnippet
snippet if "if ... then (if)"
if ${2:[[ ${1:condition} ]]}; then
${0:#statements}
fi
endsnippet
snippet until "until ... (done)"
until ${2:[[ ${1:condition} ]]}; do
${0:#statements}
done
endsnippet
snippet while "while ... (done)"
while ${2:[[ ${1:condition} ]]}; do
${0:#statements}
done
endsnippet
# vim:ft=snippets:

16
dotfiles/config/nvim/snippets/xml.snippets

@ -0,0 +1,16 @@
priority -50
snippet xml "XML declaration" b
<?xml version="1.0"?>
endsnippet
snippet t "Simple tag" b
<${1:tag}>
${2:content}
</${1/([\w:._-]+).*/$1/}>
endsnippet
snippet ti "Inline tag" b
<${1:tag}>${2:content}</${1/([\w:._-]+).*/$1/}>
endsnippet
Loading…
Cancel
Save