1
0
Fork 0
mirror of synced 2024-11-22 16:55:34 -05:00

Updated plugins

This commit is contained in:
amix 2013-07-17 19:06:05 -04:00
parent 879a7b6bd4
commit a448b32309
85 changed files with 2174 additions and 941 deletions

View file

@ -68,6 +68,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
\ 'key_loop': ['s:keyloop', 0],
\ 'lazy_update': ['s:lazy', 0],
\ 'match_func': ['s:matcher', {}],
\ 'match_window': ['s:mw', ''],
\ 'match_window_bottom': ['s:mwbottom', 1],
\ 'match_window_reversed': ['s:mwreverse', 1],
\ 'max_depth': ['s:maxdepth', 40],
@ -102,7 +103,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
" Global options
let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0, 'im': 0,
\ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'mouse': 'n',
\ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'ttimeout': 0,
\ 'gcr': 'a:blinkon0', 'ic': 1, 'lmap': '', 'mousef': 0, 'imd': 1 }
" Keymaps
@ -181,7 +182,7 @@ let s:hlgrps = {
\ 'PrtText': 'Normal',
\ 'PrtCursor': 'Constant',
\ }
" s:opts() {{{2
" Get the options {{{2
fu! s:opts(...)
unl! s:usrign s:usrcmd s:urprtmaps
for each in ['byfname', 'regexp', 'extensions'] | if exists('s:'.each)
@ -201,6 +202,9 @@ fu! s:opts(...)
let {va} = {s:bpref.ke}
en
endfo
" Match window options
cal s:match_window_opts()
" One-time values
if a:0 && a:1 != {}
unl va
for [ke, va] in items(a:1)
@ -217,7 +221,6 @@ fu! s:opts(...)
en | endfo
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
let s:maxdepth = min([s:maxdepth, 100])
let s:mxheight = max([s:mxheight, 1])
let s:glob = s:showhidden ? '.*\|*' : '*'
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
let s:lash = ctrlp#utils#lash()
@ -238,13 +241,32 @@ fu! s:opts(...)
cal extend(s:prtmaps, s:urprtmaps)
en
endf
fu! s:match_window_opts()
let s:mw_pos =
\ s:mw =~ 'top\|bottom' ? matchstr(s:mw, 'top\|bottom') :
\ exists('g:ctrlp_match_window_bottom') ? ( s:mwbottom ? 'bottom' : 'top' )
\ : 'bottom'
let s:mw_order =
\ s:mw =~ 'order:[^,]\+' ? matchstr(s:mw, 'order:\zs[^,]\+') :
\ exists('g:ctrlp_match_window_reversed') ? ( s:mwreverse ? 'btt' : 'ttb' )
\ : 'btt'
let s:mw_max =
\ s:mw =~ 'max:[^,]\+' ? str2nr(matchstr(s:mw, 'max:\zs\d\+')) :
\ exists('g:ctrlp_max_height') ? s:mxheight
\ : 10
let s:mw_min =
\ s:mw =~ 'min:[^,]\+' ? str2nr(matchstr(s:mw, 'min:\zs\d\+')) : 1
let [s:mw_max, s:mw_min] = [max([s:mw_max, 1]), max([s:mw_min, 1])]
let s:mw_min = min([s:mw_min, s:mw_max])
endf
"}}}1
" * Open & Close {{{1
fu! s:Open()
cal s:log(1)
cal s:getenv()
cal s:execextvar('enter')
sil! exe 'keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP'
sil! exe 'keepa' ( s:mw_pos == 'top' ? 'to' : 'bo' ) '1new ControlP'
cal s:buffunc(1)
let [s:bufnr, s:winw] = [bufnr('%'), winwidth(0)]
let [s:focus, s:prompt] = [1, ['', '', '']]
@ -297,7 +319,7 @@ fu! ctrlp#clra()
if isdirectory(cadir)
let cafiles = split(s:glbpath(s:fnesc(cadir, 'g', ','), '**', 1), "\n")
let eval = '!isdirectory(v:val) && v:val !~ ''\v[\/]cache[.a-z]+$|\.log$'''
sil! cal map(filter(cafiles, eval), 'delete(v:val)')
sil! cal map(s:ifilter(cafiles, eval), 'delete(v:val)')
en
cal ctrlp#clr()
endf
@ -362,7 +384,7 @@ fu! s:UserCmd(lscmd)
let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
en
if has('win32') || has('win64')
let lscmd = substitute(lscmd, '\v(^|&&\s*)\zscd (/d)@!', 'cd /d ', '')
let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '')
en
let path = exists('*shellescape') ? shellescape(path) : path
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
@ -433,7 +455,7 @@ endf
fu! s:MatchIt(items, pat, limit, exc)
let [lines, id] = [[], 0]
let pat =
\ s:byfname ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val')
\ s:byfname() ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val')
\ : s:martcs.a:pat
for item in a:items
let id += 1
@ -450,7 +472,16 @@ fu! s:MatchedItems(items, pat, limit)
let exc = exists('s:crfilerel') ? s:crfilerel : ''
let items = s:narrowable() ? s:matched + s:mdata[3] : a:items
if s:matcher != {}
let argms = [items, a:pat, a:limit, s:mmode(), s:ispath, exc, s:regexp]
let argms =
\ has_key(s:matcher, 'arg_type') && s:matcher['arg_type'] == 'dict' ? [{
\ 'items': items,
\ 'str': a:pat,
\ 'limit': a:limit,
\ 'mmode': s:mmode(),
\ 'ispath': s:ispath,
\ 'crfile': exc,
\ 'regex': s:regexp,
\ }] : [items, a:pat, a:limit, s:mmode(), s:ispath, exc, s:regexp]
let lines = call(s:matcher['match'], argms, s:matcher)
el
let lines = s:MatchIt(items, a:pat, a:limit, exc)
@ -480,7 +511,7 @@ fu! s:SplitPattern(str)
if exists('lst')
let pat = ''
if !empty(lst)
if s:byfname && index(lst, ';') > 0
if s:byfname() && index(lst, ';') > 0
let fbar = index(lst, ';')
let lst_1 = s:sublist(lst, 0, fbar - 1)
let lst_2 = len(lst) - 1 > fbar ? s:sublist(lst, fbar + 1, -1) : ['']
@ -494,15 +525,19 @@ fu! s:SplitPattern(str)
endf
" * BuildPrompt() {{{1
fu! s:Render(lines, pat)
let [&ma, lines, s:height] = [1, a:lines, min([len(a:lines), s:winh])]
let pat = s:byfname ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat
let [&ma, lines, s:res_count] = [1, a:lines, len(a:lines)]
let height = min([max([s:mw_min, s:res_count]), s:winmaxh])
let pat = s:byfname() ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat
let cur_cmd = 'keepj norm! '.( s:mw_order == 'btt' ? 'G' : 'gg' ).'1|'
" Setup the match window
sil! exe '%d _ | res' s:height
sil! exe '%d _ | res' height
" Print the new items
if empty(lines)
let [s:matched, s:lines] = [[], []]
cal setline(1, ' == NO ENTRIES ==')
let lines = [' == NO ENTRIES ==']
cal setline(1, s:offset(lines, height - 1))
setl noma nocul
exe cur_cmd
cal s:unmarksigns()
if s:dohighlight() | cal clearmatches() | en
retu
@ -514,12 +549,12 @@ fu! s:Render(lines, pat)
cal sort(lines, 's:mixedsort')
unl s:compat
en
if s:mwreverse | cal reverse(lines) | en
if s:mw_order == 'btt' | cal reverse(lines) | en
let s:lines = copy(lines)
cal map(lines, 's:formatline(v:val)')
cal setline(1, lines)
cal setline(1, s:offset(lines, height))
setl noma cul
exe 'keepj norm!' ( s:mwreverse ? 'G' : 'gg' ).'1|'
exe cur_cmd
cal s:unmarksigns()
cal s:remarksigns()
if exists('s:cline') && s:nolim != 1
@ -541,7 +576,7 @@ fu! s:Update(str)
let s:martcs = &scs && str =~ '\u' ? '\C' : ''
let pat = s:matcher == {} ? s:SplitPattern(str) : str
let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:winh)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:winmaxh)
cal s:Render(lines, pat)
endf
@ -550,7 +585,7 @@ fu! s:ForceUpdate()
endf
fu! s:BuildPrompt(upd)
let base = ( s:regexp ? 'r' : '>' ).( s:byfname ? 'd' : '>' ).'> '
let base = ( s:regexp ? 'r' : '>' ).( s:byfname() ? 'd' : '>' ).'> '
let str = escape(s:getinput(), '\')
let lazy = str == '' || exists('s:force') || !has('autocmd') ? 0 : s:lazy
if a:upd && !lazy && ( s:matches || s:regexp || exists('s:did_exp')
@ -581,11 +616,8 @@ fu! s:SetDefTxt()
if s:deftxt == '0' || ( s:deftxt == 1 && !s:ispath ) | retu | en
let txt = s:deftxt
if !type(txt)
let txt = txt && !stridx(s:crfpath, s:dyncwd)
\ ? ctrlp#rmbasedir([s:crfpath])[0] : ''
let txt = txt != '' ? txt.s:lash(s:crfpath) : ''
el
let txt = expand(txt, 1)
let path = s:crfpath.s:lash(s:crfpath)
let txt = txt && !stridx(path, s:dyncwd) ? ctrlp#rmbasedir([path])[0] : ''
en
let s:prompt[0] = txt
endf
@ -735,7 +767,7 @@ endf
fu! s:PrtSelectJump(char)
let lines = copy(s:lines)
if s:byfname
if s:byfname()
cal map(lines, 'split(v:val, ''[\/]\ze[^\/]\+$'')[-1]')
en
" Cycle through matches, use s:jmpchr to store last jump
@ -904,6 +936,11 @@ fu! s:ToggleKeyLoop()
en
endf
fu! s:ToggleMRURelative()
cal ctrlp#mrufiles#tgrel()
cal s:PrtClearCache()
endf
fu! s:PrtSwitcher()
let [s:force, s:matches] = [1, 1]
cal s:BuildPrompt(1)
@ -937,14 +974,21 @@ fu! s:SetWD(args)
en
endf
" * AcceptSelection() {{{1
fu! ctrlp#acceptfile(mode, line, ...)
let [md, useb] = [a:mode, 0]
if !type(a:line)
let [filpath, bufnr, useb] = [a:line, a:line, 1]
fu! ctrlp#acceptfile(...)
let useb = 0
if a:0 == 1 && type(a:1) == 4
let [md, line] = [a:1['action'], a:1['line']]
let atl = has_key(a:1, 'tail') ? a:1['tail'] : ''
el
let filpath = fnamemodify(a:line, ':p')
if s:nonamecond(a:line, filpath)
let bufnr = str2nr(matchstr(a:line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
let [md, line] = [a:1, a:2]
let atl = a:0 > 2 ? a:3 : ''
en
if !type(line)
let [filpath, bufnr, useb] = [line, line, 1]
el
let filpath = fnamemodify(line, ':p')
if s:nonamecond(line, filpath)
let bufnr = str2nr(matchstr(line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
let [filpath, useb] = [bufnr, 1]
el
let bufnr = bufnr('^'.filpath.'$')
@ -952,7 +996,7 @@ fu! ctrlp#acceptfile(mode, line, ...)
en
cal s:PrtExit()
let tail = s:tail()
let j2l = a:0 ? a:1 : matchstr(tail, '^ +\zs\d\+$')
let j2l = atl != '' ? atl : matchstr(tail, '^ +\zs\d\+$')
if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0
\ && !( md == 'e' && bufnr == bufnr('%') )
let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)]
@ -980,7 +1024,7 @@ fu! ctrlp#acceptfile(mode, line, ...)
" Reset &switchbuf option
let [swb, &swb] = [&swb, '']
" Open new window/buffer
let [fid, tail] = [( useb ? bufnr : filpath ), ( a:0 ? ' +'.a:1 : tail )]
let [fid, tail] = [( useb ? bufnr : filpath ), ( atl != '' ? ' +'.atl : tail )]
let args = [cmd, fid, tail, 1, [useb, j2l]]
cal call('s:openfile', args)
let &swb = swb
@ -1011,24 +1055,34 @@ fu! s:SpecInputs(str)
retu 0
endf
fu! s:AcceptSelection(mode)
if a:mode != 'e' && s:OpenMulti(a:mode) != -1 | retu | en
fu! s:AcceptSelection(action)
let [md, icr] = [a:action[0], match(a:action, 'r') >= 0]
let subm = icr || ( !icr && md == 'e' )
if !subm && s:OpenMulti(md) != -1 | retu | en
let str = s:getinput()
if a:mode == 'e' | if s:SpecInputs(str) | retu | en | en
if subm | if s:SpecInputs(str) | retu | en | en
" Get the selected line
let line = ctrlp#getcline()
if a:mode != 'e' && !s:itemtype && line == ''
if !subm && !s:itemtype && line == '' && line('.') > s:offset
\ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$'
cal s:CreateNewFile(a:mode) | retu
cal s:CreateNewFile(md) | retu
en
if empty(line) | retu | en
" Do something with it
if s:openfunc != {} && has_key(s:openfunc, s:ctype)
let actfunc = s:openfunc[s:ctype]
let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list'
el
let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile' : s:getextvar('accept')
if s:itemtype < 3
let [actfunc, type] = ['ctrlp#acceptfile', 'dict']
el
let [actfunc, exttype] = [s:getextvar('accept'), s:getextvar('act_farg')]
let type = exttype == 'dict' ? exttype : 'list'
en
cal call(actfunc, [a:mode, line])
en
let actargs = type == 'dict' ? [{ 'action': md, 'line': line, 'icr': icr }]
\ : [md, line]
cal call(actfunc, actargs)
endf
" - CreateNewFile() {{{1
fu! s:CreateNewFile(...)
@ -1187,7 +1241,10 @@ fu! s:OpenNoMarks(md, line)
cal s:remarksigns()
cal s:BuildPrompt(0)
elsei a:md == 'x'
cal call(s:openfunc[s:ctype], [a:md, a:line], s:openfunc)
let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'dict'
let argms = type == 'dict' ? [{ 'action': a:md, 'line': a:line }]
\ : [a:md, a:line]
cal call(s:openfunc[s:ctype], argms, s:openfunc)
elsei a:md == 'd'
let dir = fnamemodify(a:line, ':h')
if isdirectory(dir)
@ -1278,7 +1335,7 @@ fu! s:mixedsort(...)
let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)]
if s:ispath
let ms = []
if s:height < 21
if s:res_count < 21
let ms += [s:compfnlen(a:1, a:2)]
if s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en
if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en
@ -1324,12 +1381,21 @@ fu! ctrlp#statusline()
let prv = tps[s:walker(max, s:itemtype, -1)][1]
let s:ctype = tps[s:itemtype][0]
let focus = s:focus ? 'prt' : 'win'
let byfname = s:byfname ? 'file' : 'path'
let byfname = s:ispath ? s:byfname ? 'file' : 'path' : 'line'
let marked = s:opmul != '0' ?
\ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : ''
if s:status != {}
let args = [focus, byfname, s:regexp, prv, s:ctype, nxt, marked]
let &l:stl = call(s:status['main'], args, s:status)
let argms =
\ has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict' ? [{
\ 'focus': focus,
\ 'byfname': byfname,
\ 'regex': s:regexp,
\ 'prev': prv,
\ 'item': s:ctype,
\ 'next': nxt,
\ 'marked': marked,
\ }] : [focus, byfname, s:regexp, prv, s:ctype, nxt, marked]
let &l:stl = call(s:status['main'], argms, s:status)
el
let item = '%#CtrlPMode1# '.s:ctype.' %*'
let focus = '%#CtrlPMode2# '.focus.' %*'
@ -1349,8 +1415,13 @@ endf
fu! ctrlp#progress(enum, ...)
if has('macunix') || has('mac') | sl 1m | en
let txt = a:0 ? '(press ctrl-c to abort)' : ''
let &l:stl = s:status != {} ? call(s:status['prog'], [a:enum], s:status)
\ : '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*'
if s:status != {}
let argms = has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict'
\ ? [{ 'str': a:enum }] : [a:enum]
let &l:stl = call(s:status['prog'], argms, s:status)
el
let &l:stl = '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*'
en
redraws
endf
" *** Paths {{{2
@ -1376,6 +1447,11 @@ fu! s:pathshorten(str)
retu matchstr(a:str, '^.\{9}').'...'
\ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$')
endf
fu! s:offset(lines, height)
let s:offset = s:mw_order == 'btt' ? ( a:height - s:res_count ) : 0
retu s:offset > 0 ? ( repeat([''], s:offset) + a:lines ) : a:lines
endf
" Directory completion {{{3
fu! s:dircompl(be, sd)
if a:sd == '' | retu [] | en
@ -1464,7 +1540,7 @@ fu! s:samerootsyml(each, isfile, cwd)
endf
fu! ctrlp#rmbasedir(items)
let cwd = s:dyncwd.( s:dyncwd !~ '[\/]$' ? s:lash : '' )
let cwd = s:dyncwd.s:lash()
if a:items != [] && !stridx(a:items[0], cwd)
let idx = strlen(cwd)
retu map(a:items, 'strpart(v:val, idx)')
@ -1599,6 +1675,18 @@ fu! s:dosigns()
retu exists('s:marked') && s:bufnr > 0 && s:opmul != '0' && has('signs')
endf
" Lists & Dictionaries {{{2
fu! s:ifilter(list, str)
let [rlist, estr] = [[], substitute(a:str, 'v:val', 'each', 'g')]
for each in a:list
try
if eval(estr)
cal add(rlist, each)
en
cat | con | endt
endfo
retu rlist
endf
fu! s:dictindex(dict, expr)
for key in keys(a:dict)
if a:dict[key] == a:expr | retu key | en
@ -1808,7 +1896,6 @@ endf
fu! s:modevar()
let s:matchtype = s:mtype()
let s:ispath = s:ispathitem()
if !s:ispath | let s:byfname = 0 | en
let s:mfunc = s:mfunc()
let s:nolim = s:getextvar('nolim')
let s:dosort = s:getextvar('sort')
@ -1820,6 +1907,10 @@ fu! s:nosort()
\ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort
endf
fu! s:byfname()
retu s:ispath && s:byfname
endf
fu! s:narrowable()
retu exists('s:act_add') && exists('s:matched') && s:matched != []
\ && exists('s:mdata') && s:mdata[:2] == [s:dyncwd, s:itemtype, s:regexp]
@ -1834,7 +1925,7 @@ fu! s:getinput(...)
if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k'
retu join(prt, '')
en
let [pf, rz] = [( s:byfname ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )]
let [pf, rz] = [( s:byfname() ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )]
for dict in s:abbrev['abbrevs']
let dmd = has_key(dict, 'mode') ? dict['mode'] : ''
let pat = escape(dict['pattern'], '~')
@ -1916,7 +2007,7 @@ fu! s:getenv()
let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]]
let [s:crword, s:crnbword] = [expand('<cword>', 1), expand('<cWORD>', 1)]
let [s:crgfile, s:crline] = [expand('<cfile>', 1), getline('.')]
let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')]
let [s:winmaxh, s:crcursor] = [min([s:mw_max, &lines]), getpos('.')]
let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()]
let s:crfile = bufname('%') == ''
\ ? '['.s:crbufnr.'*No Name]' : expand('%:p', 1)
@ -1939,7 +2030,8 @@ endf
fu! s:log(m)
if exists('g:ctrlp_log') && g:ctrlp_log | if a:m
let cadir = ctrlp#utils#cachedir()
sil! exe 'redi! >' cadir.s:lash(cadir).'ctrlp.log'
let apd = g:ctrlp_log > 1 ? '>' : ''
sil! exe 'redi! >'.apd cadir.s:lash(cadir).'ctrlp.log'
el
sil! redi END
en | en
@ -2023,7 +2115,7 @@ endf
fu! s:mfunc()
let mfunc = 'match'
if s:byfname && s:ispath
if s:byfname()
let mfunc = 's:matchfname'
elsei s:itemtype > 2
let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
@ -2102,7 +2194,9 @@ fu! s:getextvar(key)
endf
fu! ctrlp#getcline()
retu !empty(s:lines) ? s:lines[line('.') - 1] : ''
let [linenr, offset] = [line('.'), ( s:offset > 0 ? s:offset : 0 )]
retu !empty(s:lines) && !( offset && linenr <= offset )
\ ? s:lines[linenr - 1 - offset] : ''
endf
fu! ctrlp#getmarkedlist()
@ -2134,6 +2228,10 @@ endf
fu! ctrlp#call(func, ...)
retu call(a:func, a:000)
endf
fu! ctrlp#getvar(var)
retu {a:var}
endf
"}}}1
" * Initialization {{{1
fu! ctrlp#setlines(...)

View file

@ -248,7 +248,9 @@ endf
fu! ctrlp#buffertag#cmd(mode, ...)
let s:btmode = a:mode
if a:0 && !empty(a:1)
let s:bufname = fnamemodify(a:1, ':p')
let s:btmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufname = fnamemodify(bname, ':p')
en
retu s:id
endf

View file

@ -83,7 +83,9 @@ endf
fu! ctrlp#changes#cmd(mode, ...)
let s:clmode = a:mode
if a:0 && !empty(a:1)
let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$')
let s:clmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
en
retu s:id
endf

View file

@ -74,7 +74,7 @@ fu! ctrlp#dir#init(...)
endf
fu! ctrlp#dir#accept(mode, str)
let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str
let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#call('s:lash', s:cwd).a:str
if a:mode =~ 't\|v\|h'
cal ctrlp#exit()
en

View file

@ -11,7 +11,7 @@ en
let g:loaded_ctrlp_line = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#line#init()',
\ 'init': 'ctrlp#line#init(s:crbufnr)',
\ 'accept': 'ctrlp#line#accept',
\ 'lname': 'lines',
\ 'sname': 'lns',
@ -29,8 +29,9 @@ fu! s:syntax()
en
endf
" Public {{{1
fu! ctrlp#line#init()
let [bufs, lines] = [ctrlp#buffers('id'), []]
fu! ctrlp#line#init(bufnr)
let [lines, bufnr] = [[], exists('s:bufnr') ? s:bufnr : a:bufnr]
let bufs = exists('s:lnmode') && s:lnmode ? ctrlp#buffers('id') : [bufnr]
for bufnr in bufs
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
if lfb == [] && bufn != ''
@ -57,7 +58,13 @@ fu! ctrlp#line#accept(mode, str)
en
endf
fu! ctrlp#line#id()
fu! ctrlp#line#cmd(mode, ...)
let s:lnmode = a:mode
if a:0 && !empty(a:1)
let s:lnmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
en
retu s:id
endf
"}}}

View file

@ -126,6 +126,10 @@ fu! ctrlp#mrufiles#bufs()
retu s:mrbs
endf
fu! ctrlp#mrufiles#tgrel()
let {s:re} = !{s:re}
endf
fu! ctrlp#mrufiles#cachefile()
if !exists('s:cadir') || !exists('s:cafile')
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'

View file

@ -40,9 +40,7 @@ Overview:~
|ctrlp_cmd|...................Default command used for the default mapping.
|ctrlp_by_filename|...........Default to filename mode or not.
|ctrlp_regexp|................Default to regexp mode or not.
|ctrlp_match_window_bottom|...Where to show the match window.
|ctrlp_match_window_reversed|.Sort order in the match window.
|ctrlp_max_height|............Max height of the match window.
|ctrlp_match_window|..........Order, height and position of the match window.
|ctrlp_switch_buffer|.........Jump to an open buffer if already opened.
|ctrlp_reuse_window|..........Reuse special windows (help, quickfix, etc).
|ctrlp_tabpage_position|......Where to put the new tab page.
@ -77,6 +75,11 @@ Overview:~
|ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not.
|ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added.
BufferTag mode: (to enable, see |ctrlp-extensions|)
|g:ctrlp_buftag_ctags_bin|....The location of the ctags-compatible binary.
|g:ctrlp_buftag_systemenc|....The encoding used for the ctags command.
|g:ctrlp_buftag_types|........Add new filetypes and set the cmd arguments.
Advanced options:
|ctrlp_open_func|.............Use custom file opening functions.
|ctrlp_status_func|...........Change CtrlP's two statuslines.
@ -114,21 +117,27 @@ Set this to 1 to set regexp search as the default: >
<
Can be toggled on/off by pressing <c-r> inside the prompt.
*'g:ctrlp_match_window_bottom'*
Set this to 0 to show the match window at the top of the screen: >
let g:ctrlp_match_window_bottom = 1
*'g:ctrlp_match_window'*
Change the postion, the listing order of results, the minimum and the maximum
heights of the match window: >
let g:ctrlp_match_window = ''
<
Example: >
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10'
<
The position: (default: bottom)
top - show the match window at the top of the screen.
bottom - show the match window at the bottom of the screen.
*'g:ctrlp_match_window_reversed'*
Change the listing order of the files in the match window. The default setting
(1) is from bottom to top: >
let g:ctrlp_match_window_reversed = 1
<
The listing order of results: (default: btt)
order:ttb - from top to bottom.
order:btt - from bottom to top.
*'g:ctrlp_max_height'*
Set the maximum height of the match window: >
let g:ctrlp_max_height = 10
<
The minimum and maximum heights:
min:{n} - show minimum {n} lines (default: 1).
max:{n} - show maximum {n} lines (default: 10).
Note: When a setting isn't set, its default value will be used.
*'g:ctrlp_switch_buffer'*
When opening a file, if it's already open in a window somewhere, CtrlP will try
@ -323,18 +332,21 @@ Some examples: >
let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') '
\ . 'do hg --cwd %s status -numac -I . %%a'] " Windows
<
Note #1: if the fallback_command is empty or the 'fallback' key is not defined,
Note #1: in the |Dictionary| format, 'fallback' and 'ignore' are optional. In
the |List| format, fallback_command is optional.
Note #2: if the fallback_command is empty or the 'fallback' key is not defined,
|globpath()| will then be used when scanning outside of a repository.
Note #2: unless the |Dictionary| format is used and 'ignore' is defined and set
Note #3: unless the |Dictionary| format is used and 'ignore' is defined and set
to 1, the |wildignore| and |g:ctrlp_custom_ignore| options do not apply when
these custom commands are being used. When not present, 'ignore' is set to 0 by
default to retain the performance advantage of using external commands.
Note #3: when changing the option's variable type, remember to |:unlet| it
Note #4: when changing the option's variable type, remember to |:unlet| it
first or restart Vim to avoid the "E706: Variable type mismatch" error.
Note #4: you can use a |b:var| to set this option on a per buffer basis.
Note #5: you can use a |b:var| to set this option on a per buffer basis.
*'g:ctrlp_max_history'*
The maximum number of input strings you want CtrlP to remember. The default
@ -563,6 +575,9 @@ Example: >
Set this to 1 to show only MRU files in the current working directory: >
let g:ctrlp_mruf_relative = 0
<
Note: you can use a custom mapping to toggle this option inside the prompt: >
let g:ctrlp_prompt_mappings = { 'ToggleMRURelative()': ['<F2>'] }
<
*'g:ctrlp_mruf_default_order'*
Set this to 1 to disable sorting when searching in MRU mode: >
@ -734,6 +749,27 @@ Structure of the function: >
endfunction
<
Note: you can extend any of the above options with { 'arg_type': 'dict' } to
enable passing all the function arguments in a single Dictionary argument. Use
the existing argument names as keys in this Dictionary.
Example: >
let g:ctrlp_status_func = {
\ 'arg_type' : 'dict',
\ 'enter': 'Function_Name_1',
\ 'exit': 'Function_Name_2',
\ }
function! Function_Name_1(dict)
" where dict == {
" \ 'focus': value,
" \ 'byfname': value,
" \ 'regex': value,
" \ ...
" }
endfunction
<
===============================================================================
COMMANDS *ctrlp-commands*
@ -1076,8 +1112,8 @@ Available extensions:~
*:CtrlPLine*
* Line mode:~
- Name: 'line'
- Command: ":CtrlPLine"
- Search for a line in all listed buffers.
- Command: ":CtrlPLine [buffer]"
- Search for a line in all listed buffers or in the specified [buffer].
*:CtrlPChange*
*:CtrlPChangeAll*
@ -1164,7 +1200,7 @@ Highlighting:~
Statuslines:~
* Highlight groups:
CtrlPMode1 : 'file' or 'path', and the current mode (Character)
CtrlPMode1 : 'file' or 'path' or 'line', and the current mode (Character)
CtrlPMode2 : 'prt' or 'win', 'regex', the working directory (|hl-LineNr|)
CtrlPStats : the scanning status (Function)
@ -1253,6 +1289,10 @@ Special thanks:~
===============================================================================
CHANGELOG *ctrlp-changelog*
+ Combine *g:ctrlp_match_window_bottom* *g:ctrlp_match_window_reversed* and
*g:ctrlp_max_height* into |g:ctrlp_match_window|.
+ New option: |g:ctrlp_match_window|.
Before 2012/11/30~
+ New options: |g:ctrlp_abbrev|,

View file

@ -51,7 +51,9 @@ com! -n=? -com=buffer CtrlPBufTag
com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
com! -bar CtrlPLine cal ctrlp#init(ctrlp#line#id())
com! -n=? -com=buffer CtrlPLine
\ cal ctrlp#init(ctrlp#line#cmd(1, <q-args>))
com! -n=? -com=buffer CtrlPChange
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))

View file

@ -76,8 +76,8 @@ syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+
syn region markdownItalic start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart
syn region markdownItalic start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart
syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart
syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart
syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart,markdownItalic
syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart,markdownItalic
syn region markdownBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart
syn region markdownBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart
syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart
@ -86,7 +86,7 @@ syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*```.*$" end=
if main_syntax ==# 'markdown'
for s:type in g:markdown_fenced_languages
exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g')
exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```\s*'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g')
endfor
unlet! s:type
endif

View file

@ -1,3 +1,7 @@
## 2.2 (06/10/2013)
Bugfixes:
- Fix plugin break in PASTE mode. This fixes #44.
## 2.1 (04/26/2013)
Bugfixes:

View file

@ -69,7 +69,7 @@ let g:multi_cursor_start_key='<F6>'
## Setting
Currently there're two additional global settings one can tweak:
### ```g:multi_cursor_exit_from_visual_mode``` (Defaut: 1)
### ```g:multi_cursor_exit_from_visual_mode``` (Default: 1)
If set to 0, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the cursors.
@ -87,7 +87,6 @@ highlight link multiple_cursors_visual Visual
## Issues
- Multi key commands like `ciw` do not work at the moment
- Insert mode can be slow. If you are using Neobundle and have many plugins, try switching to Vundle to see if it helps. See https://github.com/Shougo/neobundle.vim/issues/84 for additional info.
- All user input typed before Vim is able to fan out the last operation to all cursors is lost. This is a implementation decision to keep the input perfectly synced in all locations, at the cost of potentially losing user input.
- Select mode is not implemented

View file

@ -50,9 +50,9 @@ endif
" Internal Mappings
"===============================================================================
inoremap <silent> <Plug>(i) <C-o>:call <SID>process_user_inut()<CR>
nnoremap <silent> <Plug>(i) :call <SID>process_user_inut()<CR>
xnoremap <silent> <Plug>(i) :<C-u>call <SID>process_user_inut()<CR>
inoremap <silent> <Plug>(i) <C-o>:call <SID>process_user_input()<CR>
nnoremap <silent> <Plug>(i) :call <SID>process_user_input()<CR>
xnoremap <silent> <Plug>(i) :<C-u>call <SID>process_user_input()<CR>
inoremap <silent> <Plug>(a) <C-o>:call <SID>apply_user_input_next('i')<CR>
nnoremap <silent> <Plug>(a) :call <SID>apply_user_input_next('n')<CR>
@ -97,8 +97,8 @@ endfunction
" attempted to be created at the next occurrence of the visual selection
function! multiple_cursors#new(mode)
if a:mode ==# 'n'
" Reset all existing cursors, don't restore view
call s:cm.reset(0)
" Reset all existing cursors, don't restore view and setting
call s:cm.reset(0, 0)
" Select the word under cursor to set the '< and '> marks
exec "normal! viw"
@ -113,7 +113,7 @@ function! multiple_cursors#new(mode)
let start = line("'<")
let finish = line("'>")
if start != finish
call s:cm.reset(0)
call s:cm.reset(0, 0)
let col = col("'<")
for line in range(line("'<"), line("'>"))
let pos = [line, col]
@ -124,7 +124,7 @@ function! multiple_cursors#new(mode)
else
" Came directly from visual mode
if s:cm.is_empty()
call s:cm.reset(0)
call s:cm.reset(0, 0)
if visualmode() ==# 'V'
let left = [line('.'), 1]
@ -318,6 +318,7 @@ function! s:CursorManager.new()
\ 'virtualedit': &virtualedit,
\ 'cursorline': &cursorline,
\ 'lazyredraw': &lazyredraw,
\ 'paste': &paste,
\ }
" We save the window view when multicursor mode is entered
let obj.saved_winview = []
@ -327,7 +328,7 @@ function! s:CursorManager.new()
endfunction
" Clear all cursors and their highlights
function! s:CursorManager.reset(restore_view) dict
function! s:CursorManager.reset(restore_view, restore_setting) dict
if a:restore_view
" Return the view back to the beginning
if !empty(self.saved_winview)
@ -357,7 +358,9 @@ function! s:CursorManager.reset(restore_view) dict
let self.saved_winview = []
let self.start_from_find = 0
let s:char = ''
if a:restore_setting
call self.restore_user_settings()
endif
endfunction
" Returns 0 if it's not managing any cursors at the moment
@ -513,10 +516,17 @@ endfunction
" where the real vim cursor is
" lazyredraw needs to be turned on to prevent jerky screen behavior with many
" cursors on screen
" paste mode needs to be switched off since it turns off a bunch of features
" that's critical for the plugin to function
function! s:CursorManager.initialize() dict
let self.saved_settings['virtualedit'] = &virtualedit
let self.saved_settings['cursorline'] = &cursorline
let self.saved_settings['lazyredraw'] = &lazyredraw
let self.saved_settings['paste'] = &paste
let &virtualedit = "onemore"
let &cursorline = 0
let &lazyredraw = 1
let &paste = 0
" We could have already saved the view from multiple_cursors#find
if !self.start_from_find
let self.saved_winview = winsaveview()
@ -529,6 +539,7 @@ function! s:CursorManager.restore_user_settings() dict
let &virtualedit = self.saved_settings['virtualedit']
let &cursorline = self.saved_settings['cursorline']
let &lazyredraw = self.saved_settings['lazyredraw']
let &paste = self.saved_settings['paste']
endif
endfunction
@ -742,7 +753,7 @@ function! s:feedkeys(keys)
endfunction
" Take the user input and apply it at every cursor
function! s:process_user_inut()
function! s:process_user_input()
" Grr this is frustrating. In Insert mode, between the feedkey call and here,
" the current position could actually CHANGE for some odd reason. Forcing a
" position reset here
@ -876,7 +887,7 @@ function! s:exit()
let exit = 1
endif
if exit
call s:cm.reset(1)
call s:cm.reset(1, 1)
return 1
endif
return 0

View file

@ -160,7 +160,6 @@ like the following in your vimrc: >
cursors is lost. This is a implementation decision to keep the input
perfectly synced in all locations, at the cost of potentially losing user
input.
- Performance in terminal vim degrades significantly with more cursors
- Select mode is not implemented
==============================================================================

View file

@ -270,4 +270,19 @@ describe "Multiple Cursors" do
hello world
EOF
end
specify "#set paste mode" do
before <<-EOF
hello
hello
EOF
type ':set paste<CR><C-n><C-n>cworld<Esc>:set nopaste<CR>'
after <<-EOF
world
world
EOF
end
end

View file

@ -77,11 +77,10 @@ fun! snipMate#expandSnip(snip, col)
endif
endif
call setline(lnum, line.snipLines[0])
" Autoindent snippet according to previous indentation
let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1
call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val"))
" Insert snippet with proper indentation
let indent = indent(lnum) + 1
call setline(lnum, line . snipLines[0])
call append(lnum, map(snipLines[1:], "empty(v:val) ? v:val : '" . strpart(line, 0, indent - 1) . "' . v:val"))
" Open any folds snippet expands into
if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif
@ -391,7 +390,8 @@ endf
" if triggername is not set 'default' is assumed
fun! snipMate#ReadSnippetsFile(file)
let result = []
if !filereadable(a:file) | return result | endif
let new_scopes = []
if !filereadable(a:file) | return [result, new_scopes] | endif
let r_guard = '^guard\s\+\zs.*'
let inSnip = 0
let guard = 1
@ -421,9 +421,12 @@ fun! snipMate#ReadSnippetsFile(file)
let trigger = strpart(trigger, 0, space - 1)
endif
let content = ''
elseif line[:6] == 'extends'
call extend(new_scopes, map(split(strpart(line, 8)),
\ "substitute(v:val, ',*$', '', '')"))
endif
endfor
return result
return [result, new_scopes]
endf
" adds scope aliases to list.
@ -448,7 +451,14 @@ fun! s:AddScopeAliases(list)
endf
function! s:Glob(path, expr)
return filter(split(globpath(a:path, a:expr), "\n"), 'filereadable(v:val)')
let res = []
for p in split(a:path, ',')
let h = fnamemodify(a:expr, ':h')
if isdirectory(p . '/' . h)
call extend(res, split(glob(p . '/' . a:expr), "\n"))
endif
endfor
return filter(res, 'filereadable(v:val)')
endfunction
" returns dict of
@ -467,7 +477,7 @@ function! snipMate#GetSnippetFiles(mustExist, scopes, trigger)
let paths = join(funcref#Call(s:c.snippet_dirs), ',')
let result = {}
let scopes = s:AddScopeAliases(a:scopes)
let trigger = escape(a:trigger, '{}*[]`')
let trigger = escape(a:trigger, "*[]?{}`'$")
" collect existing files
for scope in scopes
@ -490,7 +500,7 @@ function! snipMate#GetSnippetFiles(mustExist, scopes, trigger)
if !a:mustExist
for p in split(paths, ',')
let p .= '/' . scope . '.snippets'
let p .= '/snippets/' . scope . '.snippets'
let result[p] = get(result, p, {'exists': 0, 'type': 'snippets'})
endfor
endif
@ -514,21 +524,27 @@ endf
" default triggers based on paths
fun! snipMate#DefaultPool(scopes, trigger, result)
let triggerR = substitute(a:trigger,'*','.*','g')
let extra_scopes = []
for [f,opts] in items(snipMate#GetSnippetFiles(1, a:scopes, a:trigger))
let opts.name_prefix = matchstr(f, '\v[^/]+\ze/snippets') . ' ' . opts.name_prefix
if opts.type == 'snippets'
for [trigger, name, contents, guard] in cached_file_contents#CachedFileContents(f, s:c.read_snippets_cached, 0)
let [snippets, extension] = cached_file_contents#CachedFileContents(f, s:c.read_snippets_cached, 0)
for [trigger, name, contents, guard] in snippets
if trigger !~ escape(triggerR,'~') | continue | endif
if snipMate#EvalGuard(guard)
call snipMate#SetByPath(a:result, [trigger, opts.name_prefix.' '.name], contents)
endif
endfor
call extend(extra_scopes, extension)
elseif opts.type == 'snippet'
call snipMate#SetByPath(a:result, [opts.trigger, opts.name_prefix.' '.opts.name], funcref#Function('return readfile('.string(f).')'))
else
throw "unexpected"
endif
endfor
if !empty(extra_scopes)
call snipMate#DefaultPool(extra_scopes, a:trigger, a:result)
endif
endf
" return a dict of snippets found in runtimepath matching trigger

View file

@ -1,7 +1,6 @@
*snipMate.txt* Plugin for using TextMate-style snippets in Vim.
snipMate *snippet* *snippets* *snipMate*
Last Change: December 27, 2009
|snipMate-installation| Installation
|snipMate-description| Description
@ -306,6 +305,15 @@ TextMates's functionality, use the |system()| function. E.g.: >
will insert the current date, assuming you are on a Unix system. Note that you
can also (and should) use |strftime()| for this example.
*snipMate-extends*
Borrowing from UltiSnips, .snippets files can also contain an extends
directive, for example: >
extends html, javascript, css
will tell SnipMate to also read html, javascript, and css snippets.
Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()*
Since the current filename is used often in snippets, a default function
@ -420,6 +428,15 @@ Perhaps some of these features will be added in a later release.
==============================================================================
CHANGELOG *snipMate-changelog*
0.86 - 2013-06-15
-----------------
* Use more idiomatic <Plug> maps
* Fix disappearing variables bug (hpesoj)
* Fix cursor position bug when a variable is on the same line as the stop
* Fix undo point creation causing problems with Supertab
* Fix bug where SnipMate would use a typed trigger as a regular expression
0.85 - 2013-04-03
-----------------

View file

@ -1,6 +1,6 @@
" File: snipMate.vim
" Author: Michael Sanders
" Version: 0.85
" Version: 0.86
" Description: snipMate.vim implements some of TextMate's snippets features in
" Vim. A snippet is a piece of often-typed text that you can
" insert into your document using a trigger word followed by a "<tab>".
@ -56,30 +56,15 @@ let s:snipMate['get_snippets'] = get(s:snipMate, 'get_snippets', funcref#Functio
" snippets. You can replace it with your own implementation. Defaults to all
" directories in &rtp/snippets/*
let s:snipMate['snippet_dirs'] = get(s:snipMate, 'snippet_dirs', funcref#Function('return split(&runtimepath,",")'))
if type(s:snipMate['snippet_dirs']) == type([])
call map(s:snipMate['snippet_dirs'], 'expand(v:val)')
endif
" _ is default scope added always
"
" &ft honors multiple filetypes and syntax such as in set ft=html.javascript syntax=FOO
let s:snipMate['get_scopes'] = get(s:snipMate, 'get_scopes', funcref#Function('return split(&ft,"\\.")+[&syntax, "_"]'))
if !exists('snippets_dir')
let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g')
endif
" Processes a single-snippet file; optionally add the name of the parent
" directory for a snippet with multiple matches.
fun! s:ProcessFile(file, ft, ...)
let keyword = fnamemodify(a:file, ':t:r')
if keyword == '' | return | endif
try
let text = join(readfile(a:file), "\n")
catch /E484/
echom "Error in snipMate.vim: couldn't read file: ".a:file
endtry
return a:0 ? MakeSnip(a:ft, a:1, text, keyword)
\ : MakeSnip(a:ft, keyword, text)
endf
" dummy for compatibility - will be removed
" moving to autoload to improve loading speed and debugging
fun! TriggerSnippet()

View file

@ -6,10 +6,11 @@ syn match tabStop '\$\d\+'
syn match snipEscape '\\\\\|\\`'
syn match snipCommand '\%(\\\@<!\%(\\\\\)*\)\@<=`.\{-}\%(\\\@<!\%(\\\\\)*\)\@<=`'
syn match snippet '^snippet.*' contains=multiSnipText,snipKeyword
syn match snippet '^extends.*' contains=snipKeyword
syn match snippet '^guard\s\+.*' contains=multiSnipText,snipKeyword
syn match multiSnipText '\S\+ \zs.*' contained
syn match snipKeyword '^snippet'me=s+8 contained
syn match snipError "^[^#s\t].*$"
syn match snipKeyword '^(snippet|extends)'me=s+8 contained
syn match snipError "^[^#se\t].*$"
hi link snippet Identifier
hi link snipComment Comment

View file

@ -10,6 +10,7 @@ Elliot Murphy
Eustaquio Rangel
Henrik Nyh
Honza Pokorny
Iuri Fernandes Queiroz
Jakub Nawalaniec
James F. Herdman
Jon Bernard
@ -38,6 +39,7 @@ Dmitry Dementev
Travis Holton
Chrisyue
Erik Westrup
Matt Deacalion Stevens
TODO: add contributors from github.com/SirVer/Ultisnip having contributed to
github.com/SirVer/Ultisnip/UltiSnips/* files

View file

@ -50,6 +50,49 @@ of the snippets by setting the "always_use_first_snippet" option to 1.
If you have VimL only (vim without python support) your best option is using
garbas/vim-snipmate and cope with the minor bugs found in the engine.
Policies / for contributors
===========================
Some snippets are useful for almost all languages, so let's try to have the same
triggers for them:
```
if : if without else
ife: if $1 else $2
eif : else if ($1) { .. }
el : else ..
```
If you're not satisfied with these defaults, open a ticket that we implement
aliasing. Then you can remap "else" to "el" or the like.
Don't add stupid placeholder default texts like
```
if (${1:condition}){
${2:some code here}
}
```
instead use:
```
if (${1}){
${2}
}
```
Exception: Functions which are used less often, such as Vim's matchall(), matchstr()
functions which case hints may be helpful to remember order. In the VimL case
get vim-dev plugin which has function completion
Thus for conditions (while, if ..) and block bodies just use ${N} - Thanks
Open questions:
What about one line if ee then .. else .. vs if \n .. then \n ... \n else \n .. ?
What about wh(ile), which trigger?
Discuss at: https://github.com/honza/vim-snippets/issues/230
Related repositories
====================
We also encourage people to maintain sets of snippets for particular use cases
@ -63,10 +106,11 @@ so that all users can benefit from them. People can list their snippet reposito
Installation using VAM: "github:rbonvall/snipmate-snippets-bib"
## If you believe in the success of vim-snipmate
then you may also want to have a look at [vim-git-wiki](http://github.com/MarcWeber/vim-git-wiki).
If you contribute to this git based wiki editable by Vim we have a chance
of making it official at www.vim.org.
Future - ideas - examples
=========================
[overview snippet engines](http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html)
If you have ideas you can add them to that list of "snippet engine features by example".
Historical notes
================
@ -86,19 +130,23 @@ add snippets/ruby-1.9.snippets (1.9 only)
then configure github.com/garbas/vim-snipmate this way:
let g:snipMate = {}
let g:snipMate.scope_aliases = {}
let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9'
```vim
let g:snipMate = {}
let g:snipMate.scope_aliases = {}
let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9'
```
or github.com/MarcWeber/UltiSnips this way:
let g:UltiSnips = {}
```vim
let g:UltiSnips = {}
let g:UltiSnips.snipmate_ft_filter = {
let g:UltiSnips.snipmate_ft_filter = {
\ 'default' : {'filetypes': ["FILETYPE"] },
\ 'ruby' : {'filetypes': ["ruby", "ruby-rails", "ruby-1.9"] },
```
If it happens that you work on a project requiring ruby-1.8 snippets instead,
consider using vim-addon-local-vimrc and override the filetypes.
@ -129,6 +177,8 @@ vim-snippets is not like the "linux kernel".
* Ruby - [taq](http://github.com/taq)
* PHP - [chrisyue](http://github.com/chrisyue)
* Scala - [gorodinskiy](https://github.com/gorodinskiy)
* Falcon - [steveno](https://github.com/steveno)
* Elixir - [iurifq](https://github.com/iurifq)
Contributing notes
------------------

View file

@ -1,75 +1,83 @@
# From the TextMate bundle
# with some modification
snippet fun "Function" b
${1:name} = (${2:args}) ->
${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2] else ""`->
${0:# body...}
endsnippet
snippet bfun "Function (bound)" b
${1:(${2:args}) }=>
${0:# body...}
snippet bfun "Function (bound)" i
`!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] and not t[2].startswith("\n") else ""`${2:expr}
endsnippet
snippet if "If" b
snippet if "If"
if ${1:condition}
${0:# body...}
endsnippet
snippet ife "If .. Else" b
snippet ife "If .. Else"
if ${1:condition}
${2:# body...}
else
${3:# body...}
endsnippet
snippet elif "Else if" b
snippet eif "Else if" b
else if ${1:condition}
${0:# body...}
endsnippet
snippet ifte "Ternary if" b
snippet ifte "Ternary if"
if ${1:condition} then ${2:value} else ${3:other}
endsnippet
snippet unl "Unless" b
snippet unl "Unless"
${1:action} unless ${2:condition}
endsnippet
snippet fora "Array Comprehension" b
snippet fora "Array Comprehension"
for ${1:name} in ${2:array}
${0:# body...}
endsnippet
snippet foro "Object Comprehension" b
snippet foro "Object Comprehension"
for ${1:key}, ${2:value} of ${3:Object}
${0:# body...}
endsnippet
snippet forr "Range Comprehension (inclusive)" b
for ${1:name} in [${2:start}..${3:finish}]${4: by ${5:step}}
snippet forr "Range Comprehension (inclusive)"
for ${1:name} in [${2:start}..${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
${0:# body...}
endsnippet
snippet forrex "Range Comprehension (exclusive)" b
for ${1:name} in [${2:start}...${3:finish}]${4: by ${5:step}}
snippet forrex "Range Comprehension (exclusive)"
for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
${0:# body...}
endsnippet
snippet swi "Switch" b
snippet swi "Switch"
switch ${1:object}
when ${2:value}
${0:# body...}
${3:# body...}
else
$0
endsnippet
snippet swit "Switch when .. then"
switch ${1:object}
when ${2:condition}`!p snip.rv = " then " if t[3] else ""`${3:value}
else`!p snip.rv = " " if t[4] and not t[4].startswith("\n") else ""`${4:value}
endsnippet
snippet cla "Class" b
class ${1:ClassName}${2: extends ${3:Ancestor}}
class ${1:ClassName}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor}
${4:constructor: (${5:args}) ->
${6:# body...}}
$7
${3:constructor:`!p snip.rv = " (" if t[4] else ""`${4:args}`!p snip.rv = ")" if t[4] else ""` ->
${5:# body...}}
$0
endsnippet
snippet try "Try .. Catch" b
snippet try "Try .. Catch"
try
$1
catch ${2:error}
@ -80,7 +88,7 @@ snippet req "Require" b
${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'})
endsnippet
snippet # "Interpolated Code"
snippet # "Interpolated Code" i
#{$1}$0
endsnippet

View file

@ -126,7 +126,7 @@ else
}
endsnippet
snippet elif "else if (elif)" b
snippet eif "else if (elif)" b
else if(${1:/*condition*/})
{
${VISUAL}${0:/*code*/}
@ -576,7 +576,7 @@ snippet module "New module (module)" b
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module ${2}.`!v Filename('$1', 'name')`;
module ${2}.`!v vim_snippets#Filename('$1', 'name')`;
${3}

View file

@ -76,7 +76,7 @@ snippet if
{% endif %}
endsnippet
snippet else
snippet el
{% else %}
${1}
endsnippet

View file

@ -263,7 +263,7 @@ snippet st "submit_tag"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet else "else (ERB)"
snippet el "else (ERB)"
<% else %>
endsnippet

View file

@ -1,13 +1,13 @@
snippet if "if ... then ... else ..."
snippet ife "if ... then ... else ..."
if ${1:condition}
then ${2:expression}
else ${3:expression}
endsnippet
snippet case "case ... of ..."
case ${1:expression} of
${2:pattern} -> ${3:expression}
${4:pattern} -> ${5:expression}
case ${1} of
${2} -> ${3}
${4} -> ${5}
endsnippet
snippet :: "Type signature"

View file

@ -0,0 +1,31 @@
# more can be found in snippets/html_minimal.snippets
# these UltiSnips override snippets because nested placeholders are being used
snippet id
id="${1}"${2}
endsnippet
snippet idn
id="${1}" name="${2:$1}"
endsnippet
snippet label_and_input
<label for="${2:$1}">${1}</label>
<input type="${3:text}" name="${4:$2}"${5: id="${6:$2}"} value="${7}" />${8}
endsnippet
snippet input
<input type="${1:text}" value="${2}" name="${3}"${4: id="${5:$3}}/>${7}
endsnippet
snippet submit
<input type="submit" value="${2}" ${3}/>${7}
endsnippet
snippet textarea
<textarea name="$2"${3: id="$4"}>$5</textarea>
endsnippet
snippet img
<img src="$1"${2: alt="$3"}/>
endsnippet

View file

@ -59,7 +59,7 @@ default:
$0
endsnippet
snippet elif "else if" b
snippet eif "else if" b
else if ($1)`!p nl(snip)`{
$0
}

View file

@ -50,12 +50,19 @@ function ${1:function_name} (${2:argument}) {
}
endsnippet
# for one line if .. else you usually use a ? b : c
snippet ife "if ___ else"
if (${1:true}) {$0} else{};
if (${1}) {
{$2}
} else {
{$3}
};
endsnippet
snippet if "if"
if (${1:true}) {$0};
if (${1}) {
{$2}
};
endsnippet
snippet timeout "setTimeout function"

View file

@ -4,17 +4,17 @@ endsnippet
snippet open "open"
let open ${1:module} in
${2:e}
${2}
endsnippet
snippet try "try"
try ${1:e}
try ${1}
with ${2:Not_found} -> ${3:()}
endsnippet
snippet ref "ref"
let ${1:name} = ref ${2:val} in
${3:e}
let ${1} = ref ${2} in
${3}
endsnippet
snippet matchl "pattern match on a list"
@ -24,88 +24,83 @@ match ${1:list} with
endsnippet
snippet matcho "pattern match on an option type"
match ${1:x} with
| Some(${2:y}) -> ${3:()}
match ${1} with
| Some(${2}) -> ${3:()}
| None -> ${4:()}
endsnippet
snippet fun "anonymous function"
(fun ${1:x} -> ${2:x})
(fun ${1} -> ${2})
endsnippet
snippet cc "commment"
(* ${1:comment} *)
(* ${1} *)
endsnippet
snippet let "let .. in binding"
let ${1:x} = ${2:v} in
${3:e}
let ${1} = ${2} in
${3}
endsnippet
snippet lr "let rec"
let rec ${1:f} =
${2:expr}
let rec ${1} =
${2}
endsnippet
snippet if "if"
if ${1:(* condition *)} then
${2:(* A *)}
snippet ife "if"
if ${1} then
${2}
else
${3:(* B *)}
${3}
endsnippet
snippet If "If"
if ${1:(* condition *)} then
${2:(* A *)}
snippet if "If"
if ${1} then
${2}
endsnippet
snippet while "while"
while ${1:(* condition *)} do
${2:(* A *)}
while ${1} do
${2}
done
endsnippet
snippet for "for"
for ${1:i} = ${2:1} to ${3:10} do
${4:(* BODY *)}
${4}
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}
match ${1} with
| ${2} -> ${3}
endsnippet
snippet class "class"
class ${1:name} = object
${2:methods}
${2}
end
endsnippet
snippet obj "obj"
object
${2:methods}
${2}
end
endsnippet
snippet Obj "object"
object (self)
${2:methods}
${2}
end
endsnippet
snippet {{ "object functional update"
{< ${1:x} = ${2:y} >}
{< ${1} = ${2} >}
endsnippet
snippet beg "beg"
begin
${1:block}
${1}${VISUAL}
end
endsnippet
@ -115,19 +110,19 @@ endsnippet
snippet mod "module - no signature"
module ${1:(* Name *)} = struct
${2:(* BODY *)}
${2}
end
endsnippet
snippet Mod "module with signature"
module ${1:(* Name *)} : ${2:(* SIG *)} = struct
${3:(* BODY *)}
${3}
end
endsnippet
snippet sig "anonymous signature"
sig
${2:(* BODY *)}
${2}
end
endsnippet
@ -137,32 +132,32 @@ endsnippet
snippet func "define functor - no signature"
module ${1:M} (${2:Arg} : ${3:ARG}) = struct
${4:(* BODY *)}
${4}
end
endsnippet
snippet Func "define functor - with signature"
module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct
${5:(* BODY *)}
${5}
end
endsnippet
snippet mot "Declare module signature"
module type ${1:(* Name *)} = sig
${2:(* BODY *)}
${2}
end
endsnippet
snippet module "Module with anonymous signature"
module ${1:(* Name *)} : sig
${2:(* SIGNATURE *)}
${2}
end = struct
${3:(* BODY *)}
${3}
end
endsnippet
snippet oo "odoc"
(** ${1:odoc} *)
(** ${1} *)
endsnippet
snippet qt "inline qtest"

View file

@ -11,8 +11,8 @@ endsnippet
snippet do "do"
do {
${2:// code... }
} while (${1:/* condition */});"
${2}
} while (${1});"
endsnippet
snippet doc_f "doc_f"
@ -37,21 +37,21 @@ interface ${1:someClass}
} // END interface $1"
endsnippet
snippet else "else"
snippet el "else"
else {
${1:// code...}
${1}
}
endsnippet
snippet for "for"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:// code...}
${4}
}
endsnippet
snippet foreachk "foreachk"
foreach ($${1:variable} as $${2:key} => $${3:value}){
${4:// code...}
${4}
}
endsnippet
@ -60,8 +60,8 @@ $_GET['${1}']${2}
endsnippet
snippet if "if"
if (${1:/* condition */}) {
${2:// code...}
if (${1}) {
${2}
}
endsnippet
@ -210,9 +210,9 @@ endsnippet
snippet ife "if else"
if (${1:/* condition */}) {
${2:// code...}
${2}
} else {
${3:// code...}
${3}
}
$0
endsnippet
@ -227,7 +227,7 @@ class $1
{
public function ${3:__construct}(${4:$options})
{
${4:// code}
${4}
}
}
$0

View file

@ -1,61 +1,314 @@
# -*- coding: utf-8 -*-
###########################################################################
# General Stuff #
###########################################################################
global !p
import vim
from os import path as ospath
from string import Template
import re
from collections import Counter
#http://docutils.sourceforge.net/docs/ref/rst/roles.html
TEXT_ROLES = ['emphasis','literal','code','math',
'pep-reference','rfc-reference',
'strong','subscript','superscript',
'title-reference','raw']
TEXT_ROLES_REGEX = r'\.\.\srole::?\s(w+)'
#http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
SPECIFIC_ADMONITIONS = ["attention", "caution", "danger",
"error", "hint", "important", "note",
"tip", "warning"]
#http://docutils.sourceforge.net/docs/ref/rst/directives.html
DIRECTIVES = ['topic','sidebar','math','epigraph',
'parsed-literal','code','highlights',
'pull-quote','compound','container',
'list-table','class','sectnum',
'role','default-role','unicode',
'raw']
NONE_CONTENT_DIRECTIVES = ['rubric', 'contents', 'header',
'footer', 'date', 'include', 'title']
INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include']
# CJK chars
# http://stackoverflow.com/questions/2718196/find-all-chinese-text-in-a-string-using-python-and-regex
CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
def has_cjk(char):
"""
Detect char contains CJK character
:param char: characters needs to be detect
"""
try:
CJK_RE.finditer(char).next()
except StopIteration:
return False
else:
return True
def real_filename(filename):
"""peal extension name off if possible
# i.e. "foo.bar.png will return "foo.bar"
"""
return ospath.splitext(filename)[0]
def check_file_exist(rst_path, relative_path):
"""
For RST file, it can just include files as relative path.
:param rst_path: absolute path to rst file
:param relative_path: path related to rst file
:return: relative file's absolute path if file exist
"""
abs_path = ospath.join(ospath.dirname(rst_path), relative_path)
if ospath.isfile(abs_path):
return abs_path
def rst_char_len(char):
"""
return len of string which fit in rst
For instance:chinese "我" decode as only one character,
However, the rst interpreter needs 2 "=" instead of 1.
:param: char needs to be count
"""
return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char)
def make_items(times, leading='+'):
"""
make lines with leading char multitimes
:param: times, how many times you need
:param: leading, leading character
"""
times = int(times)
if leading == 1:
msg = ""
for x in xrange(1, times+1):
msg += "%s. Item\n" % x
return msg
else:
return ("%s Item\n" % leading) * times
def look_up_directives(regex, fpath):
"""
find all directive args in given file
:param: regex, the regex that needs to match
:param: path, to path to rst file
:return: list, empty list if nothing match
"""
try:
with open(fpath) as source:
match = re.findall(regex, source.read())
except IOError:
match = []
return match
def get_popular_code_type():
"""
find most popular code type in the given rst
:param path: file to detect
:return: string, most popular code type in file
"""
buf = "".join(vim.current.buffer)
types = re.findall(r'[:|\.\.\s]code::?\s(\w+)', buf)
try:
popular_type = Counter(types).most_common()[0][0]
except IndexError:
popular_type = "lua" # Don't break default
return popular_type
def complete(t, opts):
"""
get options that start with t
:param t: query string
:param opts: list that needs to be completed
:return: a string that start with t
"""
msg = "({0})"
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
if not len(opts):
msg = "{0}"
return msg.format("|".join(opts))
endglobal
snippet part "Part" b
`!p snip.rv = len(t[1])*'#'`
`!p snip.rv = rst_char_len(t[1])*'#'`
${1:Part name}
`!p snip.rv = len(t[1])*'#'`
`!p snip.rv = rst_char_len(t[1])*'#'`
$0
endsnippet
snippet sec "Section" b
${1:Section name}
`!p snip.rv = len(t[1])*'='`
`!p snip.rv = rst_char_len(t[1])*'='`
$0
endsnippet
snippet ssec "Subsection" b
${1:Section name}
`!p snip.rv = len(t[1])*'-'`
`!p snip.rv = rst_char_len(t[1])*'-'`
$0
endsnippet
snippet sssec "Subsubsection" b
${1:Section name}
`!p snip.rv = len(t[1])*'^'`
`!p snip.rv = rst_char_len(t[1])*'^'`
$0
endsnippet
snippet chap "Chapter" b
`!p snip.rv = len(t[1])*'*'`
`!p snip.rv = rst_char_len(t[1])*'*'`
${1:Chapter name}
`!p snip.rv = len(t[1])*'*'`
`!p snip.rv = rst_char_len(t[1])*'*'`
$0
endsnippet
snippet para "Paragraph" b
${1:Paragraph name}
`!p snip.rv = len(t[1])*'"'`
`!p snip.rv = rst_char_len(t[1])*'"'`
$0
endsnippet
snippet em "Emphasize string" i
`!p
# dirty but works with CJK charactor detection
if has_cjk(vim.current.line):
snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p
if has_cjk(vim.current.line):
snip.rv ="\ "
else:
snip.rv = " "
`$0
endsnippet
snippet st "Strong string" i
`!p
if has_cjk(vim.current.line):
snip.rv ="\ "`**${1:${VISUAL:Strong}}**`!p
if has_cjk(vim.current.line):
snip.rv ="\ "
else:
snip.rv = " "
`$0
endsnippet
snippet "li(st)? (?P<num>\d+)" "List" br
$0
`!p
# usage: li 4<tab>
# which will extand into a unordered list contains 4 items
snip.rv = make_items(match.groupdict()['num'])
`
endsnippet
snippet "ol(st)? (?P<num>\d+)" "Order List" br
$0
`!p
# usage: ol 4<tab>
# which will extand into a ordered list contains 4 items
snip.rv = make_items(match.groupdict()['num'], 1)
`
endsnippet
###########################################################################
# More Specialized Stuff. #
###########################################################################
snippet cb "Code Block" b
.. code-block:: ${1:lua}
.. code-block:: ${1:`!p snip.rv = get_popular_code_type()`}
${2:code}
$0
endsnippet
# match snippets :
# img, inc, fig
snippet id "Includable Directives" b
`!p
real_name=real_filename(ospath.basename(t[2]))
di=t[1][:2]
link=""
content=""
if di == 'im':
link = "|{0}|".format(real_name)
if di == 'fi':
content="""
:alt: {0}
{0}""".format(real_name)
`
..`!p snip.rv = " %s" % link if link else ""` $1`!p snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)`:: ${2:file}`!p if content:
snip.rv +=" "+content`
`!p
# Tip of whether file is exist in comment type
if not check_file_exist(path, t[2]):
snip.rv='.. FILE {0} does not exist'.format(t[2])
else:
snip.rv=""
`$0
endsnippet
snippet di "Directives" b
.. $1`!p snip.rv=complete(t[1], DIRECTIVES)`:: $2
${3:Content}
$0
endsnippet
snippet nd "None Content Directives" b
.. $1`!p snip.rv=complete(t[1], NONE_CONTENT_DIRECTIVES)`:: $2
$0
endsnippet
snippet sa "Specific Admonitions" b
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`::
${2:Content}
$0
endsnippet
#it will be trigger at start of line or after a word
snippet ro "Text Roles" w
\ :$1`!p snip.rv=complete(t[1],
TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX,
path))`:\`$2\`\
endsnippet
############
# Sphinx #
############
snippet sid "SideBar" b
.. sidebar:: ${1:SideBar Title}
${2:SideBar Content}
endsnippet
# vim:ft=snippets:

View file

@ -25,7 +25,7 @@ endsnippet
snippet if "if <condition> ... end"
if ${1:condition}
${2:# TODO}
${2}
end
endsnippet
@ -33,9 +33,9 @@ endsnippet
snippet ife "if <condition> ... else ... end"
if ${1:condition}
${2:# TODO}
${2}
else
${3:# TODO}
${3}
end
endsnippet
@ -43,11 +43,11 @@ endsnippet
snippet ifee "if <condition> ... elseif <condition> ... else ... end"
if ${1:condition}
${2:# TODO}
${2}
elsif ${3:condition}
${4:# TODO}
${4}
else
${0:# TODO}
${0}
end
endsnippet
@ -55,7 +55,7 @@ endsnippet
snippet unless "unless <condition> ... end"
unless ${1:condition}
${0:# TODO}
${0}
end
endsnippet
@ -63,9 +63,9 @@ endsnippet
snippet unlesse "unless <condition> ... else ... end"
unless ${1:condition}
${2:# TODO}
${2}
else
${0:# TODO}
${0}
end
endsnippet
@ -73,11 +73,11 @@ endsnippet
snippet unlesee "unless <condition> ... elseif <condition> ... else ... end"
unless ${1:condition}
${2:# TODO}
${2}
elsif ${3:condition}
${4:# TODO}
${4}
else
${0:# TODO}
${0}
end
endsnippet
@ -85,7 +85,7 @@ endsnippet
snippet "\b(de)?f" "def <name>..." r
def ${1:function_name}${2: ${3:*args}}
${0:# TODO}
${0}
end
endsnippet
@ -93,7 +93,7 @@ endsnippet
snippet defi "def initialize ..."
def initialize${1: ${2:*args}}
${0:# TODO}
${0}
end
endsnippet
@ -101,23 +101,23 @@ endsnippet
snippet defr "def <name> ... rescue ..."
def ${1:function_name}${2: ${3:*args}}
${4:# TODO}
${4}
rescue
${0:# TODO}
${0}
end
endsnippet
snippet For "(<from>..<to>).each { |<i>| <block> }"
(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} }
(${1:from}..${2:to}).each { |${3:i}| ${4} }
endsnippet
snippet for "(<from>..<to>).each do |<i>| <block> end"
(${1:from}..${2:to}).each do |${3:i}|
${0:# TODO}
${0}
end
endsnippet
@ -138,42 +138,42 @@ endsnippet
snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} }
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3} }
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:# TODO}
${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}| ${3:# TODO} }
`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3} }
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:# TODO}
${0}
end
endsnippet
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} }
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3} }
endsnippet
snippet "(\S+)\.reject" ".reject do <key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}|
${0:# TODO}
${0}
end
endsnippet
@ -194,56 +194,56 @@ endsnippet
snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} }
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3} }
endsnippet
snippet "(\S+)\.sort" ".sort do |<a>,<b>| <block> end" r
`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}|
${0:# TODO}
${0}
end
endsnippet
snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} }
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2} }
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:# TODO}
${0}
end
endsnippet
snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} }
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2} }
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:# TODO}
${0}
end
endsnippet
snippet Each "<elements>.each { |<element>| <block> }"
${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} }
${1:elements}.each { |${2:${1/s$//}}| ${3} }
endsnippet
snippet each "<elements>.each do |<element>| <block> end"
${1:elements}.each do |${2:${1/s$//}}|
${0:# TODO}
${0}
end
endsnippet
@ -251,14 +251,14 @@ endsnippet
snippet each_?s(lice)? "<array>.each_slice(n) do |slice| <block> end"
each_slice(${1:2}) do |${2:slice}|
${0:# TODO}
${0}
end
endsnippet
snippet Each_?s(lice)? "<array>.each_slice(n) { |slice| <block> }"
each_slice(${1:2}) { |${2:slice}| ${3:# TODO} }
each_slice(${1:2}) { |${2:slice}| ${3} }
endsnippet
@ -273,7 +273,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}| ${2:# TODO} }
`}| ${2} }
endsnippet
@ -288,7 +288,7 @@ try:
except:
snip.rv = 'element'
`}|
${0:# TODO}
${0}
end
endsnippet
@ -303,7 +303,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}| ${2:# TODO} }
`}| ${2} }
endsnippet
@ -318,7 +318,7 @@ try:
except:
snip.rv = 'element'
`}|
${0:# TODO}
${0}
end
endsnippet
@ -333,7 +333,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}| ${2:# TODO} }
`}| ${2} }
endsnippet
@ -348,7 +348,7 @@ try:
except:
snip.rv = 'element'
`}|
${0:# TODO}
${0}
end
endsnippet
@ -364,7 +364,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`},${2:i}| ${3:# TODO} }$0
`},${2:i}| ${3} }$0
endsnippet
@ -379,7 +379,7 @@ try:
except:
snip.rv = 'element'
`},${2:i}|
${0:# TODO}
${0}
end
endsnippet
@ -387,14 +387,14 @@ endsnippet
snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} }
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3} }
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:# TODO}
${0}
end
endsnippet
@ -424,26 +424,24 @@ snippet "(\S+)\.Index" ".index do |item| ... end" r
end
endsnippet
snippet do "do |<key>| ... end" i
do ${1:|${2:key}|}
$0
end
endsnippet
snippet Do "do ... end" i
# comments about do and dov see snippets/ruby.snippets
snippet do "do ... end" i
do
$0
end
endsnippet
snippet dov "do |<key>| ... end" i
do |${0:v}|
$1
end
endsnippet
snippet until "until <expression> ... end"
until ${1:expression}
${0:# TODO}
${0}
end
endsnippet
@ -451,7 +449,7 @@ endsnippet
snippet Until "begin ... end until <expression>"
begin
${0:# TODO}
${0}
end until ${1:expression}
endsnippet
@ -459,7 +457,7 @@ endsnippet
snippet while "while <expression> ... end"
while ${1:expression}
${0:# TODO}
${0}
end
endsnippet
@ -467,7 +465,7 @@ endsnippet
snippet While "begin ... end while <expression>"
begin
${0:# TODO}
${0}
end while ${1:expression}
endsnippet
@ -493,9 +491,9 @@ endsnippet
snippet begin "begin ... rescue ... end"
begin
${1:# TODO}
${1}
rescue
${0:# TODO}
${0}
end
endsnippet

View file

@ -16,14 +16,14 @@ foreach ${1:var} ${2:\$list} {
endsnippet
snippet if "if... (if)" b
if {${1:condition}} {
if {${1}} {
${2}
}
endsnippet
snippet proc "proc... (proc)" b
proc ${1:name} {${2:args}} \
proc ${1} {${2}} \
{
${3}
}
@ -41,7 +41,7 @@ switch ${1:-exact} -- ${2:\$var} {
endsnippet
snippet while "while... (while)" b
while {${1:condition}} {
while {${1}} {
${2}
}

View file

@ -25,30 +25,30 @@ endsnippet
snippet f
fun ${1:function_name}(${2})
${3:" code}
${3}
endf
endsnippet
snippet for
for ${1:needle} in ${2:haystack}
${3:" code}
for ${1} in ${2}
${3}
endfor
endsnippet
snippet wh
while ${1:condition}
${2:" code}
while ${1}
${2}
endw
endsnippet
snippet if
if ${1:condition}
${2:" code}
if ${1}
${2}
endif
endsnippet
snippet ife
if ${1:condition}
if ${1}
${2}
else
${3}

View file

@ -0,0 +1,27 @@
" this is well known Filename found in snipmate (and the other engines), but
" rewritten and documented :)
"
" optional arg1: string in which to replace '$1' by filename with extension
" and path dropped. Defaults to $1
" optional arg2: return this value if buffer has no filename
" But why not use the template in this case, too?
" Doesn't make sense to me
fun! vim_snippets#Filename(...)
let template = get(a:000, 0, "$1")
let arg2 = get(a:000, 1, "")
let basename = expand('%:t:r')
if basename == ''
return arg2
else
return substitute(template, '$1', basename, 'g')
endif
endf
" original code:
" fun! Filename(...)
" let filename = expand('%:t:r')
" if filename == '' | return a:0 == 2 ? a:2 : '' | endif
" return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
" endf

View file

@ -109,17 +109,17 @@ snippet try
# For Loop (same as c.snippet)
snippet for for (..) {..}
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */}
${4}
}
# Custom For Loop
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5:/* code */}
${5}
}
# If Condition
snippet if
if (${1:/* condition */}) {
${2:/* code */}
${2}
}
snippet el
else {
@ -131,7 +131,7 @@ snippet t
snippet fun
function ${1:function_name}(${2})${3}
{
${4:/* code */}
${4}
}
# FlxSprite (usefull when using the flixel library)
snippet FlxSprite
@ -144,13 +144,13 @@ snippet FlxSprite
public function $1(${3: X:Number, Y:Number}):void
{
super(X,Y);
${4: //code...}
${4}
}
override public function update():void
{
super.update();
${5: //code...}
${5}
}
}
}

View file

@ -5,17 +5,17 @@ snippet if
snippet el
Else
${1}
snippet elif
snippet eif
ElseIf ${1:condition} Then
${2:; True code}
# If/Else block
snippet ifel
snippet ife
If ${1:condition} Then
${2:; True code}
Else
${3:; Else code}
EndIf
# If/ElseIf/Else block
# If/ElseIf/Else block - because there is eif this is not really neccessary
snippet ifelif
If ${1:condition 1} Then
${2:; True code}

View file

@ -20,7 +20,7 @@ snippet inc
#include <${1:stdio}.h>${2}
# #include "..."
snippet Inc
#include "${1:`Filename("$1.h")`}"${2}
#include "${1:`vim_snippets#Filename("$1.h")`}"${2}
# ifndef...define...endif
snippet ndef
#ifndef $1
@ -41,7 +41,7 @@ snippet #if
#endif
# header include guard
snippet once
#ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`}
#ifndef ${1:`toupper(vim_snippets#Filename('$1_H', 'UNTITLED_H'))`}
#define $1
@ -53,7 +53,7 @@ snippet once
# if
snippet if
if (${1:/* condition */}) {
${2:/* code */}
${2}
}${3}
# else
snippet el
@ -63,8 +63,11 @@ snippet el
# else if
snippet elif
else if (${1:/* condition */}) {
${2:/* code */}
${2}
}${3}
# ifi
snippet ifi
if (${1:/* condition */}) ${2};${3}
# ternary
snippet t
${1:/* condition */} ? ${2:a} : ${3:b}
@ -94,22 +97,22 @@ snippet case
# for
snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */}
${4}
}${5}
# for (custom)
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5:/* code */}
${5}
}${6}
# while
snippet wh
while (${1:/* condition */}) {
${2:/* code */}
${2}
}${3}
# do... while
snippet do
do {
${2:/* code */}
${2}
} while (${1:/* condition */});${3}
##
## Functions
@ -117,7 +120,7 @@ snippet do
snippet fun
${1:void} ${2:function_name}(${3})
{
${4:/* code */}
${4}
}${5}
# function declaration
snippet fund
@ -129,14 +132,14 @@ snippet td
typedef ${1:int} ${2:MyCustomType};${3}
# struct
snippet st
struct ${1:`Filename('$1_t', 'name')`} {
struct ${1:`vim_snippets#Filename('$1_t', 'name')`} {
${2:/* data */}
}${3: /* optional variable list */};${4}
# typedef struct
snippet tds
typedef struct ${2:_$1 }{
${3:/* data */}
} ${1:`Filename('$1_t', 'name')`};${4}
} ${1:`vim_snippets#Filename('$1_t', 'name')`};${4}
# typedef enum
snippet tde
typedef enum {

View file

@ -35,19 +35,19 @@ snippet bfun
${2:# body...}
# Class
snippet cla class ..
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
${2}
snippet cla class .. constructor: ..
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
constructor: (${2:args}) ->
${3}
${4}
snippet cla class .. extends ..
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
${3}
snippet cla class .. extends .. constructor: ..
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
constructor: (${3:args}) ->
${4}
@ -63,7 +63,7 @@ snippet ife
else
${3:# body...}
# Else if
snippet elif
snippet eif
else if ${1:condition}
${2:# body...}
# Ternary If

View file

@ -68,7 +68,7 @@ snippet mu
## Class
# class
snippet cl
class ${1:`Filename('$1', 'name')`}
class ${1:`vim_snippets#Filename('$1', 'name')`}
{
public:
$1(${2});
@ -79,12 +79,12 @@ snippet cl
};
# member function implementation
snippet mfun
${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
${5:/* code */}
${4:void} ${1:`vim_snippets#Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
${5}
}
# namespace
snippet ns
namespace ${1:`Filename('', 'my')`} {
namespace ${1:`vim_snippets#Filename('', 'my')`} {
${2}
} /* namespace $1 */
##
@ -100,13 +100,13 @@ snippet cin
# for i
snippet fori
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */}
${4}
}${5}
# foreach
snippet fore
for (${1:auto} ${2:i} : ${3:container}) {
${4:/* code */}
${4}
}${5}
# iterator
snippet iter
@ -123,9 +123,9 @@ snippet itera
## Lambdas
# lamda (one line)
snippet ld
[${1}](${2}){${3:/* code */}}${4}
[${1}](${2}){${3}}${4}
# lambda (multi-line)
snippet lld
[${1}](${2}){
${3:/* code */}
${3}
}${4}

View file

@ -116,49 +116,49 @@ snippet each
}
# interfaces
snippet interface
public interface ${1:`Filename()`} {
public interface ${1:`vim_snippets#Filename()`} {
${2}
}
snippet if+
public interface ${1:`Filename()`} {
public interface ${1:`vim_snippets#Filename()`} {
${2}
}
# class bodies
snippet class
public class ${1:`Filename()`} {
public class ${1:`vim_snippets#Filename()`} {
${2}
}
snippet cls
${2:public} class ${1:`Filename()`} {
${2:public} class ${1:`vim_snippets#Filename()`} {
${3}
}
snippet cls+
public class ${1:`Filename()`} {
public class ${1:`vim_snippets#Filename()`} {
${2}
}
snippet cls+^
public static class ${1:`Filename()`} {
public static class ${1:`vim_snippets#Filename()`} {
${2}
}
snippet cls&
internal class ${1:`Filename()`} {
internal class ${1:`vim_snippets#Filename()`} {
${2}
}
snippet cls&^
internal static class ${1:`Filename()`} {
internal static class ${1:`vim_snippets#Filename()`} {
${2}
}
snippet cls|
protected class ${1:`Filename()`} {
protected class ${1:`vim_snippets#Filename()`} {
${2}
}
snippet cls|%
protected abstract class ${1:`Filename()`} {
protected abstract class ${1:`vim_snippets#Filename()`} {
${2}
}
# constructor
snippet ctor
public ${1:`Filename()`}() {
public ${1:`vim_snippets#Filename()`}() {
${2}
}
# properties - auto properties by default.
@ -342,7 +342,7 @@ snippet ms-
}
# structure
snippet struct
public struct ${1:`Filename()`} {
public struct ${1:`vim_snippets#Filename()`} {
${2}
}
# enumeration

View file

@ -9,7 +9,7 @@ snippet so
${2}
snippet main
static void main() {
${1:/* code */}
${1}
}
snippet st
static ${1}
@ -22,9 +22,9 @@ snippet br
snippet th
throw ${1}
snippet cl
class ${1:`Filename("", "untitled")`} ${2}
class ${1:`vim_snippets#Filename("", "untitled")`} ${2}
snippet in
interface ${1:`Filename("", "untitled")`} ${2}
interface ${1:`vim_snippets#Filename("", "untitled")`} ${2}
snippet imp
implements ${1}
snippet ext
@ -57,15 +57,15 @@ snippet for
}
snippet fore
for (final ${2:item} in ${1:itemList}) {
${3:/* code */}
${3}
}
snippet wh
while (${1:/* condition */}) {
${2:/* code */}
${2}
}
snippet dowh
do {
${2:/* code */}
${2}
} while (${1:/* condition */});
snippet as
assert(${1:/* condition */});

View file

@ -0,0 +1,122 @@
snippet do
do
${1}
end
snippet if if .. do .. end
if ${1} do
${2}
end
snippet if if .. do: ..
if ${1:condition}, do: ${2}
snippet ife if .. do .. else .. end
if ${1:condition} do
${2}
else
${3}
end
snippet ife if .. do: .. else:
if ${1:condition}, do: ${2}, else: ${3}
snippet unless unless .. do .. end
unless ${1} do
${2}
end
snippet unless unless .. do: ..
unless ${1:condition}, do: ${2}
snippet unlesse unless .. do .. else .. end
unless ${1:condition} do
${2}
else
${3}
end
snippet unlesse unless .. do: .. else:
unless ${1:condition}, do: ${2}, else: ${3}
snippet cond
cond do
${1} ->
${2}
end
snippet case
case ${1} do
${2} ->
${3}
end
snippet def
def ${1:name} do
${2}
end
snippet defim
defimpl ${1:protocol_name}, for: ${2:data_type} do
${3}
end
snippet defma
defmacro ${1:name} do
${2}
end
snippet defmo
defmodule ${1:module_name} do
${2}
end
snippet defp
defp ${1:name} do
${2}
end
snippet defpr
defprotocol ${1:name}, [${2:function}]
snippet defr
defrecord ${1:record_name}, ${2:fields}
snippet doc
@doc """
${1}
"""
snippet fn
fn(${1:args}) -> ${2} end
snippet mdoc
@moduledoc """
${1}
"""
snippet rec
receive do
${1} ->
${2}
end
snippet req
require ${1:module_name}
snippet imp
import ${1:module_name}
snippet ali
alias ${1:module_name}
snippet test
test "${1:test_name}" do
${2}
end
snippet try try .. rescue .. end
try do
${1}
rescue
${2} -> ${3}
end

View file

@ -1,6 +1,6 @@
# module and export all
snippet mod
-module(${1:`Filename('', 'my')`}).
-module(${1:`vim_snippets#Filename('', 'my')`}).
-compile([export_all]).
@ -66,7 +66,7 @@ snippet %p
%% @private
# OTP application
snippet application
-module(${1:`Filename('', 'my')`}).
-module(${1:`vim_snippets#Filename('', 'my')`}).
-behaviour(application).
@ -84,7 +84,7 @@ snippet application
ok.
# OTP supervisor
snippet supervisor
-module(${1:`Filename('', 'my')`}).
-module(${1:`vim_snippets#Filename('', 'my')`}).
-behaviour(supervisor).
@ -107,7 +107,7 @@ snippet supervisor
{ok, {RestartStrategy, Children}}.
# OTP gen_server
snippet gen_server
-module(${1:`Filename('', 'my')`}).
-module(${1:`vim_snippets#Filename('', 'my')`}).
-behaviour(gen_server).
@ -157,4 +157,194 @@ snippet gen_server
%%%===================================================================
%%% Internal functions
%%%===================================================================
# common_test test_SUITE
snippet testsuite
-module(${1:`vim_snippets#Filename('', 'my')`}).
-include_lib("common_test/include/ct.hrl").
%% Test server callbacks
-export([suite/0, all/0, groups/0,
init_per_suite/1, end_per_suite/1,
init_per_group/2, end_per_group/2,
init_per_testcase/2, end_per_testcase/2]).
%% Test cases
-export([
]).
%%--------------------------------------------------------------------
%% COMMON TEST CALLBACK FUNCTIONS
%%--------------------------------------------------------------------
%%--------------------------------------------------------------------
%% Function: suite() -> Info
%%
%% Info = [tuple()]
%% List of key/value pairs.
%%
%% Description: Returns list of tuples to set default properties
%% for the suite.
%%
%% Note: The suite/0 function is only meant to be used to return
%% default data values, not perform any other operations.
%%--------------------------------------------------------------------
suite() ->
[{timetrap,{minutes,10}}].
%%--------------------------------------------------------------------
%% Function: init_per_suite(Config0) ->
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%%
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%% The reason for skipping the suite.
%%
%% Description: Initialization before the suite.
%%
%% Note: This function is free to add any key/value pairs to the Config
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
init_per_suite(Config) ->
Config.
%%--------------------------------------------------------------------
%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
%%
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%%
%% Description: Cleanup after the suite.
%%--------------------------------------------------------------------
end_per_suite(_Config) ->
ok.
%%--------------------------------------------------------------------
%% Function: init_per_group(GroupName, Config0) ->
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%%
%% GroupName = atom()
%% Name of the test case group that is about to run.
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding configuration data for the group.
%% Reason = term()
%% The reason for skipping all test cases and subgroups in the group.
%%
%% Description: Initialization before each test case group.
%%--------------------------------------------------------------------
init_per_group(_GroupName, Config) ->
Config.
%%--------------------------------------------------------------------
%% Function: end_per_group(GroupName, Config0) ->
%% void() | {save_config,Config1}
%%
%% GroupName = atom()
%% Name of the test case group that is finished.
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding configuration data for the group.
%%
%% Description: Cleanup after each test case group.
%%--------------------------------------------------------------------
end_per_group(_GroupName, _Config) ->
ok.
%%--------------------------------------------------------------------
%% Function: init_per_testcase(TestCase, Config0) ->
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%%
%% TestCase = atom()
%% Name of the test case that is about to run.
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%% The reason for skipping the test case.
%%
%% Description: Initialization before each test case.
%%
%% Note: This function is free to add any key/value pairs to the Config
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
init_per_testcase(_TestCase, Config) ->
Config.
%%--------------------------------------------------------------------
%% Function: end_per_testcase(TestCase, Config0) ->
%% void() | {save_config,Config1} | {fail,Reason}
%%
%% TestCase = atom()
%% Name of the test case that is finished.
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%% The reason for failing the test case.
%%
%% Description: Cleanup after each test case.
%%--------------------------------------------------------------------
end_per_testcase(_TestCase, _Config) ->
ok.
%%--------------------------------------------------------------------
%% Function: groups() -> [Group]
%%
%% Group = {GroupName,Properties,GroupsAndTestCases}
%% GroupName = atom()
%% The name of the group.
%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
%% Group properties that may be combined.
%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
%% TestCase = atom()
%% The name of a test case.
%% Shuffle = shuffle | {shuffle,Seed}
%% To get cases executed in random order.
%% Seed = {integer(),integer(),integer()}
%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
%% repeat_until_any_ok | repeat_until_any_fail
%% To get execution of cases repeated.
%% N = integer() | forever
%%
%% Description: Returns a list of test case group definitions.
%%--------------------------------------------------------------------
groups() ->
[].
%%--------------------------------------------------------------------
%% Function: all() -> GroupsAndTestCases | {skip,Reason}
%%
%% GroupsAndTestCases = [{group,GroupName} | TestCase]
%% GroupName = atom()
%% Name of a test case group.
%% TestCase = atom()
%% Name of a test case.
%% Reason = term()
%% The reason for skipping all groups and test cases.
%%
%% Description: Returns the list of groups and test cases that
%% are to be executed.
%%--------------------------------------------------------------------
all() ->
[].
%%--------------------------------------------------------------------
%% TEST CASES
%%--------------------------------------------------------------------
%%--------------------------------------------------------------------
%% Function: TestCase(Config0) ->
%% ok | exit() | {skip,Reason} | {comment,Comment} |
%% {save_config,Config1} | {skip_and_save,Reason,Config1}
%%
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%% The reason for skipping the test case.
%% Comment = term()
%% A comment about the test case that will be printed in the html log.
%%
%% Description: Test case function. (The name of it must be specified in
%% the all/0 list or in a test case group for the test case
%% to be executed).
%%--------------------------------------------------------------------

View file

@ -53,6 +53,8 @@ snippet ff
<%= form_for @${1:model} do |f| %>
${2}
<% end %>
snippet ffi
<%= ${1:f}.input :${2:attribute} %>
snippet ffcb
<%= ${1:f}.check_box :${2:attribute} %>
snippet ffe
@ -111,3 +113,13 @@ snippet slt
<%= stylesheet_link_tag ${1::all}, :cache => ${2:true} %>
snippet sslt
<%= stylesheet_link_tag "${1}" %>
snippet if
<% if ${1} %>
${2}
<% end %>
snippet ife
<% if ${1} %>
${2}
<% else %>
${3}
<% end %>

View file

@ -8,7 +8,7 @@ snippet imp
# Function
snippet fun
function ${2:function_name}(${3})
${4:/* code */}
${4}
end
# Class
@ -20,21 +20,21 @@ snippet class
# If
snippet if
if ${1:condition}
${2:/* code */}
${2}
end
# If else
snippet ife
if ${1:condition}
${2:/* code */}
${2}
else
${1}
end
# If else if
snippet elif
snippet eif
elif ${1:condition}
${2:/* code */}
${2}
# Switch case
snippet switch
@ -55,17 +55,17 @@ snippet select
# For/in Loop
snippet forin
for ${1:element} in ${2:container}
${3:/* code */}
${3}
end
# For/to Loop
snippet forto
for ${1:lowerbound} to ${2:upperbound}
${3:/* code */}
${3}
end
# While Loop
snippet while
while ${1:conidition}
${2:/* code */}
${2}
end

View file

@ -16,7 +16,7 @@ snippet ch
# case
snippet cs
case ${1:value}:
${2:/* code */}
${2}
# const
snippet c
const ${1:NAME} = ${2:0}
@ -36,7 +36,7 @@ snippet df
snippet dfr
defer func() {
if err := recover(); err != nil {
${1:/* code */}
${1}
}
}()
# gpl
@ -78,8 +78,8 @@ snippet inf
# if condition
snippet if
if ${1:/* condition */} {
${2:/* code */}
}${2}
${2}
}${3}
# else snippet
snippet el
else {
@ -109,7 +109,7 @@ snippet f6
# if else
snippet ie
if ${1:/* condition */} {
${2:/* code */}
${2}
} else {
${3}
}
@ -117,25 +117,25 @@ snippet ie
# for loop
snippet fo
for ${2:i} := 0; $2 < ${1:count}; $2${3:++} {
${4:/* code */}
${4}
}
${5}
# for range loop
snippet fr
for ${1:k}, ${2:v} := range ${3} {
${4:/* code */}
${4}
}
${5}
# function simple
snippet fun
func ${1:funcName}(${2}) ${3:error} {
${4:/* code */}
${4}
}
${5}
# function on receiver
snippet fum
func (self ${1:type}) ${2:funcName}(${3}) ${4:error} {
${5:/* code */}
${5}
}
${6}
# log printf
@ -153,7 +153,7 @@ snippet mp
# main()
snippet main
func main() {
${1:/* code */}
${1}
}
${2}
# new
@ -178,11 +178,11 @@ snippet rs
snippet sl
select {
case ${1:v1} := <-${2:chan1}
${3:/* code */}
${3}
case ${4:v2} := <-${5:chan2}
${6:/* code */}
${6}
default:
${7:/* code */}
${7}
}
# string
snippet sr
@ -197,11 +197,11 @@ snippet st
snippet sw
switch ${1:var} {
case ${2:value1}:
${3:/* code */}
${3}
case ${4:value2}:
${5:/* code */}
${5}
default:
${6:/* code */}
${6}
}
snippet sp
fmt.Sprintf("%${1:s}", ${2:var})${3}

View file

@ -11,10 +11,20 @@ snippet ul
%li
${1:item}
%li
snippet =rp
= render :partial => '${1:partial}'
snippet =rpl
= render :partial => '${1:partial}', :locals => {}
snippet =rpc
= render :partial => '${1:partial}', :collection => @$1
snippet rp
= render :partial => "${1:item}"
snippet rpc
= render :partial => "${1:item}", :collection => ${2:@$1s}
snippet rpl
= render :partial => "${1:item}", :locals => { :${2:$1} => ${3:@$1}
snippet rpo
= render :partial => "${1:item}", :object => ${2:@$1}
snippet ife
- if ${1:condition}
${2}
- else
${3}
snippet ifp
- if ${1:condition}.presence?
${2}

View file

@ -412,7 +412,7 @@ snippet head
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
<title>${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
${2}
</head>
snippet header
@ -450,7 +450,7 @@ snippet html5
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
<title>${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
${2:meta}
</head>
<body>
@ -730,6 +730,10 @@ snippet source
<source src="${1}" type="${2}" media="${3}" />
snippet span
<span>${1}</span>
snippet span.
<span class="${1}">${2}</span>
snippet span#
<span id="${1}">${2}</span>
snippet strong
<strong>${1}</strong>
snippet style
@ -791,7 +795,7 @@ snippet thead
snippet time
<time datetime="${1}" pubdate="${2:$1}">${3:$1}</time>
snippet title
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
<title>${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
snippet tr
<tr>
${1}

View file

@ -0,0 +1,74 @@
# file containing most useful mappings only
# when editing this file please be aware that there is ZenCoding and sparkup
# html 5 is recommended from now on
snippet html5
<!doctype html>
<html>
<head>
<title>$2</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
$3
</head>
<body>
$4
</body>
</html>
# ==== TAGS
# you always need these:
snippet .
class="${1}"${2}
snippet n
name="${1}"${2}
snippet r
rel="${1}"${2}
snippet t
title="${1}"${2}
# not using # because id is faster to type
snippet id
id="${1}"${2}
snippet idn
id="${1}" name="${2:$1}"
snippet label_and_input
<label for="${2:$1}">${1}</label>
<input type="${3:text}" name="${4:$2}" id="${5:$2}" value="${6}" />${7}
# FORMS
# use idn . or n to add id
snippet input
<input type="${1:text}" value="${2}" ${3}/>${7}
snippet submit
<input type="submit" value="${2}" ${3}/>${7}
snippet textarea
<textarea $1>$2</textarea>
# if you need id or class use snippets above
snippet form
<form method="${1:post/get}" action="$2">
$3
</form>
# other tags
snippet br
<br/>
snippet a
<a href="#" $2>$3</a>
snippet img
<img src="$1" alt="$2"/>
# JS/CSS
snippet css_file
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}" />${3}
snippet css_block
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}">
</link>
snippet script_block
<script type="text/javascript" charset="utf-8">
</script>
snippet script_file
<script type="text/javascript" charset="utf-8">
</script>

View file

@ -47,10 +47,10 @@ snippet if
{% if ${1} %}
${2}
{% endif %}
snippet else
snippet el
{% else %}
${1}
snippet elif
snippet eif
{% elif ${1} %}
${2}
snippet ifchanged

View file

@ -27,9 +27,9 @@ snippet if
{% if ${1:condition} %}
${2}
{% end %}
snippet elif
snippet eif
{% elif ${1:condition} %}
snippet else
snippet el
{% else %}
snippet import
{% import ${1:module} %}

View file

@ -39,11 +39,11 @@ snippet j.u
##
## Class
snippet cl
class ${1:`Filename("", "untitled")`} ${2}
class ${1:`vim_snippets#Filename("", "untitled")`} ${2}
snippet in
interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3}
interface ${1:`vim_snippets#Filename("", "untitled")`} ${2:extends Parent}${3}
snippet tc
public class ${1:`Filename()`} extends ${2:TestCase}
public class ${1:`vim_snippets#Filename()`} extends ${2:TestCase}
##
## Class Enhancements
snippet ext
@ -72,7 +72,7 @@ snippet def
${2}
snippet el
else
snippet elif
snippet eif
else if (${1}) ${2}
snippet if
if (${1}) ${2}
@ -144,7 +144,7 @@ snippet @au
snippet @br
@brief ${1:Description}
snippet @fi
@file ${1:`Filename()`}.java
@file ${1:`vim_snippets#Filename()`}.java
snippet @pa
@param ${1:param}
snippet @re
@ -171,7 +171,7 @@ snippet wh
## Main method
snippet main
public static void main (String[] args) {
${1:/* code */}
${1}
}
##
## Print Methods

View file

@ -260,7 +260,7 @@ snippet filter
${1:obj}.filter('${2:selector expression}')${3}
snippet filtert
${1:obj}.filter(function (${2:index}) {
${3:// test code}
${3}
})${4}
snippet find
${1:obj}.find('${2:selector expression}')${3}
@ -291,7 +291,7 @@ snippet getscript
});
snippet grep
$.grep(${1:array}, function (item, index) {
${2:// test code}
${2}
}${3:, true});
snippet hasc
${1:obj}.hasClass('${2:className}')${3}

View file

@ -17,7 +17,7 @@ snippet f
# Immediate function
snippet (f
(function (${1}) {
${3:/* code */}
${3}
}(${2}));
# if
snippet if
@ -38,16 +38,16 @@ snippet ter
snippet switch
switch (${1:expression}) {
case '${3:case}':
${4:// code}
${4}
break;
${5}
default:
${2:// code}
${2}
}
# case
snippet case
case '${1:case}':
${2:// code}
${2}
break;
${3}
# for (...) {...}
@ -63,19 +63,19 @@ snippet forr
# while (...) {...}
snippet wh
while (${1:/* condition */}) {
${2:/* code */}
${2}
}
# try
snippet try
try {
${1:/* code */}
${1}
} catch (${2:e}) {
${3:/* handle error */}
}
# do...while
snippet do
do {
${2:/* code */}
${2}
} while (${1:/* condition */});
# Object Method
snippet :f
@ -124,10 +124,10 @@ snippet jsons
# self-defining function
snippet sdf
var ${1:function_name} = function (${2:argument}) {
${3:// initial code ...}
${3}
$1 = function ($2) {
${4:// main code}
${4}
};
};
# singleton
@ -150,7 +150,7 @@ snippet sing
// reset the constructor pointer
instance.constructor = $1;
${3:// code ...}
${3}
return instance;
}

View file

@ -1,4 +1,4 @@
snippet ifeq
ifeq (${1:cond0},${2:cond1})
${3:code}
${3}
endif

View file

@ -22,7 +22,7 @@ snippet if if
% if ${1:condition}:
${2:}
% endif
snippet if if/else
snippet ife if/else
% if ${1:condition}:
${2:}
% else:

View file

@ -3,7 +3,7 @@ snippet Imp
#import <${1:Cocoa/Cocoa.h}>${2}
# #import "..."
snippet imp
#import "${1:`Filename()`.h}"${2}
#import "${1:`vim_snippets#Filename()`.h}"${2}
# @selector(...)
snippet sel
@selector(${1:method}:)${3}
@ -18,7 +18,7 @@ snippet log
NSLog(@"${1:%@}"${2});${3}
# Class
snippet objc
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
@interface ${1:`vim_snippets#Filename('', 'someClass')`} : ${2:NSObject}
{
}
@end
@ -28,33 +28,33 @@ snippet objc
@end
# Class Interface
snippet int
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
@interface ${1:`vim_snippets#Filename('', 'someClass')`} : ${2:NSObject}
{${3}
}
${4}
@end
snippet @interface
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
@interface ${1:`vim_snippets#Filename('', 'someClass')`} : ${2:NSObject}
{${3}
}
${4}
@end
# Class Implementation
snippet impl
@implementation ${1:`Filename('', 'someClass')`}
@implementation ${1:`vim_snippets#Filename('', 'someClass')`}
${2}
@end
snippet @implementation
@implementation ${1:`Filename('', 'someClass')`}
@implementation ${1:`vim_snippets#Filename('', 'someClass')`}
${2}
@end
# Protocol
snippet pro
@protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
@protocol ${1:`vim_snippets#Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
${3}
@end
snippet @protocol
@protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
@protocol ${1:`vim_snippets#Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
${3}
@end
# init Definition
@ -87,7 +87,7 @@ snippet cat
@end
# Category Interface
snippet cath
@interface ${1:`Filename('$1', 'NSObject')`} (${2:MyCategory})
@interface ${1:`vim_snippets#Filename('$1', 'NSObject')`} (${2:MyCategory})
${3}
@end
# Method
@ -207,7 +207,7 @@ snippet arel
# autorelease pool
snippet pool
NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init];
${2:/* code */}
${2}
[$1 drain];
# Throw an exception
snippet except

View file

@ -8,31 +8,35 @@ snippet .
# Function
snippet sub
sub ${1:function_name} {
${2:#body ...}
${2}
}
# Conditional
snippet if
if (${1}) {
${2:# body...}
${2}
}
# Conditional if..else
snippet ife
if (${1}) {
${2:# body...}
${2}
}
else {
${3:# else...}
${3}
}
# Conditional if..elsif..else
snippet ifee
if (${1}) {
${2:# body...}
${2}
}
elsif (${3}) {
${4:# elsif...}
}
else {
${5:# else...}
${5}
}
snippet eif
elsif (${1}) {
${2}
}
# Conditional One-line
snippet xif
@ -40,7 +44,7 @@ snippet xif
# Unless conditional
snippet unless
unless (${1}) {
${2:# body...}
${2}
}
# Unless conditional One-line
snippet xunless
@ -57,7 +61,7 @@ snippet eval
# While Loop
snippet wh
while (${1}) {
${2:# body...}
${2}
}
# While Loop One-line
snippet xwh
@ -65,7 +69,7 @@ snippet xwh
# C-style For Loop
snippet cfor
for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:# body...}
${4}
}
# For loop one-line
snippet xfor
@ -73,14 +77,14 @@ snippet xfor
# Foreach Loop
snippet for
foreach my $${1:x} (@${2:array}) {
${3:# body...}
${3}
}
# Foreach Loop One-line
snippet fore
${1:expression} foreach @${2:array};${3}
# Package
snippet package
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`};
package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`};
${2}
@ -89,7 +93,7 @@ snippet package
__END__
# Package syntax perl >= 5.14
snippet packagev514
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99};
package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99};
${3}
@ -127,7 +131,7 @@ snippet switch
# Anonymous subroutine
snippet asub
sub {
${1:# body }
${1}
}
@ -135,7 +139,7 @@ snippet asub
# Begin block
snippet begin
BEGIN {
${1:# begin body}
${1}
}
# call package function with some parameter
@ -174,7 +178,7 @@ snippet given
# switch-like case
snippet when
when (${1:case}) {
${2:# body}
${2}
}
# hash slice
@ -237,7 +241,7 @@ snippet subpod
=cut
sub ${1:subroutine_name} {
${2:# body...}
${2}
}
# Subroutine signature
snippet parg
@ -318,7 +322,7 @@ snippet trunner
snippet tsub
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
my $self = shift;
${4:# body}
${4}
}
@ -326,14 +330,14 @@ snippet tsub
snippet trsub
test ${1:test_name} => { description => '${2:Description of test.}'} => sub {
my ($self) = @_;
${3:# test code}
${3}
};
#prep test method
snippet tprep
sub prep${1:number}_${2:test_case} :Test(startup) {
my $self = shift;
${4:# body}
${4}
}
# cause failures to print stack trace

View file

@ -28,12 +28,12 @@ snippet use
use ${1:Foo\Bar\Baz};
${2}
snippet c
class ${1:`Filename()`}
class ${1:`vim_snippets#Filename()`}
{
${2}
}
snippet i
interface ${1:`Filename()`}
interface ${1:`vim_snippets#Filename()`}
{
${2}
}
@ -57,7 +57,7 @@ snippet sm
*
* @param ${2:$1} $$1 ${3:description}
*
* @return ${4:`Filename()`}
* @return ${4:`vim_snippets#Filename()`}
*/
${5:public} function set${6:$2}(${7:$2 }$$1)
{
@ -214,7 +214,7 @@ snippet interface
* @package ${3:default}
* @author ${4:`g:snips_author`}
*/
interface ${1:`Filename()`}
interface ${1:`vim_snippets#Filename()`}
{
${5}
}
@ -223,7 +223,7 @@ snippet class
/**
* ${1}
*/
class ${2:`Filename()`}
class ${2:`vim_snippets#Filename()`}
{
${3}
/**
@ -231,13 +231,13 @@ snippet class
*/
${5:public} function ${6:__construct}(${7:argument})
{
${8:// code...}
${8}
}
}
snippet nc
namespace ${1:`substitute(substitute(expand("%:h"), '\v^\w+\/(\u)', '\1', ''), '\/', '\\\', 'g')`};
${2:abstract }class ${3:`Filename()`}
${2:abstract }class ${3:`vim_snippets#Filename()`}
{
${4}
}
@ -249,26 +249,26 @@ snippet def?
${1}defined('${2}')${3}
snippet wh
while (${1:/* condition */}) {
${2:// code...}
${2}
}
# do ... while
snippet do
do {
${2:// code... }
${2}
} while (${1:/* condition */});
snippet if
if (${1:/* condition */}) {
${2:// code...}
${2}
}
snippet ifil
<?php if (${1:/* condition */}): ?>
${2:<!-- code... -->}
${2}
<?php endif; ?>
snippet ife
if (${1:/* condition */}) {
${2:// code...}
${2}
} else {
${3:// code...}
${3}
}
${4}
snippet ifeil
@ -278,35 +278,35 @@ snippet ifeil
${3:<!-- html... -->}
<?php endif; ?>
${4}
snippet else
snippet el
else {
${1:// code...}
${1}
}
snippet elseif
snippet eif
elseif (${1:/* condition */}) {
${2:// code...}
${2}
}
snippet switch
switch ($${1:variable}) {
case '${2:value}':
${3:// code...}
${3}
break;
${5}
default:
${4:// code...}
${4}
break;
}
snippet case
case '${1:value}':
${2:// code...}
${2}
break;${3}
snippet for
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4: // code...}
${4}
}
snippet foreach
foreach ($${1:variable} as $${2:value}) {
${3:// code...}
${3}
}
snippet foreachil
<?php foreach ($${1:variable} as $${2:value}): ?>
@ -314,7 +314,7 @@ snippet foreachil
<?php endforeach; ?>
snippet foreachk
foreach ($${1:variable} as $${2:key} => $${3:value}) {
${4:// code...}
${4}
}
snippet foreachkil
<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>
@ -343,6 +343,8 @@ snippet vd
var_dump(${1});
snippet vdd
var_dump(${1}); die(${2:});
snippet vdf
error_log(print_r($${1:foo}, true), 3, '${2:/tmp/debug.log}');${3}
snippet http_redirect
header ("HTTP/1.1 301 Moved Permanently");
header ("Location: ".URL);
@ -364,7 +366,7 @@ snippet gs
*
* @param $2 $$1 ${5:description}
*
* @return ${6:`Filename()`}
* @return ${6:`vim_snippets#Filename()`}
*/
public function set$3(${7:$2 }$$1)
{

View file

@ -65,7 +65,7 @@ snippet for
#loop while
snippet while
while (${1:/* condition */}) {
${2:/* code */}
${2}
}
#break
snippet break
@ -84,11 +84,11 @@ snippet default
snippet switch
switch(${1:expression}) {
case '${3:case}':
${4:// code}
${4}
break;
${5}
default:
${2:// code}
${2}
}
#try
snippet try

View file

@ -5,11 +5,11 @@
# Language Constructs
snippet class
class ${1:`Filename('', 'name')`} {
class ${1:`vim_snippets#Filename('', 'name')`} {
${2}
}
snippet node
node "${1:`Filename('', 'fqdn')`}" {
node "${1:`vim_snippets#Filename('', 'fqdn')`}" {
${2}
}
snippet case
@ -26,7 +26,7 @@ snippet if
if $${1:variable} {
${2}
}
snippet else
snippet el
else {
${1}
}

View file

@ -2,29 +2,33 @@ snippet #!
#!/usr/bin/env python
snippet imp
import ${1:module}
snippet uni
def __unicode__(self):
${1:representation}
snippet from
from ${1:package} import ${2:module}
# Module Docstring
snippet docs
"""
File: ${1:`Filename('$1.py', 'foo.py')`}
File: ${1:`vim_snippets#Filename('$1.py', 'foo.py')`}
Author: `g:snips_author`
Email: `g:snips_email`
Github: `g:snips_github`
Description: ${2}
"""
snippet wh
while ${1:condition}:
${2:# TODO: write code...}
${2}
# dowh - does the same as do...while in other languages
snippet dowh
while True:
${1:# TODO: write code...}
${1}
if ${2:condition}:
break
snippet with
with ${1:expr} as ${2:var}:
${3:# TODO: write code...}
${3}
# New Class
snippet cl
class ${1:ClassName}(${2:object}):
@ -37,14 +41,14 @@ snippet cl
snippet def
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
"""${3:docstring for $1}"""
${4:# TODO: write code...}
${4}
snippet deff
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
${3:# TODO: write code...}
${3}
# New Method
snippet defs
def ${1:mname}(self, ${2:arg}):
${3:# TODO: write code...}
${3}
# New Property
snippet property
def ${1:foo}():
@ -60,17 +64,17 @@ snippet property
# Ifs
snippet if
if ${1:condition}:
${2:# TODO: write code...}
${2}
snippet el
else:
${1:# TODO: write code...}
${1}
snippet ei
elif ${1:condition}:
${2:# TODO: write code...}
${2}
# For
snippet for
for ${1:item} in ${2:items}:
${3:# TODO: write code...}
${3}
# Encodes
snippet cutf8
# -*- coding: utf-8 -*-
@ -79,38 +83,38 @@ snippet clatin1
snippet cascii
# -*- coding: ascii -*-
# Lambda
snippet lda
snippet ld
${1:var} = lambda ${2:vars} : ${3:action}
snippet .
self.
snippet try Try/Except
try:
${1:# TODO: write code...}
${1}
except ${2:Exception}, ${3:e}:
${4:raise $3}
snippet try Try/Except/Else
try:
${1:# TODO: write code...}
${1}
except ${2:Exception}, ${3:e}:
${4:raise $3}
else:
${5:# TODO: write code...}
${5}
snippet try Try/Except/Finally
try:
${1:# TODO: write code...}
${1}
except ${2:Exception}, ${3:e}:
${4:raise $3}
finally:
${5:# TODO: write code...}
${5}
snippet try Try/Except/Else/Finally
try:
${1:# TODO: write code...}
${1}
except ${2:Exception}, ${3:e}:
${4:raise $3}
else:
${5:# TODO: write code...}
${5}
finally:
${6:# TODO: write code...}
${6}
# if __name__ == '__main__':
snippet ifmain
if __name__ == '__main__':
@ -127,6 +131,9 @@ snippet ipdb
# ipython debugger (pdbbb)
snippet pdbbb
import pdbpp; pdbpp.set_trace()
# python console debugger (pudb)
snippet pudb
import pudb; pudb.set_trace()
snippet pprint
import pprint; pprint.pprint(${1})${2}
snippet "
@ -136,13 +143,13 @@ snippet "
# test function/method
snippet test
def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):
${3:# TODO: write code...}
${3}
# test case
snippet testcase
class ${1:ExampleCase}(unittest.TestCase):
def test_${2:description}(self):
${3:# TODO: write code...}
${3}
snippet fut
from __future__ import ${1}
#getopt
@ -169,7 +176,8 @@ snippet glog
logger = logging.getLogger(${1:__name__})
snippet le
logger.error(${1:msg})
snippet ld
# conflict with lambda=ld, therefor we change into Logger.debuG
snippet lg
logger.debug(${1:msg})
snippet lw
logger.warning(${1:msg})

View file

@ -12,24 +12,24 @@ snippet source
# conditionals
snippet if
if (${1:condition}) {
${2:code}
${2}
}
snippet el
else {
${1:code}
${1}
}
snippet ei
else if (${1:condition}) {
${2:code}
${2}
}
# functions
snippet fun
${1:name} = function (${2:variables}) {
${3:code}
${3}
}
snippet ret
return(${1:code})
return(${1})
# dataframes, lists, etc
snippet df

View file

@ -3,9 +3,9 @@
snippet :
:${1:field name}: ${2:field body}
snippet *
*${1:Emphasis}*
*${1:Emphasis}* ${2}
snippet **
**${1:Strong emphasis}**
**${1:Strong emphasis}** ${2}
snippet _
\`${1:hyperlink-name}\`_
.. _\`$1\`: ${2:link-block}
@ -17,6 +17,53 @@ snippet -
${1:Title}
-----${2:-}
${3}
#some directive
snippet img:
.. |${2:alias}| image:: ${1:img}
snippet fig:
.. figure:: ${1:img}
:alt: ${2:alter text}
$2
snippet cont:
.. contents::
${1:content}
snippet code:
.. code:: ${1:type}
${2:write some code}
snippet tip:
.. tip::
${1:my tips}
snippet not:
.. note::
${1:my notes}
snippet war:
.. warning::
${1:attention!}
snippet imp:
.. important::
${1:this is importatnt}
snippet att:
.. attention::
${1:hey!}
snippet dan:
.. danger::
${1:ah!}
snippet err:
.. error::
${1:Error occur}
snippet cau:
.. caution::
${1:Watch out!}
#Spinx only
snippet sid:
.. sidebar:: ${1:Title}
${2}
# CJK optimize, CJK has no space between charaters
snippet *c
\ *${1:Emphasis}*\ ${2}
snippet **c
\ **${1:Strong emphasis}**\ ${2}

View file

@ -16,6 +16,14 @@ snippet =b
=begin rdoc
${1}
=end
snippet prot
protected
${1}
snippet priv
private
${1}
snippet y
:yields: ${1:arguments}
snippet rb
@ -60,7 +68,7 @@ snippet ife
else
${3}
end
snippet elsif
snippet eif
elsif ${1:condition}
${2}
snippet unless
@ -80,23 +88,23 @@ snippet until
${2}
end
snippet cla class .. end
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
${2}
end
snippet cla class .. initialize .. end
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
def initialize(${2:args})
${3}
end
end
snippet cla class .. < ParentClass .. initialize .. end
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < ${2:ParentClass}
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < ${2:ParentClass}
def initialize(${3:args})
${4}
end
end
snippet cla ClassName = Struct .. do .. end
${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} = Struct.new(:${2:attr_names}) do
${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} = Struct.new(:${2:attr_names}) do
def ${3:method_name}
${4}
end
@ -111,7 +119,7 @@ snippet cla class << self .. end
end
# class .. < DelegateClass .. initialize .. end
snippet cla-
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < DelegateClass(${2:ParentClass})
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < DelegateClass(${2:ParentClass})
def initialize(${3:args})
super(${4:del_obj})
@ -119,17 +127,17 @@ snippet cla-
end
end
snippet mod module .. end
module ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
${2}
end
snippet mod module .. module_function .. end
module ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
module_function
${2}
end
snippet mod module .. ClassMethods .. end
module ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
module ClassMethods
${2}
end
@ -156,6 +164,11 @@ snippet atp
attr_protected :${1:attr_names}
snippet ata
attr_accessible :${1:attr_names}
snippet ana
accepts_nested_attributes_for :${1:association}
# ivc == instance variable cache
snippet ivc
@${1:variable_name} ||= ${2:chached_value}
# include Enumerable
snippet Enum
include Enumerable
@ -178,6 +191,11 @@ snippet defs
def self.${1:class_method_name}
${2}
end
# def initialize
snippet definit
def initialize(${1:args})
${2}
end
# def method_missing
snippet defmm
def method_missing(meth, *args, &blk)
@ -309,6 +327,12 @@ snippet injd
inject(${1:init}) do |${2:mem}, ${3:var}|
${4}
end
snippet red
reduce(${1:init}) { |${2:mem}, ${3:var}| ${4} }
snippet redd
reduce(${1:init}) do |${2:mem}, ${3:var}|
${4}
end
snippet map
map { |${1:e}| ${2} }
snippet mapd
@ -389,13 +413,17 @@ snippet seld
end
snippet lam
lambda { |${1:args}| ${2} }
snippet doo
# I'm pretty sure that ruby users expect do to expand to do .. end
snippet do
do
${1}
end
# this is for one or more variables. typing a ", " is that cheap that it may
# not be worth adding another snippet. should 0/1 placeholders change order?
# its a good idea to think about the var name, so use it first
snippet dov
do |${1:variable}|
${2}
do |${0:v}|
${1}
end
snippet :
:${1:key} => ${2:"value"}${3}
@ -529,7 +557,7 @@ snippet clafn
snippet sinc
class << self; self end
snippet nam
namespace :${1:`Filename()`} do
namespace :${1:`vim_snippets#Filename()`} do
${2}
end
snippet tas
@ -572,8 +600,8 @@ snippet artp
snippet artpp
assert_redirected_to ${1:model}s_path
snippet asd
assert_difference "${1:Model}.${2:count}", $1 do
${3}
assert_difference "${1:Model}.${2:count}", ${3:1} do
${4}
end
snippet asnd
assert_no_difference "${1:Model}.${2:count}" do
@ -597,14 +625,14 @@ snippet defcreate
def create
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
respond_to do |wants|
respond_to do |format|
if @$1.save
flash[:notice] = '$2 was successfully created.'
wants.html { redirect_to(@$1) }
wants.xml { render :xml => @$1, :status => :created, :location => @$1 }
format.html { redirect_to(@$1) }
format.xml { render :xml => @$1, :status => :created, :location => @$1 }
else
wants.html { render :action => "new" }
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
format.html { render :action => "new" }
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
end
end
end${3}
@ -613,9 +641,9 @@ snippet defdestroy
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
@$1.destroy
respond_to do |wants|
wants.html { redirect_to($1s_url) }
wants.xml { head :ok }
respond_to do |format|
format.html { redirect_to($1s_url) }
format.xml { head :ok }
end
end${3}
snippet defedit
@ -626,41 +654,41 @@ snippet defindex
def index
@${1:model_class_name} = ${2:ModelClassName}.all
respond_to do |wants|
wants.html # index.html.erb
wants.xml { render :xml => @$1s }
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @$1s }
end
end${3}
snippet defnew
def new
@${1:model_class_name} = ${2:ModelClassName}.new
respond_to do |wants|
wants.html # new.html.erb
wants.xml { render :xml => @$1 }
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @$1 }
end
end${3}
snippet defshow
def show
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
respond_to do |wants|
wants.html # show.html.erb
wants.xml { render :xml => @$1 }
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @$1 }
end
end${3}
snippet defupdate
def update
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
respond_to do |wants|
respond_to do |format|
if @$1.update_attributes(params[:$1])
flash[:notice] = '$2 was successfully updated.'
wants.html { redirect_to(@$1) }
wants.xml { head :ok }
format.html { redirect_to(@$1) }
format.xml { head :ok }
else
wants.html { render :action => "edit" }
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
format.html { render :action => "edit" }
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
end
end
end${3}
@ -733,8 +761,8 @@ snippet ra
snippet ral
render :action => "${1:action}", :layout => "${2:layoutname}"
snippet rest
respond_to do |wants|
wants.${1:html} { ${2} }
respond_to do |format|
format.${1:html} { ${2} }
end
snippet rf
render :file => "${1:filepath}"
@ -779,7 +807,7 @@ snippet ru
snippet rxml
render :xml => ${1:text to render}
snippet sc
scope :${1:name}, :where(:@${2:field} => ${3:value})
scope :${1:name}, -> { where(${2:field}: ${3:value}) }
snippet sl
scope :${1:name}, lambda do |${2:value}|
where("${3:field = ?}", ${4:bind var})
@ -802,6 +830,85 @@ snippet sweeper
expire_page
end
end
snippet va validates_associated
validates_associated :${1:attribute}
snippet va validates .., :acceptance => true
validates :${1:terms}, :acceptance => true
snippet vc
validates :${1:attribute}, :confirmation => true
snippet ve
validates :${1:attribute}, :exclusion => { :in => ${2:%w( mov avi )} }
snippet vf
validates :${1:attribute}, :format => { :with => /${2:regex}/ }
snippet vi
validates :${1:attribute}, :inclusion => { :in => %w(${2: mov avi }) }
snippet vl
validates :${1:attribute}, :length => { :in => ${2:3}..${3:20} }
snippet vn
validates :${1:attribute}, :numericality => true
snippet vp
validates :${1:attribute}, :presence => true
snippet vu
validates :${1:attribute}, :uniqueness => true
snippet format
format.${1:js|xml|html} { ${2} }
snippet wc
where(${1:"conditions"}${2:, bind_var})
snippet wh
where(${1:field} => ${2:value})
snippet xdelete
xhr :delete, :${1:destroy}, :id => ${2:1}${3}
snippet xget
xhr :get, :${1:show}, :id => ${2:1}${3}
snippet xpost
xhr :post, :${1:create}, :${2:object} => { ${3} }
snippet xput
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { ${4} }${5}
snippet test
test "should ${1:do something}" do
${2}
end
###########################
# migrations snippets #
###########################
snippet mac
add_column :${1:table_name}, :${2:column_name}, :${3:data_type}
snippet mai
add_index :${1:table_name}, :${2:column_name}
snippet mrc
remove_column :${1:table_name}, :${2:column_name}
snippet mrnc
rename_column :${1:table_name}, :${2:old_column_name}, :${3:new_column_name}
snippet mcc
change_column :${1:table}, :${2:column}, :${3:type}
snippet mnc
t.${1:string} :${2:title}${3:, null: false}${4}
snippet mct
create_table :${1:table_name} do |t|
${2}
end
snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end
class ${1:class_name} < ActiveRecord::Migration
def up
${2}
end
def down
end
end
snippet migration class .. < ActiveRecord::Migration .. def change .. end
class ${1:class_name} < ActiveRecord::Migration
def change
${2}
end
end
snippet trc
t.remove :${1:column}
snippet tre
t.rename :${1:old_column_name}, :${2:new_column_name}
${3}
snippet tref
t.references :${1:model}
snippet tcb
t.boolean :${1:title}
${2}
@ -847,98 +954,17 @@ snippet tcts
snippet tctss
t.timestamps
${1}
snippet va
validates_associated :${1:attribute}
snippet vao
validates_acceptance_of :${1:terms}
snippet vc
validates_confirmation_of :${1:attribute}
snippet ve
validates_exclusion_of :${1:attribute}, :in => ${2:%w( mov avi )}
snippet vf
validates_format_of :${1:attribute}, :with => /${2:regex}/
snippet vi
validates_inclusion_of :${1:attribute}, :in => %w(${2: mov avi })
snippet vl
validates_length_of :${1:attribute}, :within => ${2:3}..${3:20}
snippet vn
validates_numericality_of :${1:attribute}
snippet vpo
validates_presence_of :${1:attribute}
snippet vu
validates_uniqueness_of :${1:attribute}
snippet wants
wants.${1:js|xml|html} { ${2} }
snippet wc
where(${1:"conditions"}${2:, bind_var})
snippet wh
where(${1:field} => ${2:value})
snippet xdelete
xhr :delete, :${1:destroy}, :id => ${2:1}${3}
snippet xget
xhr :get, :${1:show}, :id => ${2:1}${3}
snippet xpost
xhr :post, :${1:create}, :${2:object} => { ${3} }
snippet xput
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { ${4} }${5}
snippet test
test "should ${1:do something}" do
${2}
end
#migrations
snippet mac
add_column :${1:table_name}, :${2:column_name}, :${3:data_type}
snippet mrc
remove_column :${1:table_name}, :${2:column_name}
snippet mrnc
rename_column :${1:table_name}, :${2:old_column_name}, :${3:new_column_name}
snippet mcc
change_column :${1:table}, :${2:column}, :${3:type}
snippet mnc
t.${1:string} :${2:title}${3:, null: false}${4}
snippet mct
create_table :${1:table_name} do |t|
${2}
end
snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end
class ${1:class_name} < ActiveRecord::Migration
def up
${2}
end
def down
end
end
snippet migration class .. < ActiveRecord::Migration .. def change .. end
class ${1:class_name} < ActiveRecord::Migration
def change
${2}
end
end
snippet trc
t.remove :${1:column}
snippet tre
t.rename :${1:old_column_name}, :${2:new_column_name}
${3}
snippet tref
t.references :${1:model}
#rspec
snippet it
it "${1:spec_name}" do
${2}
end
snippet itp
it "${1:spec_name}"
${2}
snippet its
its(:${1:method}) { should ${2} }
snippet itsn
its(:${1:method}) { should_not ${2} }
##########################
# Rspec snippets #
##########################
snippet desc
describe ${1:class_name} do
${2}
end
snippet descm
describe "${1:#method}" do
${2:pending "Not implemented"}
end
snippet cont
context "${1:message}" do
${2}
@ -952,22 +978,101 @@ snippet aft
${2}
end
snippet let
let(:${1:object}) ${2:block}
let(:${1:object}) ${2}
snippet let!
let!(:${1:object}) ${2:block}
let!(:${1:object}) ${2}
snippet subj
subject { ${1} }
snippet s.
subject.${1:method}
snippet spec
specify { subject.${1} }
snippet exp
expect(${1:object}).to ${2}
snippet btr
be_true
snippet bfa
be_false
expect { ${1:object} }.to ${2}
snippet raise
expect { ${1:object} }.to raise_error ${2:StandardError}, /${3:message_regex}/
snippet shared
shared_examples "${1:shared examples name}" ${2}
snippet itb
it_behaves_like "${1:shared examples name}"${2}
snippet ana
accepts_nested_attributes_for :${1:association}
shared_examples ${1:"shared examples name"}
snippet ibl
it_behaves_like ${1:"shared examples name"}
snippet it
it "${1:spec_name}" do
${2}
end
snippet its
its(:${1:method}) { should ${2} }
snippet is
it { should ${1} }
snippet isn
it { should_not ${1} }
#ShouldaMatchers#ActionController
snippet isfp
it { should filter_param :${1:key} }
snippet isrt
it { should redirect_to ${1:url} }
snippet isrtp
it { should render_template ${1} }
snippet isrwl
it { should render_with_layout ${1} }
snippet isrf
it { should rescue_from ${1:exception} }
snippet isrw
it { should respond_with ${1:status} }
snippet isr
it { should route(:${1:method}, '${2:path}') }
snippet isss
it { should set_session :${1:key} }
snippet issf
it { should set_the_flash('${1}') }
#ShouldaMatchers#ActiveModel
snippet isama
it { should allow_mass_assignment_of :${1} }
snippet isav
it { should allow_value(${1}).for :${2} }
snippet isee
it { should ensure_exclusion_of :${1} }
snippet isei
it { should ensure_inclusion_of :${1} }
snippet isel
it { should ensure_length_of :${1} }
snippet isva
it { should validate_acceptance_of :${1} }
snippet isvc
it { should validate_confirmation_of :${1} }
snippet isvn
it { should validate_numericality_of :${1} }
snippet isvp
it { should validate_presence_of :${1} }
snippet isvu
it { should validate_uniqueness_of :${1} }
#ShouldaMatchers#ActiveRecord
snippet isana
it { should accept_nested_attributes_for :${1} }
snippet isbt
it { should belong_to :${1} }
snippet isbtcc
it { should belong_to(:${1}).counter_cache ${2:true} }
snippet ishbtm
it { should have_and_belong_to_many :${1} }
snippet isbv
it { should be_valid }${1}
snippet ishc
it { should have_db_column :${1} }
snippet ishi
it { should have_db_index :${1} }
snippet ishm
it { should have_many :${1} }
snippet ishmt
it { should have_many(:${1}).through :${2} }
snippet isho
it { should have_one :${1} }
snippet ishro
it { should have_readonly_attribute :${1} }
snippet iss
it { should serialize :${1} }
snippet isres
it { should respond_to :${1} }
snippet isresw
it { should respond_to(:${1}).with(${2}).arguments }
snippet super_call
${1:super_class}.instance_method(:${2:method}).bind(self).call

View file

@ -7,61 +7,65 @@
#if
snippet if
if(${1:obj}) {
${2:/* code */}
${2}
}
#if not
snippet ifn
if(!${1:obj}) {
${2:/* code */}
${2}
}
#if-else
snippet ifel
snippet ife
if(${1:obj}) {
${2:/* code */}
${2}
} else {
${3:/* code */}
${3}
}
#if-else-if
snippet ifelif
if(${1:obj}) {
${2:/* code */}
${2}
} else if(${3:obj}) {
${4:/* code */}
${4}
}
snippet eif
else if(${3:obj}) {
${4}
}
#while loop
snippet while
while (${1:obj}) {
${2:/* code */}
${2}
}
#for loop(classic)
snippet for
for (${1:item} <- ${2:obj}) {
${3:/* code */}
${3}
}
#for loop(indexed)
snippet fori
for (${1:i} <- ${2:0} to ${3:obj}.length) {
${4:/* code */}
${4}
}
#exceptions
snippet try
try {
${1:/* code */}
${1}
} catch {
case e: FileNotFoundException => ${2:/* code */}
case e: IOException => ${3:/* code */}
case e: FileNotFoundException => ${2}
case e: IOException => ${3}
} finally {
${4:/* code */}
${4}
}
#match
snippet match
${1: obj} match {
case ${2:e} => ${3:/* code */}
case _ => ${4:/* code */}
case ${2:e} => ${3}
case _ => ${4}
}
#case
snippet case
case ${1:value} => ${2:/* code */}
case ${1:value} => ${2}
############################
# methods and arguments
#
@ -82,9 +86,9 @@ snippet ovdef
override def ${1:name}(${2:arg}) = ${3:}
#first class function(see scalabook p 188)
snippet fcf
(${1:a}: ${2:T}) => $1 ${3:/* code */}
(${1:a}: ${2:T}) => $1 ${3}
snippet =>
${1:name} => ${2:/* code */}
${1:name} => ${2}
#recursion
snippet rec
def ${1:name}(${2:arg}) =
@ -196,11 +200,11 @@ snippet as
#scope() with one arg
snippet (a
(${1:a} => ${2:/* code */})
(${1:a} => ${2})
#scope() with two args
snippet {(
{(${1:a},${2:b}) =>
${3:/* code */}
${3}
}
#filter
snippet filter
@ -220,10 +224,10 @@ snippet fldr
#fold left operator(if u wanna reduce readability of ur code)
#use wildcard symbols
snippet /:
(${1:first}/:${2:name})(${3:/* code */})
(${1:first}/:${2:name})(${3})
#fold right operator
snippet :\
(${1:first}:\${2:name})(${3:/* code */})
(${1:first}:\${2:name})(${3})
#reduce left
snippet redl
${1:name}.reduceLeft[${2:T}] {(
@ -258,13 +262,13 @@ snippet athis
snippet abstract
abstract class ${1:name}${2:(arg)}${3: extends }${4: with} {
${5:override def toString = "$1"}
${6:/* code */}
${6}
}
#class
snippet class
class ${1:name}${2:(arg)}${3: extends }${4: with} {
${5:override def toString = "$1"}
${6:/* code */}
${6}
}
#object
snippet object
@ -279,7 +283,7 @@ snippet ordered
class ${1:name}${2:(arg)} extends Ordered[$1] ${3: with} {
${4:override def toString = "$1"}
def compare(that: $1) = ${5:this - that}
${6:/* code */}
${6}
}
#case class
snippet casecl

View file

@ -80,7 +80,5 @@ snippet getopt
esac # --- end of case ---
done
shift $(($OPTIND-1))
snippet root
if [ $(id -u) -ne 0 ]; then exec sudo $0; fi

View file

@ -5,7 +5,7 @@ snippet #!
# Process
snippet pro
proc ${1:function_name} {${2:args}} {
${3:#body ...}
${3}
}
#xif
snippet xif
@ -13,19 +13,23 @@ snippet xif
# Conditional
snippet if
if {${1}} {
${2:# body...}
${2}
}
# Conditional if..else
snippet ife
if {${1}} {
${2:# body...}
${2}
} else {
${3:# else...}
}
snippet eif
elseif {${1}} {
${2}
}
# Conditional if..elsif..else
snippet ifee
if {${1}} {
${2:# body...}
${2}
} elseif {${3}} {
${4:# elsif...}
} else {
@ -42,17 +46,17 @@ snippet catch
# While Loop
snippet wh
while {${1}} {
${2:# body...}
${2}
}
# For Loop
snippet for
for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {
${4:# body...}
${4}
}
# Foreach Loop
snippet fore
foreach ${1:x} {${2:#list}} {
${3:# body...}
${3}
}
# after ms script...
snippet af

View file

@ -1,16 +1,16 @@
#PREAMBLE
#newcommand
snippet nc
\newcommand{\${1:cmd}}[${2:opt}]{${3:realcmd}}${4}
\newcommand{\${1:cmd}}[${2:opt}]{${3:realcmd}} ${4}
#usepackage
snippet up
\usepackage[${1:[options}]{${2:package}}
\usepackage[${1:options}]{${2:package}} ${3}
#newunicodechar
snippet nuc
\newunicodechar{${1}}{${2:\ensuremath}${3:tex-substitute}}}
\newunicodechar{${1}}{${2:\ensuremath}${3:tex-substitute}}} ${4}
#DeclareMathOperator
snippet dmo
\DeclareMathOperator{${1}}{${2}}
\DeclareMathOperator{${1}}{${2}} ${3}
#DOCUMENT
# \begin{}...\end{}
@ -26,7 +26,7 @@ snippet tab
snippet thm
\begin[${1:author}]{${2:thm}}
${3}
\end{$1}
\end{$2}
snippet center
\begin{center}
${1}
@ -56,6 +56,11 @@ snippet \
\[
${1}
\]
# Equation array
snippet eqnarray
\begin{eqnarray}
${1}
\end{eqnarray}
# Enumerate
snippet enum
\begin{enumerate}
@ -66,11 +71,17 @@ snippet itemize
\begin{itemize}
\item ${1}
\end{itemize}
snippet item
\item ${1}
# Description
snippet desc
\begin{description}
\item[${1}] ${2}
\end{description}
# Endless new item
snippet ]i
\item ${1}
${2:]i}
# Matrix
snippet mat
\begin{${1:p/b/v/V/B/small}matrix}
@ -103,16 +114,31 @@ snippet sec
\section{${1:section name}}
\label{sec:${2:$1}}
${3}
# Section without number
snippet sec*
\section*{${1:section name}}
\label{sec:${2:$1}}
${3}
# Sub Section
snippet sub
\subsection{${1:subsection name}}
\label{sub:${2:$1}}
${3}
# Sub Section without number
snippet sub*
\subsection*{${1:subsection name}}
\label{sub:${2:$1}}
${3}
# Sub Sub Section
snippet subs
\subsubsection{${1:subsubsection name}}
\label{ssub:${2:$1}}
${3}
# Sub Sub Section without number
snippet subs*
\subsubsection*{${1:subsubsection name}}
\label{ssub:${2:$1}}
${3}
# Paragraph
snippet par
\paragraph{${1:paragraph name}}
@ -123,6 +149,9 @@ snippet subp
\subparagraph{${1:subparagraph name}}
\label{subp:${2:$1}}
${3}
snippet ni
\noindent
${1}
#References
snippet itd
\item[${1:description}] ${2:item}
@ -133,14 +162,21 @@ snippet table
snippet listing
${1:Listing}~\ref{${2:list}}${3}
snippet section
${1:Section}~\ref{${2:sec:}}${3}
${1:Section}~\ref{sec:${2}} ${3}
snippet page
${1:page}~\pageref{${2}}${3}
${1:page}~\pageref{${2}} ${3}
snippet index
\index{${1:index}}${2}
\index{${1:index}} ${2}
#Citations
snippet citen
\cite{$1} ${2}
# bibtex commands
snippet citep
\citep{$1} ${2}
snippet citet
\citet{$1} ${2}
snippet cite
\cite[${1}]{${2}}${3}
\cite[${1}]{${2}} ${3}
snippet fcite
\footcite[${1}]{${2}}${3}
#Formating text: italic, bold, underline, small capital, emphase ..
@ -172,6 +208,7 @@ snippet fig
\caption{${3}}
\label{fig:${4}}
\end{figure}
${5}
snippet tikz
\begin{figure}
\begin{center}
@ -182,10 +219,40 @@ snippet tikz
\caption{${3}}
\label{fig:${4}}
\end{figure}
${5}
#math
snippet stackrel
\stackrel{${1:above}}{${2:below}} ${3}
snippet frac
\frac{${1:num}}{${2:denom}}
\frac{${1:num}}{${2:denom}} ${3}
snippet sum
\sum^{${1:n}}_{${2:i=1}}{${3}}
\sum^{${1:n}}_{${2:i=1}} ${3}
snippet lim
\lim_{${1:x \to +\infty}} ${2}
snippet frame
\begin{frame}[<+->]
\frametitle{${1:title}}
${2}
\end{frame}
snippet block
\begin{block}{${1:title}}
${2}
\end{block}
snippet alert
\begin{alertblock}{${1:title}}
${2}
\end{alertblock}
snippet example
\begin{exampleblock}{${1:title}}
${2}
\end{exampleblock}
snippet col2
\begin{columns}
\begin{column}{0.5\textwidth}
${1}
\end{column}
\begin{column}{0.5\textwidth}
${2}
\end{column}
\end{columns}

View file

@ -4,13 +4,13 @@ snippet header
" Description: ${3}
${4:" Last Modified: `strftime("%B %d, %Y")`}
snippet guard
if exists('${1:did_`Filename()`}') || &cp${2: || version < 700}
if exists('${1:did_`vim_snippets#Filename()`}') || &cp${2: || version < 700}
finish
endif
let $1 = 1${3}
snippet f
fun! ${1:`expand('%') =~ 'autoload' ? substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#' : ''`}${2:function_name}(${3})
${4:" code}
${4}
endf
snippet t
try
@ -19,19 +19,25 @@ snippet t
${3}
endtry
snippet for
for ${1:needle} in ${2:haystack}
${3:" code}
for ${1} in ${2}
${3}
endfor
snippet forkv
for [${1},${2}] in items(${3})
${4}
unlet $1 $2
endfor
snippet wh
while ${1:condition}
${2:" code}
while ${1}
${2}
endw
snippet if
if ${1:condition}
${2:" code}
if ${1}
${2}
endif
snippet ife
if ${1:condition}
if ${1}
${2}
else
${3}

View file

@ -12,7 +12,7 @@ snippet ife
else
${3:# statements}
fi
snippet elif
snippet eif
elif ${1:condition} ; then
${2:# statements}
snippet for