Merge commit '588aac5317d46e7749be614555e957abfb0fcf11' into main
commit
279061fcc3
@ -1,3 +1,4 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
*.swp
|
*.swp
|
||||||
doc/tags
|
doc/tags
|
||||||
|
.ropeproject/
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
language: python
|
||||||
|
|
||||||
|
python:
|
||||||
|
- 2.7
|
||||||
|
- 3.3
|
||||||
|
- 3.4
|
||||||
|
env:
|
||||||
|
- VIM_VERSION="74"
|
||||||
|
- VIM_VERSION="mercurial"
|
||||||
|
# - VIM_VERSION="NEOVIM"
|
||||||
|
|
||||||
|
install:
|
||||||
|
# Some of these commands fail transiently. We keep retrying them until they succeed.
|
||||||
|
- until sudo add-apt-repository ppa:kalakris/tmux -y; do sleep 10; done
|
||||||
|
- until sudo add-apt-repository ppa:neovim-ppa/unstable -y; do sleep 10; done
|
||||||
|
- until sudo apt-get update -qq; do sleep 10; done
|
||||||
|
- until sudo apt-get install -qq -y --force-yes tmux xclip gdb neovim mercurial; do sleep 10; done
|
||||||
|
- ./travis_install.sh
|
||||||
|
|
||||||
|
script:
|
||||||
|
- ./travis_test.sh
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
webhooks:
|
||||||
|
urls:
|
||||||
|
- https://webhooks.gitter.im/e/558acac434012ba838cd
|
||||||
|
on_success: change # options: [always|never|change] default: always
|
||||||
|
on_failure: always # options: [always|never|change] default: always
|
||||||
|
on_start: false # default: false
|
@ -0,0 +1,73 @@
|
|||||||
|
[![Build Status](https://travis-ci.org/SirVer/ultisnips.svg?branch=master)](https://travis-ci.org/SirVer/ultisnips)
|
||||||
|
[![Stories in Ready](https://badge.waffle.io/SirVer/ultisnips.png?label=ready&title=Ready)](https://waffle.io/SirVer/ultisnips)
|
||||||
|
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/SirVer/ultisnips?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||||
|
|
||||||
|
UltiSnips
|
||||||
|
=========
|
||||||
|
|
||||||
|
UltiSnips is the ultimate solution for snippets in Vim. It has tons of features
|
||||||
|
and is very fast.
|
||||||
|
|
||||||
|
![GIF Demo](https://raw.github.com/SirVer/ultisnips/master/doc/demo.gif)
|
||||||
|
|
||||||
|
In this demo I am editing a python file. I first expand the `#!` snippet, then
|
||||||
|
the `class` snippet. The completion menu comes from
|
||||||
|
[YouCompleteMe](https://github.com/Valloric/YouCompleteMe), UltiSnips also
|
||||||
|
integrates with [neocomplete](https://github.com/Shougo/neocomplete.vim). I can
|
||||||
|
jump through placeholders and add text while the snippet inserts text in other
|
||||||
|
places automatically: when I add `Animal` as a base class, `__init__` gets
|
||||||
|
updated to call the base class constructor. When I add arguments to the
|
||||||
|
constructor, they automatically get assigned to instance variables. I then
|
||||||
|
insert my personal snippet for `print` debugging. Note that I left insert mode,
|
||||||
|
inserted another snippet and went back to add an additional argument to
|
||||||
|
`__init__` and the class snippet was still active and added another instance
|
||||||
|
variable.
|
||||||
|
|
||||||
|
The official home of UltiSnips is at <https://github.com/sirver/ultisnips>.
|
||||||
|
Please add pull requests and issues there.
|
||||||
|
|
||||||
|
UltiSnips was started in Jun 2009 by @SirVer. In Dec 2015, maintenance was
|
||||||
|
handed over to @seletskiy.
|
||||||
|
|
||||||
|
Quick Start
|
||||||
|
-----------
|
||||||
|
|
||||||
|
This assumes you are using [Vundle](https://github.com/gmarik/Vundle.vim). Adapt
|
||||||
|
for your plugin manager of choice. Put this into your `.vimrc`.
|
||||||
|
|
||||||
|
" Track the engine.
|
||||||
|
Plugin 'SirVer/ultisnips'
|
||||||
|
|
||||||
|
" Snippets are separated from the engine. Add this if you want them:
|
||||||
|
Plugin 'honza/vim-snippets'
|
||||||
|
|
||||||
|
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
|
||||||
|
let g:UltiSnipsExpandTrigger="<tab>"
|
||||||
|
let g:UltiSnipsJumpForwardTrigger="<c-b>"
|
||||||
|
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
|
||||||
|
|
||||||
|
" If you want :UltiSnipsEdit to split your window.
|
||||||
|
let g:UltiSnipsEditSplit="vertical"
|
||||||
|
|
||||||
|
UltiSnips comes with comprehensive
|
||||||
|
[documentation](https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt).
|
||||||
|
As there are more options and tons of features I suggest you at least skim it.
|
||||||
|
|
||||||
|
Screencasts
|
||||||
|
-----------
|
||||||
|
|
||||||
|
From a gentle introduction to really advanced in a few minutes: The blog posts
|
||||||
|
of the screencasts contain more advanced examples of the things discussed in the
|
||||||
|
videos.
|
||||||
|
|
||||||
|
- [Episode 1: What are snippets and do I need them?](http://www.sirver.net/blog/2011/12/30/first-episode-of-ultisnips-screencast/)
|
||||||
|
- [Episode 2: Creating Basic Snippets](http://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/)
|
||||||
|
- [Episode 3: What's new in version 2.0](http://www.sirver.net/blog/2012/02/05/third-episode-of-ultisnips-screencast/)
|
||||||
|
- [Episode 4: Python Interpolation](http://www.sirver.net/blog/2012/03/31/fourth-episode-of-ultisnips-screencast/)
|
||||||
|
|
||||||
|
Also the excellent [Vimcasts](http://vimcasts.org) dedicated three episodes to
|
||||||
|
UltiSnips:
|
||||||
|
|
||||||
|
- [Meet UltiSnips](http://vimcasts.org/episodes/meet-ultisnips/)
|
||||||
|
- [Using Python interpolation in UltiSnips snippets](http://vimcasts.org/episodes/ultisnips-python-interpolation/)
|
||||||
|
- [Using selected text in UltiSnips snippets](http://vimcasts.org/episodes/ultisnips-visual-placeholder/)
|
@ -1,22 +0,0 @@
|
|||||||
UltiSnips
|
|
||||||
=========
|
|
||||||
|
|
||||||
This is the official repository for UltiSnips. Send Pull request to
|
|
||||||
SirVer/ultisnips, not the automatic clone from vim-scripts or any
|
|
||||||
other fork of this project.
|
|
||||||
|
|
||||||
Screencasts
|
|
||||||
-----------
|
|
||||||
|
|
||||||
The blog posts of the screencasts contain more advanced examples of the things
|
|
||||||
discussed in the videos.
|
|
||||||
|
|
||||||
* `Episode 1: What are snippets and do I need them?`__
|
|
||||||
* `Episode 2: Creating Basic Snippets`__
|
|
||||||
* `Episode 3: What's new in version 2.0`__
|
|
||||||
* `Episode 4: Python Interpolation`__
|
|
||||||
|
|
||||||
__ http://www.sirver.net/blog/2011/12/30/first-episode-of-ultisnips-screencast/
|
|
||||||
__ http://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/
|
|
||||||
__ http://www.sirver.net/blog/2012/02/05/third-episode-of-ultisnips-screencast/
|
|
||||||
__ http://www.sirver.net/blog/2012/03/31/fourth-episode-of-ultisnips-screencast/
|
|
@ -1,21 +0,0 @@
|
|||||||
This directory contains the main scripts that come bundled with UltiSnips.
|
|
||||||
|
|
||||||
Standing On The Shoulders of Giants
|
|
||||||
===================================
|
|
||||||
|
|
||||||
The snippets have been collected from various other project which I want to
|
|
||||||
express my gratitude for. My main source for inspiration where the following
|
|
||||||
two projects:
|
|
||||||
|
|
||||||
TextMate: http://svn.textmate.org/trunk/Bundles/
|
|
||||||
SnipMate: http://code.google.com/p/snipmate/
|
|
||||||
|
|
||||||
All snippets from those sources were copied and cleaned up, so that they are
|
|
||||||
- not using shell script, only python (so they are cross platform compatible)
|
|
||||||
- not using any feature that UltiSnips doesn't offer
|
|
||||||
|
|
||||||
UltiSnips has seen contributions by various individuals. Those contributions
|
|
||||||
have been merged into this collection seamlessly and without further comments.
|
|
||||||
|
|
||||||
-- vim:ft=rst:nospell:
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
|||||||
# This file contains snippets that are always defined. I personally
|
|
||||||
# have snippets for signatures and often needed texts
|
|
||||||
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
##############
|
|
||||||
# NICE BOXES #
|
|
||||||
##############
|
|
||||||
global !p
|
|
||||||
import string, vim
|
|
||||||
|
|
||||||
""" Maps a filetype to comment format used for boxes.
|
|
||||||
Automatically filled during usage"""
|
|
||||||
_commentDict = { }
|
|
||||||
|
|
||||||
def _parse_comments(s):
|
|
||||||
""" Parses vim's comments option to extract comment format """
|
|
||||||
i = iter(s.split(","))
|
|
||||||
|
|
||||||
rv = []
|
|
||||||
try:
|
|
||||||
while True:
|
|
||||||
# get the flags and text of a comment part
|
|
||||||
flags, text = next(i).split(':', 1)
|
|
||||||
|
|
||||||
if len(flags) == 0:
|
|
||||||
rv.append((text, text, text, ""))
|
|
||||||
# parse 3-part comment, but ignore those with O flag
|
|
||||||
elif flags[0] == 's' and 'O' not in flags:
|
|
||||||
ctriple = []
|
|
||||||
indent = ""
|
|
||||||
|
|
||||||
if flags[-1] in string.digits:
|
|
||||||
indent = " " * int(flags[-1])
|
|
||||||
ctriple.append(text)
|
|
||||||
|
|
||||||
flags,text = next(i).split(':', 1)
|
|
||||||
assert(flags[0] == 'm')
|
|
||||||
ctriple.append(text)
|
|
||||||
|
|
||||||
flags,text = next(i).split(':', 1)
|
|
||||||
assert(flags[0] == 'e')
|
|
||||||
ctriple.append(text)
|
|
||||||
ctriple.append(indent)
|
|
||||||
|
|
||||||
rv.append(ctriple)
|
|
||||||
elif flags[0] == 'b':
|
|
||||||
if len(text) == 1:
|
|
||||||
rv.insert(0, (text,text,text, ""))
|
|
||||||
except StopIteration:
|
|
||||||
return rv
|
|
||||||
|
|
||||||
def _get_comment_format():
|
|
||||||
""" Returns a 4-element tuple representing the comment format for
|
|
||||||
the current file. """
|
|
||||||
return _parse_comments(vim.eval("&comments"))[0]
|
|
||||||
|
|
||||||
|
|
||||||
def make_box(twidth, bwidth=None):
|
|
||||||
b, m, e, i = _get_comment_format()
|
|
||||||
bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2
|
|
||||||
sline = b + m + bwidth_inner * m[0] + 2 * m[0]
|
|
||||||
nspaces = (bwidth_inner - twidth) // 2
|
|
||||||
mlines = i + m + " " + " " * nspaces
|
|
||||||
mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m
|
|
||||||
eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e
|
|
||||||
return sline, mlines, mlinee, eline
|
|
||||||
|
|
||||||
def foldmarker():
|
|
||||||
"Return a tuple of (open fold marker, close fold marker)"
|
|
||||||
return vim.eval("&foldmarker").split(",")
|
|
||||||
|
|
||||||
endglobal
|
|
||||||
|
|
||||||
snippet box "A nice box with the current comment symbol" b
|
|
||||||
`!p
|
|
||||||
box = make_box(len(t[1]))
|
|
||||||
snip.rv = box[0] + '\n' + box[1]
|
|
||||||
`${1:content}`!p
|
|
||||||
box = make_box(len(t[1]))
|
|
||||||
snip.rv = box[2] + '\n' + box[3]`
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet bbox "A nice box over the full width" b
|
|
||||||
`!p
|
|
||||||
width = int(vim.eval("&textwidth")) or 71
|
|
||||||
box = make_box(len(t[1]), width)
|
|
||||||
snip.rv = box[0] + '\n' + box[1]
|
|
||||||
`${1:content}`!p
|
|
||||||
box = make_box(len(t[1]), width)
|
|
||||||
snip.rv = box[2] + '\n' + box[3]`
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fold "Insert a vim fold marker" b
|
|
||||||
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = _get_comment_format()[2]`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet foldc "Insert a vim fold close marker" b
|
|
||||||
`!p snip.rv = _get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = _get_comment_format()[2]`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet foldp "Insert a vim fold marker pair" b
|
|
||||||
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = _get_comment_format()[2]`
|
|
||||||
${2:${VISUAL:Content}}
|
|
||||||
`!p snip.rv = _get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = _get_comment_format()[2]`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# LOREM IPSUM GENERATORS #
|
|
||||||
##########################
|
|
||||||
snippet lorem "Lorem Ipsum - 50 Words" b
|
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
|
||||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
|
|
||||||
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
|
|
||||||
no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,52 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
snippet online "Online resource" b
|
|
||||||
@online{${1:name},
|
|
||||||
author={${2:author}},
|
|
||||||
title={${3:title}},
|
|
||||||
date={${4:date}},
|
|
||||||
url={${5:url}}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet article "Article reference" b
|
|
||||||
@article{${1:name},
|
|
||||||
author={${2:author}},
|
|
||||||
title={${3:title}},
|
|
||||||
journaltitle={${4:journal}},
|
|
||||||
volume={${5:NN}},
|
|
||||||
number={${6:NN}},
|
|
||||||
year={${7:YYYY}},
|
|
||||||
pages={${8:NN}--${9:NN}}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet book "Book reference" b
|
|
||||||
@book{${1:name},
|
|
||||||
author={${2:author}},
|
|
||||||
title={${3:title}},
|
|
||||||
subtitle={${4:subtitle}},
|
|
||||||
year={${5:YYYY}},
|
|
||||||
location={${6:somewhere}},
|
|
||||||
publisher={${7:publisher}},
|
|
||||||
pages={${8:NN}--${9:NN}}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet inb "In Book reference" b
|
|
||||||
@inbook{${1:name},
|
|
||||||
author={${2:author}},
|
|
||||||
title={${3:title}},
|
|
||||||
subtitle={${4:subtitle}},
|
|
||||||
booktitle={${5:book}},
|
|
||||||
editor={${6:editor}},
|
|
||||||
year={${7:YYYY}},
|
|
||||||
location={${8:somewhere}},
|
|
||||||
publisher={${9:publisher}},
|
|
||||||
pages={${10:NN}--${11:NN}}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
@ -1,29 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
global !p
|
|
||||||
def newsoa():
|
|
||||||
import datetime
|
|
||||||
now = datetime.datetime.now()
|
|
||||||
# return standard SOA formatted serial for today
|
|
||||||
return now.strftime("%Y%m%d00")
|
|
||||||
endglobal
|
|
||||||
|
|
||||||
snippet zone "Bootstrap a new Bind zonefile" b
|
|
||||||
$TTL 86400
|
|
||||||
@ IN SOA ${1:example.net}. ${2:hostmaster.$1}.(
|
|
||||||
`!p snip.rv = newsoa()`; serial
|
|
||||||
21600; refresh every 6 hours
|
|
||||||
3600; retry after one hour
|
|
||||||
604800; expire after a week
|
|
||||||
86400 ); minimum TTL of 1 day
|
|
||||||
|
|
||||||
IN NS ns01.$1.
|
|
||||||
IN MX 10 mail.$1.
|
|
||||||
|
|
||||||
ns01.$1 IN A
|
|
||||||
mail.$1 IN A
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet A "Insert A Record" b
|
|
||||||
${1:hostname} IN A ${2:ip}
|
|
||||||
endsnippet
|
|
@ -1,155 +0,0 @@
|
|||||||
###########################################################################
|
|
||||||
# TextMate Snippets #
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
snippet def "#define ..."
|
|
||||||
#define ${1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifndef "#ifndef ... #define ... #endif"
|
|
||||||
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
|
|
||||||
#define ${1:SYMBOL} ${2:value}
|
|
||||||
#endif
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet #if "#if #endif" b
|
|
||||||
#if ${1:0}
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}}
|
|
||||||
#endif
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet inc "#include local header (inc)"
|
|
||||||
#include "${1:`!p snip.rv = snip.basename + '.h'`}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Inc "#include <> (Inc)"
|
|
||||||
#include <${1:.h}>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mark "#pragma mark (mark)"
|
|
||||||
#if 0
|
|
||||||
${1:#pragma mark -
|
|
||||||
}#pragma mark $2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet main "main() (main)"
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for loop (for)"
|
|
||||||
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
|
||||||
{
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fori "for int loop (fori)"
|
|
||||||
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
|
||||||
{
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet enum "Enumeration"
|
|
||||||
enum ${1:name} { $0 };
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet once "Include header once only guard"
|
|
||||||
#ifndef ${1:`!p
|
|
||||||
if not snip.c:
|
|
||||||
import random, string
|
|
||||||
name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper()
|
|
||||||
rand = ''.join(random.sample(string.ascii_letters+string.digits, 8))
|
|
||||||
snip.rv = ('%s_%s' % (name,rand)).upper()
|
|
||||||
else:
|
|
||||||
snip.rv = snip.c`}
|
|
||||||
#define $1
|
|
||||||
|
|
||||||
${0}
|
|
||||||
|
|
||||||
#endif /* end of include guard: $1 */
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet td "Typedef"
|
|
||||||
typedef ${1:int} ${2:MyCustomType};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wh "while loop"
|
|
||||||
while(${1:/* condition */}) {
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet do "do...while loop (do)"
|
|
||||||
do {
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
} while(${1:/* condition */});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fprintf "fprintf ..."
|
|
||||||
fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if .. (if)"
|
|
||||||
if (${1:/* condition */})
|
|
||||||
{
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet el "else .. (else)"
|
|
||||||
else {
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet eli "else if .. (eli)"
|
|
||||||
else if (${1:/* condition */}) {
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ife "if .. else (ife)"
|
|
||||||
if (${1:/* condition */})
|
|
||||||
{
|
|
||||||
${2:/* code */}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
${3:/* else */}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet printf "printf .. (printf)"
|
|
||||||
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet st "struct"
|
|
||||||
struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`}
|
|
||||||
{
|
|
||||||
${0:/* data */}
|
|
||||||
};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fun "function" b
|
|
||||||
${1:void} ${2:function_name}(${3})
|
|
||||||
{
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fund "function declaration" b
|
|
||||||
${1:void} ${2:function_name}(${3});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,91 +0,0 @@
|
|||||||
# From the TextMate bundle
|
|
||||||
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
snippet fun "Function" b
|
|
||||||
${1:name} = (${2:args}) ->
|
|
||||||
${0:# body...}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet bfun "Function (bound)" b
|
|
||||||
${1:(${2:args}) }=>
|
|
||||||
${0:# body...}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "If" b
|
|
||||||
if ${1:condition}
|
|
||||||
${0:# body...}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ife "If .. Else" b
|
|
||||||
if ${1:condition}
|
|
||||||
${2:# body...}
|
|
||||||
else
|
|
||||||
${3:# body...}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet elif "Else if" b
|
|
||||||
else if ${1:condition}
|
|
||||||
${0:# body...}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifte "Ternary if" b
|
|
||||||
if ${1:condition} then ${2:value} else ${3:other}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet unl "Unless" b
|
|
||||||
${1:action} unless ${2:condition}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fora "Array Comprehension" b
|
|
||||||
for ${1:name} in ${2:array}
|
|
||||||
${0:# body...}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet foro "Object Comprehension" b
|
|
||||||
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}}
|
|
||||||
${0:# body...}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet forrex "Range Comprehension (exclusive)" b
|
|
||||||
for ${1:name} in [${2:start}...${3:finish}]${4: by ${5:step}}
|
|
||||||
${0:# body...}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet swi "Switch" b
|
|
||||||
switch ${1:object}
|
|
||||||
when ${2:value}
|
|
||||||
${0:# body...}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cla "Class" b
|
|
||||||
class ${1:ClassName}${2: extends ${3:Ancestor}}
|
|
||||||
|
|
||||||
${4:constructor: (${5:args}) ->
|
|
||||||
${6:# body...}}
|
|
||||||
$7
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet try "Try .. Catch" b
|
|
||||||
try
|
|
||||||
$1
|
|
||||||
catch ${2:error}
|
|
||||||
$3
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet req "Require" b
|
|
||||||
${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet # "Interpolated Code"
|
|
||||||
#{$1}$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet log "Log" b
|
|
||||||
console.log ${1:"${2:msg}"}
|
|
||||||
endsnippet
|
|
@ -1,166 +0,0 @@
|
|||||||
#
|
|
||||||
# CoffeeScript versions -- adapted from the JS TextMate bundle + additions
|
|
||||||
# for some jasmine-jquery matchers
|
|
||||||
#
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
extends coffee
|
|
||||||
|
|
||||||
priority -49
|
|
||||||
|
|
||||||
snippet des "Describe (coffee)" b
|
|
||||||
describe '${1:description}', ->
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet it "it (coffee)" b
|
|
||||||
it '${1:description}', ->
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet bef "before each (coffee)" b
|
|
||||||
beforeEach ->
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet aft "after each (coffee)" b
|
|
||||||
afterEach ->
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet any "any (coffee)" b
|
|
||||||
jasmine.any($1)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ru "runs (coffee)" b
|
|
||||||
runs ->
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wa "waits (coffee)" b
|
|
||||||
waits($1)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ex "expect (coffee)" b
|
|
||||||
expect(${1:target})$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ee "expect to equal (coffee)" b
|
|
||||||
expect(${1:target}).toEqual(${2:value})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet em "expect to match (coffee)" b
|
|
||||||
expect(${1:target}).toMatch(${2:pattern})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet eha "expect to have attribute (coffee)" b
|
|
||||||
expect(${1:target}).toHaveAttr('${2:attr}'${3:, '${4:value}'})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet et "expect to be truthy (coffee)" b
|
|
||||||
expect(${1:target}).toBeTruthy()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ef "expect to be falsy (coffee)" b
|
|
||||||
expect(${1:target}).toBeFalsy()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ed "expect to be defined (coffee)" b
|
|
||||||
expect(${1:target}).toBeDefined()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet en "expect to be null (coffee)" b
|
|
||||||
expect(${1:target}).toBeNull()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ec "expect to contain (coffee)" b
|
|
||||||
expect(${1:target}).toContain(${2:value})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ev "expect to be visible (coffee)" b
|
|
||||||
expect(${1:target}).toBeVisible()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet eh "expect to be hidden (coffee)" b
|
|
||||||
expect(${1:target}).toBeHidden()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notx "expect not (coffee)" b
|
|
||||||
expect(${1:target}).not$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet note "expect not to equal (coffee)" b
|
|
||||||
expect(${1:target}).not.toEqual(${2:value})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notm "expect not to match (coffee)" b
|
|
||||||
expect(${1:target}).not.toMatch(${2:pattern})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notha "expect to not have attribute (coffee)" b
|
|
||||||
expect(${1:target}).not.toHaveAttr('${2:attr}'${3:, '${4:value}'})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet nott "expect not to be truthy (coffee)" b
|
|
||||||
expect(${1:target}).not.toBeTruthy()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notf "expect not to be falsy (coffee)" b
|
|
||||||
expect(${1:target}).not.toBeFalsy()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notd "expect not to be defined (coffee)" b
|
|
||||||
expect(${1:target}).not.toBeDefined()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notn "expect not to be null (coffee)" b
|
|
||||||
expect(${1:target}).not.toBeNull()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notc "expect not to contain (coffee)" b
|
|
||||||
expect(${1:target}).not.toContain(${2:value})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notv "expect not to be visible (coffee)" b
|
|
||||||
expect(${1:target}).not.toBeVisible()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet noth "expect not to be hidden (coffee)" b
|
|
||||||
expect(${1:target}).not.toBeHidden()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet s "spy on (coffee)" b
|
|
||||||
spyOn(${1:object}, "${2:method}")$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sr "spy on and return (coffee)" b
|
|
||||||
spyOn(${1:object}, "${2:method}").andReturn(${3:arguments})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet st "spy on and throw (coffee)" b
|
|
||||||
spyOn(${1:object}, "${2:method}").andThrow(${3:exception})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sct "spy on and call through (coffee)" b
|
|
||||||
spyOn(${1:object}, "${2:method}").andCallThrough()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet scf "spy on and call fake (coffee)" b
|
|
||||||
spyOn(${1:object}, "${2:method}").andCallFake(${3:function})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet esc "expect was called (coffee)" b
|
|
||||||
expect(${1:target}).wasCalled()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet escw "expect was called with (coffee)" b
|
|
||||||
expect(${1:target}).wasCalledWith(${2:arguments})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notsc "expect was not called (coffee)" b
|
|
||||||
expect(${1:target}).wasNotCalled()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet noscw "expect was not called with (coffee)" b
|
|
||||||
expect(${1:target}).wasNotCalledWith(${2:arguments})
|
|
||||||
endsnippet
|
|
@ -1,57 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
extends c
|
|
||||||
|
|
||||||
# We want to overwrite everything in parent ft.
|
|
||||||
priority -49
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# TextMate Snippets #
|
|
||||||
###########################################################################
|
|
||||||
snippet beginend "$1.begin(), $1.end() (beginend)"
|
|
||||||
${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), $1${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cl "class .. (class)"
|
|
||||||
class ${1:`!p snip.rv = snip.basename or "name"`}
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
${1/(\w+).*/$1/} (${2:arguments});
|
|
||||||
virtual ~${1/(\w+).*/$1/} ();
|
|
||||||
|
|
||||||
private:
|
|
||||||
${0:/* data */}
|
|
||||||
};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ns "namespace .. (namespace)"
|
|
||||||
namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`}
|
|
||||||
{
|
|
||||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
|
||||||
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet readfile "read file (readF)"
|
|
||||||
std::vector<char> v;
|
|
||||||
if (FILE *fp = fopen(${1:"filename"}, "r"))
|
|
||||||
{
|
|
||||||
char buf[1024];
|
|
||||||
while(size_t len = fread(buf, 1, sizeof(buf), fp))
|
|
||||||
v.insert(v.end(), buf, buf + len);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet map "std::map (map)"
|
|
||||||
std::map<${1:key}, ${2:value}> map$0;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vector "std::vector (v)"
|
|
||||||
std::vector<${1:char}> v$0;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tp "template <typename ..> (template)"
|
|
||||||
template <typename ${1:_InputIter}>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,328 +0,0 @@
|
|||||||
#######################################################################
|
|
||||||
# C# Snippets for UltiSnips #
|
|
||||||
#######################################################################
|
|
||||||
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# classes and structs #
|
|
||||||
#########################
|
|
||||||
|
|
||||||
snippet namespace "namespace" b
|
|
||||||
namespace ${1:MyNamespace}
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet class "class" w
|
|
||||||
class ${1:MyClass}
|
|
||||||
{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet struct "struct" w
|
|
||||||
struct ${1:MyStruct}
|
|
||||||
{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet interface "interface" w
|
|
||||||
interface I${1:Interface}
|
|
||||||
{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet enum "enumeration" b
|
|
||||||
enum ${1:MyEnum} { ${2:Item} };
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
############
|
|
||||||
# Main() #
|
|
||||||
############
|
|
||||||
|
|
||||||
snippet sim "static int main" b
|
|
||||||
static int Main(string[] args)
|
|
||||||
{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet svm "static void main" b
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
################
|
|
||||||
# properties #
|
|
||||||
################
|
|
||||||
|
|
||||||
snippet prop "Simple property declaration" b
|
|
||||||
public ${1:int} ${2:MyProperty} { get; set; }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet propfull "Full property declaration" b
|
|
||||||
private ${1:int} ${2:_myProperty};
|
|
||||||
|
|
||||||
public $1 ${3:MyProperty}
|
|
||||||
{
|
|
||||||
get { return $2; }
|
|
||||||
set { $2 = value; }
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet propg "Property with a private setter" b
|
|
||||||
public ${1:int} ${2:MyProperty} { get; private set; }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
############
|
|
||||||
# blocks #
|
|
||||||
############
|
|
||||||
|
|
||||||
snippet #if "#if #endif" b
|
|
||||||
#if ${1:DEBUG}
|
|
||||||
${VISUAL}$0
|
|
||||||
#endif
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet #region "#region #endregion" b
|
|
||||||
#region ${1:Region}
|
|
||||||
${VISUAL}$0
|
|
||||||
#endregion
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
###########
|
|
||||||
# loops #
|
|
||||||
###########
|
|
||||||
|
|
||||||
snippet for "for loop" b
|
|
||||||
for (int ${1:i} = 0; $1 < ${2:10}; $1++)
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet forr "for loop (reverse)" b
|
|
||||||
for (int ${1:i} = ${2:10}; $1 >= 0; $1--)
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet foreach "foreach loop" b
|
|
||||||
foreach (${3:var} ${2:item} in ${1:items})
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet while "while loop" b
|
|
||||||
while (${1:true})
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet do "do loop" b
|
|
||||||
do
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
} while (${1:true});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
###############
|
|
||||||
# branching #
|
|
||||||
###############
|
|
||||||
|
|
||||||
snippet if "if statement" b
|
|
||||||
if ($1)
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ife "if else statement" b
|
|
||||||
if ($1)
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet elif "else if" b
|
|
||||||
else if ($1)
|
|
||||||
{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet elseif "else if" b
|
|
||||||
else if ($1)
|
|
||||||
{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifnn "if not null" b
|
|
||||||
if ($1 != null)
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet switch "switch statement" b
|
|
||||||
switch (${1:statement})
|
|
||||||
{
|
|
||||||
case ${2:value}:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$0break;
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet case "case" b
|
|
||||||
case ${1:value}:
|
|
||||||
$2
|
|
||||||
break;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
##############
|
|
||||||
# wrappers #
|
|
||||||
##############
|
|
||||||
|
|
||||||
snippet using "using statement" b
|
|
||||||
using (${1:resource})
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet unchecked "unchecked block" b
|
|
||||||
unchecked
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet checked "checked block" b
|
|
||||||
checked
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet unsafe "unsafe" b
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
########################
|
|
||||||
# exception handling #
|
|
||||||
########################
|
|
||||||
|
|
||||||
snippet try "try catch block" b
|
|
||||||
try
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
catch (${1:Exception} ${2:e})
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tryf "try finally block" b
|
|
||||||
try
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet throw "throw"
|
|
||||||
throw new ${1}Exception("${2}");
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
##########
|
|
||||||
# LINQ #
|
|
||||||
##########
|
|
||||||
|
|
||||||
snippet from "LINQ syntax" b
|
|
||||||
var ${1:seq} =
|
|
||||||
from ${2:item1} in ${3:items1}
|
|
||||||
join ${4:item2} in ${5:items2} on $2.${6:prop1} equals $4.${7:prop2}
|
|
||||||
select ${8:$2.prop3}
|
|
||||||
where ${9:clause}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
############################
|
|
||||||
# feedback and debugging #
|
|
||||||
############################
|
|
||||||
|
|
||||||
snippet da "Debug.Assert" b
|
|
||||||
Debug.Assert(${1:true});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cw "Console.WriteLine" b
|
|
||||||
Console.WriteLine("$1");
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# as you first type comma-separated parameters on the right, {n} values appear in the format string
|
|
||||||
snippet cwp "Console.WriteLine with parameters" b
|
|
||||||
Console.WriteLine("${2:`!p
|
|
||||||
snip.rv = ' '.join(['{' + str(i) + '}' for i in range(t[1].count(','))])
|
|
||||||
`}"${1:, something});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mbox "Message box" b
|
|
||||||
MessageBox.Show("${1:message}");
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
##################
|
|
||||||
# full methods #
|
|
||||||
##################
|
|
||||||
|
|
||||||
snippet equals "Equals method" b
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (obj == null || GetType() != obj.GetType())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
return base.Equals(obj);
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
##############
|
|
||||||
# comments #
|
|
||||||
##############
|
|
||||||
|
|
||||||
snippet /// "XML comment" b
|
|
||||||
/// <summary>
|
|
||||||
/// $1
|
|
||||||
/// </summary>
|
|
||||||
endsnippet
|
|
@ -1,407 +0,0 @@
|
|||||||
###########################################################################
|
|
||||||
# Most of these came from TextMate #
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
snippet ! "!important CSS (!)"
|
|
||||||
${1:!important}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fixed "Fixed Position Bottom 100% wide IE6"
|
|
||||||
${2:bottom: auto;}top: expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-${1:THE HEIGHT OF THIS THING IN PIXELS}));
|
|
||||||
${3:left: expression(eval(document.documentElement.scrollLeft));
|
|
||||||
}${4:width: expression(eval(document.documentElement.clientWidth));}$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background-attachment: scroll:fixed (background)"
|
|
||||||
background-attachment: ${1:scroll/fixed};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background-color: color-hex (background)"
|
|
||||||
background-color: #${1:DDD};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background-color: color-name (background)"
|
|
||||||
background-color: ${1:red};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background-color: color-rgb (background)"
|
|
||||||
background-color: rgb(${1:255},${2:255},${3:255});$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background-color: transparent (background)"
|
|
||||||
background-color: transparent;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background-image: none (background)"
|
|
||||||
background-image: none;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background-image: url (background)"
|
|
||||||
background-image: url($1);$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background-position: position (background)"
|
|
||||||
background-position: ${1:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background-repeat: r:r-x:r-y:n-r (background)"
|
|
||||||
background-repeat: ${1:repeat/repeat-x/repeat-y/no-repeat};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet background "background: color image repeat attachment position (background)"
|
|
||||||
background:${6: #${1:DDD}} url($2) ${3:repeat/repeat-x/repeat-y/no-repeat} ${4:scroll/fixed} ${5:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-bottom-color: size style color (border)"
|
|
||||||
border-bottom-color: #${1:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-bottom-style: size style color (border)"
|
|
||||||
border-bottom-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-bottom-width: size style color (border)"
|
|
||||||
border-bottom-width: ${1:1}px ${2:solid} #${3:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-bottom: size style color (border)"
|
|
||||||
border-bottom: ${1:1}px ${2:solid} #${3:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-color: color (border)"
|
|
||||||
border-color: ${1:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-left-color: color (border)"
|
|
||||||
border-right-color: #${1:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-left-style: style (border)"
|
|
||||||
border-left-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-left-width: size (border)"
|
|
||||||
border-left-width: ${1:1}px
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-left: size style color (border)"
|
|
||||||
border-left: ${1:1}px ${2:solid} #${3:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-right-color: color (border)"
|
|
||||||
border-right-color: #${1:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-right-style: style (border)"
|
|
||||||
border-right-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-right-width: size (border)"
|
|
||||||
border-right-width: ${1:1}px
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-right: size style color (border)"
|
|
||||||
border-right: ${1:1}px ${2:solid} #${3:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-style: style (border)"
|
|
||||||
border-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-top-color: color (border)"
|
|
||||||
border-top-color: #${1:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-top-style: style (border)"
|
|
||||||
border-top-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-top-width: size (border)"
|
|
||||||
border-top-width: ${1:1}px
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-top: size style color (border)"
|
|
||||||
border-top: ${1:1}px ${2:solid} #${3:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border-width: width (border)"
|
|
||||||
border-width: ${1:1px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet border "border: size style color (border)"
|
|
||||||
border: ${1:1px} ${2:solid} #${3:999};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet clear "clear: value (clear)"
|
|
||||||
clear: ${1:left/right/both/none};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet color "color: color-hex (color)"
|
|
||||||
color: #${1:DDD};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet color "color: color-name (color)"
|
|
||||||
color: ${1:red};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet color "color: color-rgb (color)"
|
|
||||||
color: rgb(${1:255},${2:255},${3:255});$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cursor "cursor: type (cursor)"
|
|
||||||
cursor: ${1:default/auto/crosshair/pointer/move/*-resize/text/wait/help};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cursor "cursor: url (cursor)"
|
|
||||||
cursor: url($1);$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet direction "direction: ltr|rtl (direction)"
|
|
||||||
direction: ${1:ltr|rtl};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet display "display: block (display)"
|
|
||||||
display: block;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet display "display: common-types (display)"
|
|
||||||
display: ${1:none/inline/block/list-item/run-in/compact/marker};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet display "display: inline (display)"
|
|
||||||
display: inline;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet display "display: table-types (display)"
|
|
||||||
display: ${1:table/inline-table/table-row-group/table-header-group/table-footer-group/table-row/table-column-group/table-column/table-cell/table-caption};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet float "float: left:right:none (float)"
|
|
||||||
float: ${1:left/right/none};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet font "font-family: family (font)"
|
|
||||||
font-family: ${1:Arial, "MS Trebuchet"}, ${2:sans-}serif;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet font "font-size: size (font)"
|
|
||||||
font-size: ${1:100%};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet font "font-style: normal:italic:oblique (font)"
|
|
||||||
font-style: ${1:normal/italic/oblique};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet font "font-variant: normal:small-caps (font)"
|
|
||||||
font-variant: ${1:normal/small-caps};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet font "font-weight: weight (font)"
|
|
||||||
font-weight: ${1:normal/bold};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet font "font: style variant weight size:line-height font -family (font)"
|
|
||||||
font: ${1:normal/italic/oblique} ${2:normal/small-caps} ${3:normal/bold} ${4:1em/1.5em} ${5:Arial}, ${6:sans-}serif;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet font "font: size font (font)"
|
|
||||||
font: ${1:75%} ${2:"Lucida Grande", "Trebuchet MS", Verdana,} ${3:sans-}serif;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet letter "letter-spacing: length-em (letter)"
|
|
||||||
letter-spacing: $1em;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet letter "letter-spacing: length-px (letter)"
|
|
||||||
letter-spacing: $1px;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet list "list-style-image: url (list)"
|
|
||||||
list-style-image: url($1);$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet list "list-style-position: pos (list)"
|
|
||||||
list-style-position: ${1:inside/outside};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet list "list-style-type: asian (list)"
|
|
||||||
list-style-type: ${1:cjk-ideographic/hiragana/katakana/hiragana-iroha/katakana-iroha};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet list "list-style-type: marker(list)"
|
|
||||||
list-style-type: ${1:none/disc/circle/square};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet list "list-style-type: numeric (list)"
|
|
||||||
list-style-type: ${1:decimal/decimal-leading-zero/zero};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet list "list-style-type: other (list)"
|
|
||||||
list-style-type: ${1:hebrew/armenian/georgian};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet list "list-style-type: roman-alpha-greek (list)"
|
|
||||||
list-style-type: ${1:lower-roman/upper-roman/lower-alpha/upper-alpha/lower-greek/lower-latin/upper-latin};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet list "list-style: type position image (list)"
|
|
||||||
list-style: ${1:none/disc/circle/square/decimal/zero} ${2:inside/outside} url($3);$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet margin "margin-bottom: length (margin)"
|
|
||||||
margin-bottom: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet margin "margin-left: length (margin)"
|
|
||||||
margin-left: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet margin "margin-right: length (margin)"
|
|
||||||
margin-right: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet margin "margin-top: length (margin)"
|
|
||||||
margin-top: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet margin "margin: all (margin)"
|
|
||||||
margin: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet margin "margin: T R B L (margin)"
|
|
||||||
margin: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet margin "margin: V H (margin)"
|
|
||||||
margin: ${1:20px} ${2:0px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet marker "marker-offset: auto (marker)"
|
|
||||||
marker-offset: auto;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet marker "marker-offset: length (marker)"
|
|
||||||
marker-offset: ${1:10px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet overflow "overflow: type (overflow)"
|
|
||||||
overflow: ${1:visible/hidden/scroll/auto};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet padding "padding-bottom: length (margin)"
|
|
||||||
padding-bottom: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet padding "padding-left: length (margin)"
|
|
||||||
padding-left: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet padding "padding-right: length (margin)"
|
|
||||||
padding-right: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet padding "padding-top: length (margin)"
|
|
||||||
padding-top: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet padding "padding: T R B L (padding)"
|
|
||||||
padding: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet padding "padding: V H (padding)"
|
|
||||||
padding: ${1:20px} ${2:0px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet padding "padding: all (padding)"
|
|
||||||
padding: ${1:20px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet position "position: type (position)"
|
|
||||||
position: ${1:static/relative/absolute/fixed};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet { "properties { } ( } )"
|
|
||||||
{
|
|
||||||
/* $1 */
|
|
||||||
$0
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet scrollbar "scrollbar"
|
|
||||||
scrollbar-base-color: ${1:#CCCCCC};${2:
|
|
||||||
scrollbar-arrow-color: ${3:#000000};
|
|
||||||
scrollbar-track-color: ${4:#999999};
|
|
||||||
scrollbar-3dlight-color: ${5:#EEEEEE};
|
|
||||||
scrollbar-highlight-color: ${6:#FFFFFF};
|
|
||||||
scrollbar-face-color: ${7:#CCCCCC};
|
|
||||||
scrollbar-shadow-color: ${9:#999999};
|
|
||||||
scrollbar-darkshadow-color: ${8:#666666};}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet selection "selection"
|
|
||||||
$1::-moz-selection,
|
|
||||||
$1::selection {
|
|
||||||
color: ${2:inherit};
|
|
||||||
background: ${3:inherit};
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet text "text-align: left:center:right (txt)"
|
|
||||||
text-align: ${1:left/right/center/justify};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet text "text-decoration: none:underline:overline:line-through:blink (text)"
|
|
||||||
text-decoration: ${1:none/underline/overline/line-through/blink};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet text "text-indent: length (text)"
|
|
||||||
text-indent: ${1:10}px;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet text "text-shadow: color-hex x y blur (text)"
|
|
||||||
text-shadow: #${1:DDD} ${2:10px} ${3:10px} ${4:2px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet text "text-shadow: color-rgb x y blur (text)"
|
|
||||||
text-shadow: rgb(${1:255},${2:255},${3:255}) ${4:10px} ${5:10px} ${6:2px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet text "text-shadow: none (text)"
|
|
||||||
text-shadow: none;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet text "text-transform: capitalize:upper:lower (text)"
|
|
||||||
text-transform: ${1:capitalize/uppercase/lowercase};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet text "text-transform: none (text)"
|
|
||||||
text-transform: none;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vertical "vertical-align: type (vertical)"
|
|
||||||
vertical-align: ${1:baseline/sub/super/top/text-top/middle/bottom/text-bottom/length/%};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet visibility "visibility: type (visibility)"
|
|
||||||
visibility: ${1:visible/hidden/collapse};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet white "white-space: normal:pre:nowrap (white)"
|
|
||||||
white-space: ${1:normal/pre/nowrap};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet word "word-spacing: length (word)"
|
|
||||||
word-spacing: ${1:10px};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet word "word-spacing: normal (word)"
|
|
||||||
word-spacing: normal;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet z "z-index: index (z)"
|
|
||||||
z-index: $1;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,584 +0,0 @@
|
|||||||
# Simple shortcuts
|
|
||||||
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
snippet imp "import (imp)" b
|
|
||||||
import ${1:std.stdio};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pimp "public import (pimp)" b
|
|
||||||
public import ${1:/*module*/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet over "override (over)" b
|
|
||||||
override ${1:/*function*/}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet al "alias (al)"
|
|
||||||
alias ${1:/*orig*/} ${2:/*alias*/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mixin "mixin (mixin)" b
|
|
||||||
mixin ${1:/*mixed_in*/} ${2:/*name*/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet new "new (new)"
|
|
||||||
new ${1}(${2});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet scpn "@safe const pure nothrow (scpn)"
|
|
||||||
@safe const pure nothrow
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet spn "@safe pure nothrow (spn)"
|
|
||||||
@safe pure nothrow
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cont "continue (cont)"
|
|
||||||
continue;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet dis "@disable (dis)" b
|
|
||||||
@disable ${1:/*method*/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pub "public (pub)" b
|
|
||||||
public:
|
|
||||||
${1:/*members*/}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet priv "private (priv)" b
|
|
||||||
private:
|
|
||||||
${1:/*members*/}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet prot "protected (prot)" b
|
|
||||||
protected:
|
|
||||||
${1:/*members*/}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pack "package (pack)" b
|
|
||||||
package:
|
|
||||||
${1:/*members*/}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ret "return (ret)"
|
|
||||||
return ${1:/*value to return*/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet auto "auto (auto)" b
|
|
||||||
auto ${1:/*variable*/} = ${2:/*value*/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet con "const (con)" b
|
|
||||||
const ${1:/*variable*/} = ${2:/*value*/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet siz "size_t (siz)" b
|
|
||||||
size_t ${1:/*variable*/} = ${2:/*value*/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sup "super (sup)" b
|
|
||||||
super(${1:/*args*/});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Phobos
|
|
||||||
|
|
||||||
snippet tup "tuple (tup)"
|
|
||||||
tuple(${1:/*args*/})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wr "writeln (wr)"
|
|
||||||
writeln(${1:/*args*/});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet to "to (to)"
|
|
||||||
to!(${1:/*type*/})(${2:/*arg*/})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet enf "enforce (enf)" b
|
|
||||||
enforce(${1:/*condition*/},
|
|
||||||
new ${2}Exception(${3:/*args*/}));
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Branches
|
|
||||||
|
|
||||||
snippet if "if .. (if)"
|
|
||||||
if(${1:/*condition*/})
|
|
||||||
{
|
|
||||||
${VISUAL}${0:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ife "if .. else (ife)" b
|
|
||||||
if(${1:/*condition*/})
|
|
||||||
{
|
|
||||||
${2:/*code*/}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
${3:/*else*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet el "else (el)" b
|
|
||||||
else
|
|
||||||
{
|
|
||||||
${VISUAL}${1:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet elif "else if (elif)" b
|
|
||||||
else if(${1:/*condition*/})
|
|
||||||
{
|
|
||||||
${VISUAL}${0:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sw "switch (sw)"
|
|
||||||
switch(${1:/*var*/})
|
|
||||||
{
|
|
||||||
case ${2:/*value*/}:
|
|
||||||
${3:/*code*/}
|
|
||||||
break;
|
|
||||||
case ${4:/*value*/}:
|
|
||||||
${5:/*code*/}
|
|
||||||
break;
|
|
||||||
${7:/*more cases*/}
|
|
||||||
default:
|
|
||||||
${6:assert(false);}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fsw "final switch (fsw)"
|
|
||||||
switch(${1:/*var*/})
|
|
||||||
{
|
|
||||||
case ${2:/*value*/}:
|
|
||||||
${3:/*code*/}
|
|
||||||
break;
|
|
||||||
case ${4:/*value*/}:
|
|
||||||
${5:/*code*/}
|
|
||||||
break;
|
|
||||||
${7:/*more cases*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet case "case (case)" b
|
|
||||||
case ${1:/*value*/}:
|
|
||||||
${2:/*code*/}
|
|
||||||
break;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ?: "ternary operator (?:)"
|
|
||||||
${1:/*condition*/} ? ${2:/*then*/} : ${3:/*else*/}$4
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Loops
|
|
||||||
|
|
||||||
snippet do "do while (do)" b
|
|
||||||
do
|
|
||||||
{
|
|
||||||
${VISUAL}${2:/*code*/}
|
|
||||||
} while(${1:/*condition*/});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wh "while (wh)" b
|
|
||||||
while(${1:/*condition*/})
|
|
||||||
{
|
|
||||||
${VISUAL}${2:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for (for)" b
|
|
||||||
for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
|
||||||
{
|
|
||||||
${VISUAL}${0:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet forever "forever (forever)" b
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
${VISUAL}${0:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fore "foreach (fore)"
|
|
||||||
foreach(${1:/*elem*/}; ${2:/*range*/})
|
|
||||||
{
|
|
||||||
${VISUAL}${3:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet forif "foreach if (forif)" b
|
|
||||||
foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/})
|
|
||||||
{
|
|
||||||
${VISUAL}${4:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Contracts
|
|
||||||
snippet in "in contract (in)" b
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(${1:/*condition*/}, "${2:error message}");
|
|
||||||
${3}
|
|
||||||
}
|
|
||||||
body
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet out "out contract (out)" b
|
|
||||||
out${1:(result)}
|
|
||||||
{
|
|
||||||
assert(${2:/*condition*/}, "${3:error message}");
|
|
||||||
${4}
|
|
||||||
}
|
|
||||||
body
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet inv "invariant (inv)" b
|
|
||||||
invariant()
|
|
||||||
{
|
|
||||||
assert(${1:/*condition*/}, "${2:error message}");
|
|
||||||
${3}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Functions (generic)
|
|
||||||
|
|
||||||
snippet fun "function definition (fun)"
|
|
||||||
${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow}
|
|
||||||
{
|
|
||||||
${VISUAL}${5:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet void "void function definition (void)"
|
|
||||||
void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow}
|
|
||||||
{
|
|
||||||
${VISUAL}${4:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet this "ctor (this)" w
|
|
||||||
this(${1:/*args*/})
|
|
||||||
{
|
|
||||||
${VISUAL}${2:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet get "getter property (get)"
|
|
||||||
@property ${1:/*type*/} ${2:/*member_name*/}() const pure nothrow {return ${3:$2_};}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet set "setter property (set)"
|
|
||||||
@property void ${1:/*member_name*/}(${2:/*type*/} rhs) pure nothrow {${3:$1_} = rhs;}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Functions (concrete)
|
|
||||||
|
|
||||||
snippet main "Main" b
|
|
||||||
void main(string[] args)
|
|
||||||
{
|
|
||||||
${VISUAL}${0: /*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Mixins
|
|
||||||
|
|
||||||
snippet signal "signal (signal)" b
|
|
||||||
mixin Signal!(${1:/*args*/}) ${2:/*name*/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Scope
|
|
||||||
|
|
||||||
snippet scope "scope (scope)" b
|
|
||||||
scope(${1:exit})
|
|
||||||
{
|
|
||||||
${VISUAL}${2:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# With
|
|
||||||
|
|
||||||
snippet with "with (with)"
|
|
||||||
with(${1})
|
|
||||||
{
|
|
||||||
${VISUAL}${2:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Exception handling
|
|
||||||
|
|
||||||
snippet try "try/catch (try)" b
|
|
||||||
try
|
|
||||||
{
|
|
||||||
${VISUAL}${1:/*code to try*/}
|
|
||||||
}
|
|
||||||
catch(${2}Exception e)
|
|
||||||
{
|
|
||||||
${3:/*handle exception*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tryf "try/catch/finally (tryf)" b
|
|
||||||
try
|
|
||||||
{
|
|
||||||
${VISUAL}${1:/*code to try*/}
|
|
||||||
}
|
|
||||||
catch(${2}Exception e)
|
|
||||||
{
|
|
||||||
${3:/*handle exception*/}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
${4:/*cleanup*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet catch "catch (catch)" b
|
|
||||||
catch(${1}Exception e)
|
|
||||||
{
|
|
||||||
${2:/*handle exception*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet thr "throw (thr)"
|
|
||||||
throw new ${1}Exception("${2}");
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# Type declarations
|
|
||||||
|
|
||||||
snippet struct "struct (struct)"
|
|
||||||
struct ${1:`!p snip.rv = (snip.basename or "name")`}
|
|
||||||
{
|
|
||||||
${2}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet union "union (union)"
|
|
||||||
union ${1:`!p snip.rv = (snip.basename or "name")`}
|
|
||||||
{
|
|
||||||
${2}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet class "class (class)"
|
|
||||||
class ${1:`!p snip.rv = (snip.basename or "name")`}
|
|
||||||
{
|
|
||||||
${2}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet inter "interface (inter)"
|
|
||||||
interface ${1:`!p snip.rv = (snip.basename or "name")`}
|
|
||||||
{
|
|
||||||
${2}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet enum "enum (enum)"
|
|
||||||
enum ${1:`!p snip.rv = (snip.basename or "name")`}
|
|
||||||
{
|
|
||||||
${2}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# Exception declarations
|
|
||||||
|
|
||||||
snippet exc "exception declaration (exc)" b
|
|
||||||
/// ${3:/*documentation*/}
|
|
||||||
class ${1}Exception : ${2}Exception
|
|
||||||
{
|
|
||||||
public this(string msg, string file = __FILE__, int line = __LINE__)
|
|
||||||
{
|
|
||||||
super(msg, file, line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# Conditional compilation
|
|
||||||
|
|
||||||
snippet version "version (version)" b
|
|
||||||
version(${1:/*version name*/})
|
|
||||||
{
|
|
||||||
${VISUAL}${2:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet debug "debug" b
|
|
||||||
debug
|
|
||||||
{
|
|
||||||
${VISUAL}${1:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# Templates
|
|
||||||
|
|
||||||
snippet temp "template (temp)" b
|
|
||||||
template ${2:/*name*/}(${1:/*args*/})
|
|
||||||
{
|
|
||||||
${3:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# Asserts
|
|
||||||
|
|
||||||
snippet ass "assert (ass)" b
|
|
||||||
assert(${1:false}, "${2:TODO}");
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# Unittests
|
|
||||||
|
|
||||||
snippet unittest "unittest (unittest)" b
|
|
||||||
unittest
|
|
||||||
{
|
|
||||||
${1:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# Common member functions
|
|
||||||
|
|
||||||
snippet opDis "opDispatch (opDis)" b
|
|
||||||
${1:/*return type*/} opDispatch(string s)()
|
|
||||||
{
|
|
||||||
${2:/*code*/};
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet op= "opAssign (op=)" b
|
|
||||||
void opAssign(${1} rhs) ${2:@safe pure nothrow}
|
|
||||||
{
|
|
||||||
${2:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet opCmp "opCmp (opCmp)" b
|
|
||||||
int opCmp(${1} rhs) @safe const pure nothrow
|
|
||||||
{
|
|
||||||
${2:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet opApply "opApply (opApply)" b
|
|
||||||
int opApply(int delegate(ref ${1:/*iterated type/s*/}) dg)
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
${2:/*loop*/}
|
|
||||||
{
|
|
||||||
result = dg(${3:/*arg/s*/});
|
|
||||||
if(result){break;}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet toString "toString (toString)" b
|
|
||||||
string toString() @safe const pure nothrow
|
|
||||||
{
|
|
||||||
${1:/*code*/}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# Comments
|
|
||||||
|
|
||||||
|
|
||||||
snippet todo "TODO (todo)"
|
|
||||||
// TODO: ${1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# DDoc
|
|
||||||
|
|
||||||
snippet doc "generic ddoc block (doc)" b
|
|
||||||
/// ${1:description}
|
|
||||||
///
|
|
||||||
/// ${2:details}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fdoc "function ddoc block (fdoc)" b
|
|
||||||
/// ${1:description}
|
|
||||||
///
|
|
||||||
/// ${2:Params: ${3:param} = ${4:param description}
|
|
||||||
/// ${5}}
|
|
||||||
///
|
|
||||||
/// ${6:Returns: ${7:return value}}
|
|
||||||
///
|
|
||||||
/// ${8:Throws: ${9}Exception ${10}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Par "Params (Par)"
|
|
||||||
Params: ${1:param} = ${2:param description}
|
|
||||||
/// ${3}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Ret "Returns (Ret)"
|
|
||||||
Returns: ${1:return value/s}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Thr "Throws (Thr)"
|
|
||||||
Throws: ${1}Exception ${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Example "Examples (Example)"
|
|
||||||
Examples:
|
|
||||||
/// --------------------
|
|
||||||
/// ${1:example code}
|
|
||||||
/// --------------------
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# License blocks
|
|
||||||
|
|
||||||
snippet gpl "GPL (gpl)" b
|
|
||||||
// This program is free software; you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation; either version 2 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
//
|
|
||||||
// Copyright (C) ${1:Author}, `!v strftime("%Y")`
|
|
||||||
|
|
||||||
${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet boost "Boost (boost)" b
|
|
||||||
// Copyright ${1:Author} `!v strftime("%Y")`.
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# New module
|
|
||||||
|
|
||||||
snippet module "New module (module)" b
|
|
||||||
// Copyright ${1:Author} `!v strftime("%Y")`.
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
module ${2}.`!v Filename('$1', 'name')`;
|
|
||||||
|
|
||||||
|
|
||||||
${3}
|
|
||||||
endsnippet
|
|
@ -1,238 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
# Generic Tags
|
|
||||||
snippet %
|
|
||||||
{% ${1} %}${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet %%
|
|
||||||
{% ${1:tag_name} %}
|
|
||||||
${2}
|
|
||||||
{% end$1 %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet {
|
|
||||||
{{ ${1} }}${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Template Tags
|
|
||||||
|
|
||||||
snippet autoescape
|
|
||||||
{% autoescape ${1:off} %}
|
|
||||||
${2}
|
|
||||||
{% endautoescape %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet block
|
|
||||||
{% block ${1} %}
|
|
||||||
${2}
|
|
||||||
{% endblock $1 %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet #
|
|
||||||
{# ${1:comment} #}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet comment
|
|
||||||
{% comment %}
|
|
||||||
${1}
|
|
||||||
{% endcomment %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cycle
|
|
||||||
{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet debug
|
|
||||||
{% debug %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet extends
|
|
||||||
{% extends "${1:base.html}" %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet filter
|
|
||||||
{% filter ${1} %}
|
|
||||||
${2}
|
|
||||||
{% endfilter %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet firstof
|
|
||||||
{% firstof ${1} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for
|
|
||||||
{% for ${1} in ${2} %}
|
|
||||||
${3}
|
|
||||||
{% endfor %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet empty
|
|
||||||
{% empty %}
|
|
||||||
${1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if
|
|
||||||
{% if ${1} %}
|
|
||||||
${2}
|
|
||||||
{% endif %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet else
|
|
||||||
{% else %}
|
|
||||||
${1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifchanged
|
|
||||||
{% ifchanged %}${1}{% endifchanged %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifequal
|
|
||||||
{% ifequal ${1} ${2} %}
|
|
||||||
${3}
|
|
||||||
{% endifequal %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifnotequal
|
|
||||||
{% ifnotequal ${1} ${2} %}
|
|
||||||
${3}
|
|
||||||
{% endifnotequal %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet include
|
|
||||||
{% include "${1}" %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet load
|
|
||||||
{% load ${1} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet now
|
|
||||||
{% now "${1:jS F Y H:i}" %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet regroup
|
|
||||||
{% regroup ${1} by ${2} as ${3} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet spaceless
|
|
||||||
{% spaceless %}${1}{% endspaceless %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ssi
|
|
||||||
{% ssi ${1} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet trans
|
|
||||||
{% trans "${1:string}" %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet url
|
|
||||||
{% url ${1} as ${2} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet widthratio
|
|
||||||
{% widthratio ${1:this_value} ${2:max_value} ${3:100} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet with
|
|
||||||
{% with ${1} as ${2} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Template Filters
|
|
||||||
|
|
||||||
# Note: Since SnipMate can't determine which template filter you are
|
|
||||||
# expanding without the "|" character, these do not add the "|"
|
|
||||||
# character. These save a few keystrokes still.
|
|
||||||
|
|
||||||
# Note: Template tags that take no arguments are not implemented.
|
|
||||||
|
|
||||||
snippet add
|
|
||||||
add:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet center
|
|
||||||
center:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cut
|
|
||||||
cut:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet date
|
|
||||||
date:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet default
|
|
||||||
default:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet defaultifnone
|
|
||||||
default_if_none:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet dictsort
|
|
||||||
dictsort:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet dictsortrev
|
|
||||||
dictsortreversed:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet divisibleby
|
|
||||||
divisibleby:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet floatformat
|
|
||||||
floatformat:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet getdigit
|
|
||||||
get_digit:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet join
|
|
||||||
join:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lengthis
|
|
||||||
length_is:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pluralize
|
|
||||||
pluralize:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet removetags
|
|
||||||
removetags:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet slice
|
|
||||||
slice:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet stringformat
|
|
||||||
stringformat:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet time
|
|
||||||
time:"${1}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet truncatewords
|
|
||||||
truncatewords:${1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet truncatewordshtml
|
|
||||||
truncatewords_html:${1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet urlizetrunc
|
|
||||||
urlizetrunc:${1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wordwrap
|
|
||||||
wordwrap:${1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,100 +0,0 @@
|
|||||||
###########################################################################
|
|
||||||
# TEXTMATE SNIPPETS #
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
snippet pat "Case:Receive:Try Clause"
|
|
||||||
${1:pattern}${2: when ${3:guard}} ->;
|
|
||||||
${4:body}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet beh "Behaviour Directive"
|
|
||||||
-behaviour (${1:behaviour}).
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet case "Case Expression"
|
|
||||||
case ${1:expression} of
|
|
||||||
${2:pattern}${3: when ${4:guard}} ->
|
|
||||||
${5:body}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet def "Define Directive"
|
|
||||||
-define (${1:macro}${2: (${3:param})}, ${4:body}).
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet exp "Export Directive"
|
|
||||||
-export ([${1:function}/${2:arity}]).
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fun "Fun Expression"
|
|
||||||
fun
|
|
||||||
(${1:pattern})${2: when ${3:guard}} ->
|
|
||||||
${4:body}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fu "Function"
|
|
||||||
${1:function} (${2:param})${3: when ${4:guard}} ->
|
|
||||||
${5:body}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "If Expression"
|
|
||||||
if
|
|
||||||
${1:guard} ->
|
|
||||||
${2:body}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifdef "Ifdef Directive"
|
|
||||||
-ifdef (${1:macro}).
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifndef "Ifndef Directive"
|
|
||||||
-ifndef (${1:macro}).
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet imp "Import Directive"
|
|
||||||
-import (${1:module}, [${2:function}/${3:arity}]).
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet inc "Include Directive"
|
|
||||||
-include ("${1:file}").
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mod "Module Directive"
|
|
||||||
-module (${1:`!p snip.rv = snip.basename or "module"`}).
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rcv "Receive Expression"
|
|
||||||
receive
|
|
||||||
${1: ${2:pattern}${3: when ${4:guard}} ->
|
|
||||||
${5:body}}
|
|
||||||
${6:after
|
|
||||||
${7:expression} ->
|
|
||||||
${8:body}}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rec "Record Directive"
|
|
||||||
-record (${1:record}, {${2:field}${3: = ${4:value}}}).
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet try "Try Expression"
|
|
||||||
try${1: ${2:expression}${3: of
|
|
||||||
${4:pattern}${5: when ${6:guard}} ->
|
|
||||||
${7:body}}}
|
|
||||||
${8:catch
|
|
||||||
${9:pattern}${10: when ${11:guard}} ->
|
|
||||||
${12:body}}
|
|
||||||
${13:after
|
|
||||||
${14:body}}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet undef "Undef Directive"
|
|
||||||
-undef (${1:macro}).
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,280 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
# TextMate added these variables to cope with changes in ERB handling
|
|
||||||
# in different versions of Rails -- for instance, Rails 3 automatically
|
|
||||||
# strips whitespace so that it's no longer necessary to use a form like
|
|
||||||
# <% end -%>, but if you're still maintaining Rails 2 projects, you
|
|
||||||
# can't omit the minus sign and get the same behavior.
|
|
||||||
#
|
|
||||||
# The following regex replace substitutes the function below for the
|
|
||||||
# TextMate variable references after the snippets are converted:
|
|
||||||
#
|
|
||||||
# /\v\$\{(TM_RAILS_TEMPLATE_([^_]+)_RUBY_([^_\s]+))\}/`!p textmate_var('\1', snip)`/g
|
|
||||||
#
|
|
||||||
global !p
|
|
||||||
def textmate_var(var, snip):
|
|
||||||
lookup = dict(
|
|
||||||
TM_RAILS_TEMPLATE_START_RUBY_EXPR = snip.opt('g:tm_rails_template_start_ruby_expr', '<%= '),
|
|
||||||
TM_RAILS_TEMPLATE_END_RUBY_EXPR = snip.opt('g:tm_rails_template_end_ruby_expr', ' %>'),
|
|
||||||
TM_RAILS_TEMPLATE_START_RUBY_INLINE = snip.opt('g:tm_rails_template_start_ruby_inline', '<% '),
|
|
||||||
TM_RAILS_TEMPLATE_END_RUBY_INLINE = snip.opt('g:tm_rails_template_end_ruby_inline', ' %>'),
|
|
||||||
TM_RAILS_TEMPLATE_END_RUBY_BLOCK = '<% end %>'
|
|
||||||
)
|
|
||||||
snip.rv = lookup[var]
|
|
||||||
return
|
|
||||||
endglobal
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# GENERATED FROM get_tm_snippets.py + REGEX REPLACE #
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
snippet fi "<%= Fixtures.identify(:symbol) %>"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`Fixtures.identify(:${1:name})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ft "form_tag"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => "${5:update}"}${6:, {:${8:class} => "${9:form}"\}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
$0
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet end "end (ERB)"
|
|
||||||
<% end -%>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for loop (ERB)"
|
|
||||||
<% if !${1:list}.blank? %>
|
|
||||||
<% for ${2:item} in ${1} %>
|
|
||||||
$3
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
$4
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ffcb "form_for check_box"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.check_box :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ffff "form_for file_field 2"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.file_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ffhf "form_for hidden_field 2"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.hidden_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ffl "form_for label 2"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.label :${1:attribute}${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ffpf "form_for password_field 2"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.password_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ffrb "form_for radio_box 2"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_box :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ffs "form_for submit 2"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ffta "form_for text_area 2"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_area :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fftf "form_for text_field 2"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fields "fields_for"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`fields_for :${1:model}, @${2:$1} do |$1|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)`
|
|
||||||
$0
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f_fields_for (nff)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`f.fields_for :${1:attribute} do |${2:f}|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)`
|
|
||||||
$0
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f.checkbox"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.check_box :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f.file_field"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.file_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f.hidden_field"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.hidden_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f.label"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.label :${1:attribute}${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f.password_field"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.password_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f.radio_box"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_box :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f.submit"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f.text_area"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_area :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f. "f.text_field"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ffe "form_for with errors"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`error_messages_for :${1:model}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${2:$1} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
$0
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ff "form_for"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${1:model} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
$0
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ist "image_submit_tag"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_submit_tag("${1:agree.png}"${2:${3:, :id => "${4:${1/^(\w+)(\.\w*)?$/$1/}}"}${5:, :name => "${6:${1/^(\w+)(\.\w*)?$/$1/}}"}${7:, :class => "${8:${1/^(\w+)(\.\w*)?$/$1/}-button}"}${9:, :disabled => ${10:false}}})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet it "image_tag"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_tag "$1${2:.png}"${3:${4:, :title => "${5:title}"}${6:, :class => "${7:class}"}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet layout "layout"
|
|
||||||
layout "${1:template_name}"${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet jit "javascript_include_tag"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`javascript_include_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lia "link_to (action)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet liai "link_to (action, id)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:edit}", :id => ${3:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lic "link_to (controller)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lica "link_to (controller, action)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet licai "link_to (controller, action, id)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:edit}", :id => ${4:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet linpp "link_to (nested path plural)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${10:parent}_${11:child}_path(${12:@}${13:${10}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet linp "link_to (nested path)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lipp "link_to (path plural)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${4:model}s_path}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lip "link_to (path)"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:model}_path(${13:@}${14:${12}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lim "link_to model"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:model}.${2:name}, ${3:${4:$1}_path(${14:$1})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hide "page.hide (*ids)"
|
|
||||||
page.hide ${1:"${2:id(s)}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ins "page.insert_html (position, id, partial)"
|
|
||||||
page.insert_html :${1:top}, ${2:"${3:id}"}, :${4:partial => "${5:template}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rep "page.replace (id, partial)"
|
|
||||||
page.replace ${1:"${2:id}"}, :${3:partial => "${4:template}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet reph "page.replace_html (id, partial)"
|
|
||||||
page.replace_html ${1:"${2:id}"}, :${3:partial => "${4:template}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet show "page.show (*ids)"
|
|
||||||
page.show ${1:"${2:id(s)}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tog "page.toggle (*ids)"
|
|
||||||
page.toggle ${1:"${2:id(s)}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vis "page.visual_effect (effect, id)"
|
|
||||||
page.visual_effect :${1:toggle_slide}, ${2:"${3:DOM ID}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rp "render (partial) (rp)"
|
|
||||||
render :partial => "${1:item}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rpc "render (partial,collection) (rpc)"
|
|
||||||
render :partial => "${1:item}", :collection => ${2:@$1s}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rpl "render (partial,locals) (rpl)"
|
|
||||||
render :partial => "${1:item}", :locals => { :${2:$1} => ${3:@$1}$0 }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rpo "render (partial,object) (rpo)"
|
|
||||||
render :partial => "${1:item}", :object => ${2:@$1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rps "render (partial,status) (rps)"
|
|
||||||
render :partial => "${1:item}", :status => ${2:500}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet slt "stylesheet_link_tag"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`stylesheet_link_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
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)"
|
|
||||||
<% else %>
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if (ERB)"
|
|
||||||
<% if ${1:condition} %>$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lf "link_to_function"
|
|
||||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to_function ${1:"${2:Greeting}"}, "${3:alert('Hello world!')}"$4`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,131 +0,0 @@
|
|||||||
# Snippets for Go
|
|
||||||
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
# when to abbriviate and when not?
|
|
||||||
# b doesn't work here, because it ignores whitespace
|
|
||||||
# optional local name?
|
|
||||||
snippet /^import/ "Import declaration" r
|
|
||||||
import (
|
|
||||||
"${1:package}"
|
|
||||||
)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /^package/ "Package declaration" r
|
|
||||||
// Package $1 provides ...
|
|
||||||
package ${1:main}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Mostly converted from: https://github.com/AlanQuatermain/go-tmbundle
|
|
||||||
snippet /^cons/ "Constants declaration" r
|
|
||||||
const (
|
|
||||||
${1:constant}${2/(.+)/ /}${2:type} = ${0:value}
|
|
||||||
)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /^con/ "Constant declaration" r
|
|
||||||
const ${1:name}${2/(.+)/ /}${2:type} = ${0:value}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet iota "Iota constant generator" b
|
|
||||||
const (
|
|
||||||
${1:constant}${2/(.+)/ /}${2:type} = iota
|
|
||||||
)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet struct "Struct declaration" b
|
|
||||||
type ${1:Struct} struct {
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet interface "Interface declaration" b
|
|
||||||
type ${1:Interface} interface {
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# statements
|
|
||||||
snippet for "For loop" b
|
|
||||||
for ${1:condition}${1/(.+)/ /}{
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet forr "For range loop" b
|
|
||||||
for ${2:name} := range ${1:collection} {
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "If statement" b
|
|
||||||
if ${1:condition}${1/(.+)/ /}{
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet switch "Switch statement" b
|
|
||||||
switch ${1:expression}${1/(.+)/ /}{
|
|
||||||
case${0}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet select "Select statement" b
|
|
||||||
select {
|
|
||||||
case${0}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet case "Case clause" b
|
|
||||||
case ${1:condition}:
|
|
||||||
${0:${VISUAL}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet default "Default clause" b
|
|
||||||
default:
|
|
||||||
${0:${VISUAL}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# functions
|
|
||||||
snippet /^main/ "Main function" r
|
|
||||||
func main() {
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /^meth/ "Method" r
|
|
||||||
func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} {
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet func "Function" b
|
|
||||||
func ${1:name}(${2:params})${3/(.+)/ /}${3:type} {
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# types and variables
|
|
||||||
snippet map "Map type" b
|
|
||||||
map[${1:keytype}]${2:valtype}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet : "Variable declaration :=" b
|
|
||||||
${1:name} := ${0:value}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet var "Variable declaration" b
|
|
||||||
var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vars "Variables declaration" b
|
|
||||||
var (
|
|
||||||
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
|
|
||||||
)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet json "JSON field"
|
|
||||||
\`json:"${1:displayName}"\`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,63 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
snippet if "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}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet :: "Type signature"
|
|
||||||
${1:name} :: ${2:Type} -> ${3:Type}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet => "Type constraint"
|
|
||||||
(${1:Class} ${2:Type var}) => ${3:$2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet def "Function definition"
|
|
||||||
${1:name} :: ${2:Type} -> ${3:Type}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet def[] "Function definition for list patterns"
|
|
||||||
${1:name} :: [${2:Type}] -> ${3:Type}
|
|
||||||
$1 [] = ${4:undefined}
|
|
||||||
$1 ${5:(x:xs)} = ${6:undefined}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet = "Function clause"
|
|
||||||
${1:name} ${2:pattern} = ${3:undefined}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet 2= "Function clause"
|
|
||||||
${1:name} ${2:pattern} = ${3:undefined}
|
|
||||||
$1 ${4:pattern} = ${5:undefined}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet 3= "Function clause"
|
|
||||||
${1:name} ${2:pattern} = ${3:undefined}
|
|
||||||
$1 ${4:pattern} = ${5:undefined}
|
|
||||||
$1 ${6:pattern} = ${7:undefined}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet | "Guard"
|
|
||||||
| ${1:predicate} = ${2:undefined}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet \ "Lambda expression"
|
|
||||||
\ ${1:pattern} -> ${2:expression}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet [|] "List comprehension"
|
|
||||||
[${3:foo }$1 | ${1:x} <- ${2:xs} ]
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet let "let ... in ..."
|
|
||||||
let ${1:name} = ${2:expression}
|
|
||||||
in ${3:expression}
|
|
||||||
endsnippet
|
|
@ -1,32 +0,0 @@
|
|||||||
# Snippets for VIM Help Files
|
|
||||||
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
global !p
|
|
||||||
def sec_title(snip, t):
|
|
||||||
file_start = snip.fn.split('.')[0]
|
|
||||||
sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-')
|
|
||||||
return ("*%s-%s*" % (file_start, sec_name)).rjust(78-len(t[1]))
|
|
||||||
endglobal
|
|
||||||
|
|
||||||
snippet sec "Section marker" b
|
|
||||||
==============================================================================
|
|
||||||
${1:SECTION}`!p snip.rv = sec_title(snip, t)`
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ssec "Sub section marker" b
|
|
||||||
${1:Subsection}`!p snip.rv = sec_title(snip, t)
|
|
||||||
snip += "-"*len(t[1])`
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sssec "Subsub Section marker" b
|
|
||||||
${1:SubSubsection}:`!p snip.rv = sec_title(snip, t)`
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,302 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# TextMate Snippets #
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
global !p
|
|
||||||
def x(snip):
|
|
||||||
if snip.ft.startswith("x"):
|
|
||||||
snip.rv = '/'
|
|
||||||
else:
|
|
||||||
snip.rv = ""
|
|
||||||
endglobal
|
|
||||||
|
|
||||||
############
|
|
||||||
# Doctypes #
|
|
||||||
############
|
|
||||||
snippet doctype "DocType XHTML 1.0 Strict" b
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet doctype "DocType XHTML 1.0 Transitional" b
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet doctype "DocType XHTML 1.1" b
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet doctype "HTML - 4.0 Transitional (doctype)" b
|
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet doctype "HTML - 5.0 (doctype)" b
|
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
#############
|
|
||||||
# Shortcuts #
|
|
||||||
#############
|
|
||||||
snippet down "Down (down)"
|
|
||||||
↓
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet enter "Enter (enter)"
|
|
||||||
⌅
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet escape "Escape (escape)"
|
|
||||||
⎋
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet shift "Shift (shift)"
|
|
||||||
⇧
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tab "Tab (tab)"
|
|
||||||
⇥
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet up "Up (up)"
|
|
||||||
↑
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet return "Return (return)"
|
|
||||||
↩
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet right "Right (right)"
|
|
||||||
→
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet left "Left (left)"
|
|
||||||
←
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet option "Option (option)"
|
|
||||||
⌥
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Conditional inserts #
|
|
||||||
#######################
|
|
||||||
snippet ! "IE Conditional Comment: Internet Explorer 5_0 only"
|
|
||||||
<!--[if IE 5.0]>${1:IE Conditional Comment: Internet Explorer 5.0 only }<![endif]-->$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ! "IE Conditional Comment: Internet Explorer 5_5 only"
|
|
||||||
<!--[if IE 5.5000]>${1:IE Conditional Comment: Internet Explorer 5.5 only }<![endif]-->$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ! "IE Conditional Comment: Internet Explorer 5_x"
|
|
||||||
<!--[if lt IE 6]>${1:IE Conditional Comment: Internet Explorer 5.x }<![endif]-->$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ! "IE Conditional Comment: Internet Explorer 6 and below"
|
|
||||||
<!--[if lte IE 6]>${1:IE Conditional Comment: Internet Explorer 6 and below }<![endif]-->$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ! "IE Conditional Comment: Internet Explorer 6 only"
|
|
||||||
<!--[if IE 6]>${1:IE Conditional Comment: Internet Explorer 6 only }<![endif]-->$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ! "IE Conditional Comment: Internet Explorer 7+"
|
|
||||||
<!--[if gte IE 7]>${1:IE Conditional Comment: Internet Explorer 7 and above }<![endif]-->$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ! "IE Conditional Comment: Internet Explorer"
|
|
||||||
<!--[if IE]>${1: IE Conditional Comment: Internet Explorer }<![endif]-->$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ! "IE Conditional Comment: NOT Internet Explorer"
|
|
||||||
<!--[if !IE]><!-->${1: IE Conditional Comment: NOT Internet Explorer }<!-- <![endif]-->$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
#############
|
|
||||||
# HTML TAGS #
|
|
||||||
#############
|
|
||||||
snippet input "Input with Label" w
|
|
||||||
<label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}`!p x(snip)`>
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet input "XHTML <input>" w
|
|
||||||
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}`!p x(snip)`>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet opt "Option" w
|
|
||||||
<option${1: value="${2:option}"}>${3:$2}</option>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet select "Select Box" w
|
|
||||||
<select name="${1:some_name}" id="${2:$1}"${3:${4: multiple}${5: onchange="${6:}"}${7: size="${8:1}"}}>
|
|
||||||
<option${9: value="${10:option1}"}>${11:$10}</option>
|
|
||||||
<option${12: value="${13:option2}"}>${14:$13}</option>${15:}
|
|
||||||
$0
|
|
||||||
</select>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet textarea "XHTML <textarea>" w
|
|
||||||
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mailto "XHTML <a mailto: >" w
|
|
||||||
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet base "XHTML <base>" w
|
|
||||||
<base href="$1"${2: target="$3"}`!p x(snip)`>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet img "XHTML <img>" w
|
|
||||||
<img src="${1:imgsrc}">
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet body "XHTML <body>"
|
|
||||||
<body id="${1:`!p
|
|
||||||
snip.rv = snip.fn and 'Hallo' or 'Nothin'
|
|
||||||
`}"${2: onload="$3"}>
|
|
||||||
$0
|
|
||||||
</body>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet div "XHTML <div>" w
|
|
||||||
<div`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""``!p snip.rv=' class="' if t[2] else ""`${2:name}`!p snip.rv = '"' if t[2] else ""`>
|
|
||||||
$0
|
|
||||||
</div>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet form "XHTML <form>" w
|
|
||||||
<form action="${1:`!p
|
|
||||||
snip.rv = (snip.basename or 'unnamed') + '_submit'
|
|
||||||
`}" method="${2:get}" accept-charset="utf-8">
|
|
||||||
$0
|
|
||||||
|
|
||||||
<p><input type="submit" value="Continue →"`!p x(snip)`></p>
|
|
||||||
</form>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet h1 "XHTML <h1>" w
|
|
||||||
<h1 id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}">${1}</h1>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet head "XHTML <head>"
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"`!p x(snip)`>
|
|
||||||
<title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title>
|
|
||||||
$0
|
|
||||||
</head>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet link "XHTML <link>" w
|
|
||||||
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"`!p x(snip)`>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet meta "XHTML <meta>" w
|
|
||||||
<meta name="${1:name}" content="${2:content}"`!p x(snip)`>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet scriptsrc "XHTML <script src...>" w
|
|
||||||
<script src="$1" type="text/javascript" charset="${3:utf-8}"></script>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet script "XHTML <script>" w
|
|
||||||
<script type="text/javascript" charset="utf-8">
|
|
||||||
$0
|
|
||||||
</script>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet style "XHTML <style>" w
|
|
||||||
<style type="text/css" media="screen">
|
|
||||||
$0
|
|
||||||
</style>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet table "XHTML <table>" w
|
|
||||||
<table border="${1:0}"${2: cellspacing="${3:5}" cellpadding="${4:5}"}>
|
|
||||||
<tr><th>${5:Header}</th></tr>
|
|
||||||
<tr><td>${0:Data}</td></tr>
|
|
||||||
</table>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet a "Link" w
|
|
||||||
<a href="${1:http://www.${2:url.com}}"${3: target="_blank"}>${4:Anchor Text}</a>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet p "paragraph" w
|
|
||||||
<p>$0</p>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet li "list item" w
|
|
||||||
<li>$0</li>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ul "unordered list" w
|
|
||||||
<ul>
|
|
||||||
$0
|
|
||||||
</ul>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet td "table cell" w
|
|
||||||
<td>$0</td>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tr "table row" w
|
|
||||||
<tr>$0</tr>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet title "XHTML <title>" w
|
|
||||||
<title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fieldset "Fieldset" w
|
|
||||||
<fieldset id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}" ${2:class="${3:}"}>
|
|
||||||
<legend>$1</legend>
|
|
||||||
$0
|
|
||||||
</fieldset>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet movie "Embed QT movie (movie)" b
|
|
||||||
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
|
|
||||||
<param name="src" value="$1"`!p x(snip)`>
|
|
||||||
<param name="controller" value="$4"`!p x(snip)`>
|
|
||||||
<param name="autoplay" value="$5"`!p x(snip)`>
|
|
||||||
<embed src="${1:movie.mov}"
|
|
||||||
width="${2:320}" height="${3:240}"
|
|
||||||
controller="${4:true}" autoplay="${5:true}"
|
|
||||||
scale="tofit" cache="true"
|
|
||||||
pluginspage="http://www.apple.com/quicktime/download/"
|
|
||||||
`!p x(snip)`>
|
|
||||||
</object>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet html5 "HTML5 Template"
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>${1}</title>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
${2}
|
|
||||||
</header>
|
|
||||||
<footer>
|
|
||||||
${4}
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
endsnippet
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,3 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
extends html, django
|
|
@ -1,3 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
extends html, jinja2
|
|
@ -1,431 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
# Many of the snippets here use a global option called
|
|
||||||
# "g:ultisnips_java_brace_style" which, if set to "nl" will put a newline
|
|
||||||
# before '{' braces.
|
|
||||||
# Setting "g:ultisnips_java_junit" will change how the test method snippet
|
|
||||||
# looks, it is defaulted to junit4, setting this option to 3 will remove the
|
|
||||||
# @Test annotation from the method
|
|
||||||
|
|
||||||
global !p
|
|
||||||
def junit(snip):
|
|
||||||
if snip.opt("g:ultisnips_java_junit", "") == "3":
|
|
||||||
snip += ""
|
|
||||||
else:
|
|
||||||
snip.rv += "@Test\n\t"
|
|
||||||
|
|
||||||
def nl(snip):
|
|
||||||
if snip.opt("g:ultisnips_java_brace_style", "") == "nl":
|
|
||||||
snip += ""
|
|
||||||
else:
|
|
||||||
snip.rv += " "
|
|
||||||
def getArgs(group):
|
|
||||||
import re
|
|
||||||
word = re.compile('[a-zA-Z><.]+ \w+')
|
|
||||||
return [i.split(" ") for i in word.findall(group) ]
|
|
||||||
|
|
||||||
def camel(word):
|
|
||||||
return word[0].upper() + word[1:]
|
|
||||||
|
|
||||||
endglobal
|
|
||||||
|
|
||||||
snippet sleep "try sleep catch" b
|
|
||||||
try {
|
|
||||||
Thread.sleep(${1:1000});
|
|
||||||
} catch (InterruptedException e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /i|n/ "new primitive or int" br
|
|
||||||
${1:int} ${2:i} = ${3:1};
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /o|v/ "new Object or variable" br
|
|
||||||
${1:Object} ${2:var} = new $1(${3});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f "field" b
|
|
||||||
${1:private} ${2:String} ${3:`!p snip.rv = t[2].lower()`};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ab "abstract" b
|
|
||||||
abstract $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet as "assert" b
|
|
||||||
assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet at "assert true" b
|
|
||||||
assertTrue(${1:actual});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet af "assert false" b
|
|
||||||
assertFalse(${1:actual});$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ae "assert equals" b
|
|
||||||
assertEquals(${1:expected}, ${2:actual});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet br "break"
|
|
||||||
break;
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cs "case" b
|
|
||||||
case $1:
|
|
||||||
$2
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ca "catch" b
|
|
||||||
catch (${1:Exception} ${2:e})`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cle "class extends" b
|
|
||||||
public class ${1:`!p
|
|
||||||
snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements ${5:Interface} }{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet clc "class with constructor, fields, setter and getters" b
|
|
||||||
public class `!p
|
|
||||||
snip.rv = snip.basename or "untitled"` {
|
|
||||||
`!p
|
|
||||||
args = getArgs(t[1])
|
|
||||||
if len(args) == 0: snip.rv = ""
|
|
||||||
for i in args:
|
|
||||||
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
|
|
||||||
if len(args) > 0:
|
|
||||||
snip.rv += "\n"`
|
|
||||||
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
|
|
||||||
args = getArgs(t[1])
|
|
||||||
for i in args:
|
|
||||||
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] + ";"
|
|
||||||
if len(args) == 0:
|
|
||||||
snip.rv += "\n"`
|
|
||||||
}$0
|
|
||||||
`!p
|
|
||||||
args = getArgs(t[1])
|
|
||||||
if len(args) == 0: snip.rv = ""
|
|
||||||
for i in args:
|
|
||||||
snip.rv += "\n\tpublic void set" + camel(i[1]) + "(" + i[0] + " " + i[1] + ") {\n" + "\
|
|
||||||
\tthis." + i[1] + " = " + i[1] + ";\n\t}\n"
|
|
||||||
|
|
||||||
snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\
|
|
||||||
\n\t\treturn " + i[1] + ";\n\t}\n"
|
|
||||||
`
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet clc "class with constructor, with field names" b
|
|
||||||
public class `!p
|
|
||||||
snip.rv = snip.basename or "untitled"` {
|
|
||||||
`!p
|
|
||||||
args = getArgs(t[1])
|
|
||||||
for i in args:
|
|
||||||
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
|
|
||||||
if len(args) > 0:
|
|
||||||
snip.rv += "\n"`
|
|
||||||
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
|
|
||||||
args = getArgs(t[1])
|
|
||||||
for i in args:
|
|
||||||
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
|
|
||||||
if len(args) == 0:
|
|
||||||
snip.rv += "\n"`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet clc "class and constructor" b
|
|
||||||
public class `!p
|
|
||||||
snip.rv = snip.basename or "untitled"` {
|
|
||||||
|
|
||||||
public `!p snip.rv = snip.basename or "untitled"`($2) {
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cl "class" b
|
|
||||||
public class ${1:`!p
|
|
||||||
snip.rv = snip.basename or "untitled"`} {
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cos "constant string" b
|
|
||||||
public static final String ${1:var} = "$2";$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet co "constant" b
|
|
||||||
public static final ${1:String} ${2:var} = $3;$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet de "default" b
|
|
||||||
default:
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet elif "else if" b
|
|
||||||
else if ($1)`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /el(se)?/ "else" br
|
|
||||||
else`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fi "final" b
|
|
||||||
final $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fore "for (each)" b
|
|
||||||
for ($1 : $2)`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fori "for" b
|
|
||||||
for (int ${1:i} = 0; $1 < ${2:10}; $1++)`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for" b
|
|
||||||
for ($1; $2; $3)`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if" b
|
|
||||||
if ($1)`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet imt "import junit_framework_TestCase;" b
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet im "import" b
|
|
||||||
import ${1:java}.${2:util}.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet in "interface" b
|
|
||||||
interface ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cc "constructor call or setter body"
|
|
||||||
this.${1:var} = $1;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet list "Collections List" b
|
|
||||||
List<${1:String}> ${2:list} = new ${3:Array}List<$1>();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet map "Collections Map" b
|
|
||||||
Map<${1:String}, ${2:String}> ${3:map} = new ${4:Hash}Map<$1, $2>();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet set "Collections Set" b
|
|
||||||
Set<${1:String}> ${2:set} = new ${3:Hash}Set<$1>();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /Str?|str/ "String" br
|
|
||||||
String $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cn "Constructor" b
|
|
||||||
public `!p snip.rv = snip.basename or "untitled"`(${1:}) {
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cn "constructor, \w fields + assigments" b
|
|
||||||
`!p
|
|
||||||
args = getArgs(t[1])
|
|
||||||
for i in args:
|
|
||||||
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
|
|
||||||
if len(args) > 0:
|
|
||||||
snip.rv += "\n"`
|
|
||||||
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
|
|
||||||
args = getArgs(t[1])
|
|
||||||
for i in args:
|
|
||||||
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
|
|
||||||
if len(args) == 0:
|
|
||||||
snip.rv += "\n"`
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet j.b "java_beans_" i
|
|
||||||
java.beans.
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet j.i "java_io" i
|
|
||||||
java.io.
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet j.m "java_math" i
|
|
||||||
java.math.
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet j.n "java_net_" i
|
|
||||||
java.net.
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet j.u "java_util_" i
|
|
||||||
java.util.
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet main "method (main)" b
|
|
||||||
public static void main(String[] args)`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet try "try/catch" b
|
|
||||||
try {
|
|
||||||
$1
|
|
||||||
} catch(${2:Exception} ${3:e}){
|
|
||||||
${4:e.printStackTrace();}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mt "method throws" b
|
|
||||||
${1:private} ${2:void} ${3:method}(${4}) ${5:throws $6 }{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet m "method" b
|
|
||||||
${1:private} ${2:void} ${3:method}(${4}) {
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet md "Method With javadoc" b
|
|
||||||
/**
|
|
||||||
* ${7:Short Description}`!p
|
|
||||||
for i in getArgs(t[4]):
|
|
||||||
snip.rv += "\n\t * @param " + i[1] + " usage..."`
|
|
||||||
* `!p
|
|
||||||
if "throws" in t[5]:
|
|
||||||
snip.rv = "\n\t * @throws " + t[6]
|
|
||||||
else:
|
|
||||||
snip.rv = ""` `!p
|
|
||||||
if not "void" in t[2]:
|
|
||||||
snip.rv = "\n\t * @return object"
|
|
||||||
else:
|
|
||||||
snip.rv = ""`
|
|
||||||
**/
|
|
||||||
${1:public} ${2:void} ${3:method}($4) ${5:throws $6 }{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /get(ter)?/ "getter" br
|
|
||||||
public ${1:String} get${2:Name}() {
|
|
||||||
return `!p snip.rv = t[2].lower()`;
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /set(ter)?/ "setter" br
|
|
||||||
public void set${1:Name}(${2:String} $1) {
|
|
||||||
return this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br
|
|
||||||
public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) {
|
|
||||||
this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
|
|
||||||
}
|
|
||||||
|
|
||||||
public $2 get$1() {
|
|
||||||
return `!p snip.rv = t[1].lower()`;
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pa "package" b
|
|
||||||
package $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet p "print" b
|
|
||||||
System.out.print($1);$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pl "println" b
|
|
||||||
System.out.println($1);$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pr "private" b
|
|
||||||
private $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet po "protected" b
|
|
||||||
protected $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pu "public" b
|
|
||||||
public $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet re "return" b
|
|
||||||
return $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet st "static"
|
|
||||||
static $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sw "switch" b
|
|
||||||
switch ($1)`!p nl(snip)`{
|
|
||||||
case $2: $0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sy "synchronized"
|
|
||||||
synchronized $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tc "test case"
|
|
||||||
public class ${1:`!p snip.rv = snip.basename or "untitled"`} extends ${2:TestCase}`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t "test" b
|
|
||||||
`!p junit(snip)`public void test${1:Name}() {
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tt "test throws" b
|
|
||||||
`!p junit(snip)`public void test${1:Name}() ${2:throws Exception }{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet th "throw" b
|
|
||||||
throw new $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wh "while" b
|
|
||||||
while ($1)`!p nl(snip)`{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,162 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# TextMate Snippets #
|
|
||||||
###########################################################################
|
|
||||||
snippet get "Get Elements"
|
|
||||||
getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2')
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet '':f "object method string"
|
|
||||||
'${1:${2:#thing}:${3:click}}': function(element) {
|
|
||||||
${VISUAL}$0
|
|
||||||
}${10:,}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet :f "Object Method"
|
|
||||||
${1:method_name}: function(${3:attribute}) {
|
|
||||||
${VISUAL}$0
|
|
||||||
}${10:,}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet :, "Object Value JS"
|
|
||||||
${1:value_name}: ${0:value},
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet : "Object key key: 'value'"
|
|
||||||
${1:key}: ${2:"${3:value}"}${4:, }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet proto "Prototype (proto)"
|
|
||||||
${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {
|
|
||||||
${VISUAL}$0
|
|
||||||
};
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for (...) {...} (counting up)" b
|
|
||||||
for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ford "for (...) {...} (counting down, faster)" b
|
|
||||||
for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fun "function (fun)"
|
|
||||||
function ${1:function_name}(${2:argument}) {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet iife "Immediately-Invoked Function Expression (iife)"
|
|
||||||
(function (${1:argument}) {
|
|
||||||
${VISUAL}$0
|
|
||||||
}(${2:$1}));
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ife "if ___ else"
|
|
||||||
if (${1:condition}) {
|
|
||||||
${2://code}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
${3://code}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if"
|
|
||||||
if (${1:condition}) {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet timeout "setTimeout function"
|
|
||||||
setTimeout(function() {
|
|
||||||
${VISUAL}$0
|
|
||||||
}${2:.bind(${3:this})}, ${1:10});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Snippets for Console Debug Output
|
|
||||||
|
|
||||||
snippet ca "console.assert" b
|
|
||||||
console.assert(${1:assertion}, ${2:"${3:message}"});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cclear "console.clear" b
|
|
||||||
console.clear();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cdir "console.dir" b
|
|
||||||
console.dir(${1:object});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cdirx "console.dirxml" b
|
|
||||||
console.dirxml(${1:object});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ce "console.error" b
|
|
||||||
console.error(${1:"${2:value}"});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cgroup "console.group" b
|
|
||||||
console.group("${1:label}");
|
|
||||||
${VISUAL}$0
|
|
||||||
console.groupEnd();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cgroupc "console.groupCollapsed" b
|
|
||||||
console.groupCollapsed("${1:label}");
|
|
||||||
${VISUAL}$0
|
|
||||||
console.groupEnd();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ci "console.info" b
|
|
||||||
console.info(${1:"${2:value}"});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cl "console.log" b
|
|
||||||
console.log(${1:"${2:value}"});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cprof "console.profile" b
|
|
||||||
console.profile("${1:label}");
|
|
||||||
${VISUAL}$0
|
|
||||||
console.profileEnd();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ctable "console.table" b
|
|
||||||
console.table(${1:"${2:value}"});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ctime "console.time" b
|
|
||||||
console.time("${1:label}");
|
|
||||||
${VISUAL}$0
|
|
||||||
console.timeEnd("$1");
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ctimestamp "console.timeStamp" b
|
|
||||||
console.timeStamp("${1:label}");
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ctrace "console.trace" b
|
|
||||||
console.trace();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cw "console.warn" b
|
|
||||||
console.warn(${1:"${2:value}"});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# AMD (Asynchronous Module Definition) snippets
|
|
||||||
|
|
||||||
snippet def "define an AMD module"
|
|
||||||
define(${1:optional_name, }[${2:'jquery'}], ${3:callback});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet req "require an AMD module"
|
|
||||||
require([${1:'dependencies'}], ${2:callback});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,169 +0,0 @@
|
|||||||
priority -50
|
|
||||||
extends javascript
|
|
||||||
priority -49
|
|
||||||
|
|
||||||
# JavaScript versions -- from the TextMate bundle + some additions
|
|
||||||
# for jasmine-jquery matchers
|
|
||||||
#
|
|
||||||
|
|
||||||
snippet des "Describe (js)" b
|
|
||||||
describe('${1:description}', function() {
|
|
||||||
$0
|
|
||||||
});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet it "it (js)" b
|
|
||||||
it('${1:description}', function() {
|
|
||||||
$0
|
|
||||||
});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet bef "before each (js)" b
|
|
||||||
beforeEach(function() {
|
|
||||||
$0
|
|
||||||
});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet aft "after each (js)" b
|
|
||||||
afterEach(function() {
|
|
||||||
$0
|
|
||||||
});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet any "any (js)" b
|
|
||||||
jasmine.any($1)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ru "runs (js)" b
|
|
||||||
runs(function() {
|
|
||||||
$0
|
|
||||||
});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wa "waits (js)" b
|
|
||||||
waits($1);
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ex "expect (js)" b
|
|
||||||
expect(${1:target})$0;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ee "expect to equal (js)" b
|
|
||||||
expect(${1:target}).toEqual(${2:value});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet em "expect to match (js)" b
|
|
||||||
expect(${1:target}).toMatch(${2:pattern});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet eha "expect to have attribute (js)" b
|
|
||||||
expect(${1:target}).toHaveAttr('${2:attr}'${3:, '${4:value}'});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet et "expect to be truthy (js)" b
|
|
||||||
expect(${1:target}).toBeTruthy();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ef "expect to be falsy (js)" b
|
|
||||||
expect(${1:target}).toBeFalsy();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ed "expect to be defined (js)" b
|
|
||||||
expect(${1:target}).toBeDefined();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet en "expect to be null (js)" b
|
|
||||||
expect(${1:target}).toBeNull();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ec "expect to contain (js)" b
|
|
||||||
expect(${1:target}).toContain(${2:value});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ev "expect to be visible (js)" b
|
|
||||||
expect(${1:target}).toBeVisible();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet eh "expect to be hidden (js)" b
|
|
||||||
expect(${1:target}).toBeHidden();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notx "expect not (js)" b
|
|
||||||
expect(${1:target}).not$0;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet note "expect not to equal (js)" b
|
|
||||||
expect(${1:target}).not.toEqual(${2:value});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notm "expect not to match (js)" b
|
|
||||||
expect(${1:target}).not.toMatch(${2:pattern});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notha "expect to not have attribute (js)" b
|
|
||||||
expect(${1:target}).not.toHaveAttr('${2:attr}'${3:, '${4:value}'});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet nott "expect not to be truthy (js)" b
|
|
||||||
expect(${1:target}).not.toBeTruthy();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notf "expect not to be falsy (js)" b
|
|
||||||
expect(${1:target}).not.toBeFalsy();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notd "expect not to be defined (js)" b
|
|
||||||
expect(${1:target}).not.toBeDefined();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notn "expect not to be null (js)" b
|
|
||||||
expect(${1:target}).not.toBeNull();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notc "expect not to contain (js)" b
|
|
||||||
expect(${1:target}).not.toContain(${2:value});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notv "expect not to be visible (js)" b
|
|
||||||
expect(${1:target}).not.toBeVisible();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet noth "expect not to be hidden (js)" b
|
|
||||||
expect(${1:target}).not.toBeHidden();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet s "spy on (js)" b
|
|
||||||
spyOn(${1:object}, '${2:method}')$0;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sr "spy on and return (js)" b
|
|
||||||
spyOn(${1:object}, '${2:method}').andReturn(${3:arguments});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet st "spy on and throw (js)" b
|
|
||||||
spyOn(${1:object}, '${2:method}').andThrow(${3:exception});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sct "spy on and call through (js)" b
|
|
||||||
spyOn(${1:object}, '${2:method}').andCallThrough();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet scf "spy on and call fake (js)" b
|
|
||||||
spyOn(${1:object}, '${2:method}').andCallFake(${3:function});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet esc "expect was called (js)" b
|
|
||||||
expect(${1:target}).wasCalled();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet escw "expect was called with (js)" b
|
|
||||||
expect(${1:target}).wasCalledWith(${2:arguments});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notsc "expect was not called (js)" b
|
|
||||||
expect(${1:target}).wasNotCalled();
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet noscw "expect was not called with (js)" b
|
|
||||||
expect(${1:target}).wasNotCalledWith(${2:arguments});
|
|
||||||
endsnippet
|
|
@ -1,51 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
# JSDoc snippets
|
|
||||||
|
|
||||||
snippet /* "A JSDoc comment" b
|
|
||||||
/**
|
|
||||||
* ${1:${VISUAL}}$0
|
|
||||||
*/
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @au "@author email (First Last)"
|
|
||||||
@author ${1:`!v g:snips_author_email`} (${2:`!v g:snips_author`})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @li "@license Description"
|
|
||||||
@license ${1:MIT}$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @ver "@version Semantic version"
|
|
||||||
@version ${1:0.1.0}$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @fileo "@fileoverview Description" b
|
|
||||||
/**
|
|
||||||
* @fileoverview ${1:${VISUAL:A description of the file}}$0
|
|
||||||
*/
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @constr "@constructor"
|
|
||||||
@constructor
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @p "@param {Type} varname Description"
|
|
||||||
@param {${1:Type}} ${2:varname} ${3:Description}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @ret "@return {Type} Description"
|
|
||||||
@return {${1:Type}} ${2:Description}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @pri "@private"
|
|
||||||
@private
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @over "@override"
|
|
||||||
@override
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet @pro "@protected"
|
|
||||||
@protected
|
|
||||||
endsnippet
|
|
@ -1,209 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
# http://jinja.pocoo.org/
|
|
||||||
|
|
||||||
# jinja2 is a full featured template engine for Python. It has full
|
|
||||||
# unicode support, an optional integrated sandboxed execution
|
|
||||||
# environment, widely used and BSD licensed.
|
|
||||||
|
|
||||||
# possible extends:
|
|
||||||
#extends html
|
|
||||||
|
|
||||||
|
|
||||||
snippet block "block" b
|
|
||||||
{% block ${1:name} %}
|
|
||||||
$2
|
|
||||||
{% endblock $1 %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet {{ "variable" b
|
|
||||||
{{ $1 }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet {# "comment" b
|
|
||||||
{# $1 #}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet # "comment" b
|
|
||||||
{# $1 #}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet raw "escaped block" b
|
|
||||||
{% raw %}
|
|
||||||
$1
|
|
||||||
{% endraw %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet extends "extends" b
|
|
||||||
{% extends "${1:template}" %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet include "include" b
|
|
||||||
{% include "${1:template}" %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet import "import" b
|
|
||||||
{% import "${1:template}" %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet from "from/import/as" b
|
|
||||||
{% from "${1:template}" import ${2:name}${3: as ${4:$2}} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet filter "filter" b
|
|
||||||
{% filter ${1:filter} %}
|
|
||||||
$2
|
|
||||||
{% endfilter %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# Being able to quickly remove the whole 'else' block seems faster to me than
|
|
||||||
# choosing between 'for' and 'for/else' snippets from the menu.
|
|
||||||
# snippet for "for" b
|
|
||||||
# {% for ${1:item} in ${2:sequence} %}
|
|
||||||
# $3${4:
|
|
||||||
# {% else %}
|
|
||||||
# $5}
|
|
||||||
# {% endfor %}
|
|
||||||
# endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet for "for" b
|
|
||||||
{% for ${1:item} in ${2:sequence} %}
|
|
||||||
$3
|
|
||||||
{% endfor %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet for "for/else" b
|
|
||||||
{% for ${1:item} in ${2:sequence} %}
|
|
||||||
$3
|
|
||||||
{% else %}
|
|
||||||
$4
|
|
||||||
{% endfor %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet if "if" b
|
|
||||||
{% if ${1:expr} %}
|
|
||||||
$2
|
|
||||||
{% endif %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet if "if/else" b
|
|
||||||
{% if ${1:expr} %}
|
|
||||||
$2
|
|
||||||
{% else %}
|
|
||||||
$3
|
|
||||||
{% endif %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet if "if/elif/else" b
|
|
||||||
{% if ${1:expr} %}
|
|
||||||
$2
|
|
||||||
{% elif %}
|
|
||||||
$3
|
|
||||||
{% else %}
|
|
||||||
$4
|
|
||||||
{% endif %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet macro "macro" b
|
|
||||||
{% macro ${1:name}(${2:args}) %}
|
|
||||||
$3
|
|
||||||
{% endmacro %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet call "call" b
|
|
||||||
{% call ${1:name}(${2:args}) %}
|
|
||||||
$3
|
|
||||||
{% endcall %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet set "set" b
|
|
||||||
{% set ${1:name} = ${2:'value'} %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet trans "translation" b
|
|
||||||
{% trans %}
|
|
||||||
$1
|
|
||||||
{% endtrans %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet with "with" b
|
|
||||||
{% with %}
|
|
||||||
$1
|
|
||||||
{% endwith %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet autoescape "autoescape" b
|
|
||||||
{% autoescape ${1:true} %}
|
|
||||||
$2
|
|
||||||
{% endautoescape %}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Filters
|
|
||||||
# @todo: expand only when snippet is preceeded by a |
|
|
||||||
|
|
||||||
snippet batch "batch items" w
|
|
||||||
batch(linecount=$1, fill_with=${2:None})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet dictsort "sort and yield (key, value) pairs" w
|
|
||||||
dictsort(case_sensitive=${1:False}, by=${2:'key'})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet round "round number" w
|
|
||||||
round(precision=${1:0}, method=${2:'common|ceil|floor'})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet urlize "convert plain-text url to <a/>" w
|
|
||||||
urlize(trim_url_limit=${1:None}, nofollow=${2:False})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet wordwrap "wordwrap" w
|
|
||||||
wordwrap(width=${1:79}, break_long_words=${2:True})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet truncate "truncate" w
|
|
||||||
truncate(lenght=${1:79}, killwords=${2:False}, end=${3:'...''})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet sum "sum of sequence of numbers + start" w
|
|
||||||
sum(attribute=${1:None}, start=${2:0})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet sort "sort an iterable" w
|
|
||||||
sort(reverse=${1:False}, case_sensitive=${2:False}, attribute=${3:None})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet indent "indent" w
|
|
||||||
indent(width=${1:4}, indentfirst=${2:False})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,20 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
snippet s "String" b
|
|
||||||
"${1:key}": "${0:value}",
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet n "number" b
|
|
||||||
"${1:key}": ${0:value},
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet a "Array" b
|
|
||||||
[
|
|
||||||
${VISUAL}$0
|
|
||||||
],
|
|
||||||
endsnippet
|
|
||||||
snippet o "Object" b
|
|
||||||
{
|
|
||||||
${VISUAL}$0
|
|
||||||
},
|
|
||||||
endsnippet
|
|
@ -1,8 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
snippet t "Transaction" b
|
|
||||||
${1:`!v strftime("%Y")`}-${2:`!v strftime("%m")`}-${3:`!v strftime("%d")`} ${4:*} ${5:Payee}
|
|
||||||
${6:Expenses} \$${7:0.00}
|
|
||||||
${8:Assets:Checking}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
@ -1,3 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
extends haskell
|
|
@ -1,39 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Snippets for the Lua language #
|
|
||||||
#################################
|
|
||||||
snippet #! "Shebang header" b
|
|
||||||
#!/usr/bin/env lua
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet !fun(ction)?! "New function" br
|
|
||||||
function ${1:new_function}(${2:args})
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet forp "pair for loop" b
|
|
||||||
for ${1:name},${2:val} in pairs(${3:table_name}) do
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fori "ipair for foop" b
|
|
||||||
for ${1:idx},${2:val} in ipairs(${3:table_name}) do
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "numeric for loop" b
|
|
||||||
for ${1:i}=${2:first},${3:last}${4/^..*/(?0:,:)/}${4:step} do
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet local "local x = 1"
|
|
||||||
local ${1:x} = ${0:1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,92 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
#################
|
|
||||||
# From snipmate #
|
|
||||||
#################
|
|
||||||
snippet def "definition" b
|
|
||||||
<%def name="${1:name}">
|
|
||||||
${2:}
|
|
||||||
</%def>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet call "call" b
|
|
||||||
<%call expr="${1:name}">
|
|
||||||
${2:}
|
|
||||||
</%call>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet doc "doc" b
|
|
||||||
<%doc>
|
|
||||||
${1:}
|
|
||||||
</%doc>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet text "text" b
|
|
||||||
<%text>
|
|
||||||
${1:}
|
|
||||||
</%text>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for" b
|
|
||||||
% for ${1:i} in ${2:iter}:
|
|
||||||
${3:}
|
|
||||||
% endfor
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if " b
|
|
||||||
% if ${1:condition}:
|
|
||||||
${2:}
|
|
||||||
% endif
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if/else" b
|
|
||||||
% if ${1:condition}:
|
|
||||||
${2:}
|
|
||||||
% else:
|
|
||||||
${3:}
|
|
||||||
% endif
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet try "try" b
|
|
||||||
% try:
|
|
||||||
${1:}
|
|
||||||
% except${2:}:
|
|
||||||
${3:pass}
|
|
||||||
% endtry
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wh "wh" b
|
|
||||||
% while ${1:}:
|
|
||||||
${2:}
|
|
||||||
% endwhile
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet $ "$" i
|
|
||||||
${${1:}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet <% "<%" b
|
|
||||||
<% ${1:} %>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet <!% "<!%" b
|
|
||||||
<!% ${1:} %>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet inherit "inherit" b
|
|
||||||
<%inherit file="${1:filename}" />
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet include "include" b
|
|
||||||
<%include file="${1:filename}" />
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet namespace "namespace" b
|
|
||||||
<%namespace file="${1:name}" />
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet page "page" b
|
|
||||||
<%page args="${1:}" />
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,42 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Sections and Paragraphs #
|
|
||||||
###########################
|
|
||||||
snippet sec "Section" b
|
|
||||||
# ${1:Section Name} #
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ssec "Sub Section" b
|
|
||||||
## ${1:Section Name} ##
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sssec "SubSub Section" b
|
|
||||||
### ${1:Section Name} ###
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet par "Paragraph" b
|
|
||||||
#### ${1:Paragraph Name} ####
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet spar "Paragraph" b
|
|
||||||
##### ${1:Paragraph Name} #####
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
################
|
|
||||||
# Common stuff #
|
|
||||||
################
|
|
||||||
snippet link "Link to something"
|
|
||||||
[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet img "Image"
|
|
||||||
![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,272 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# TextMate Snippets #
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
snippet imp "#import (imp)" b
|
|
||||||
#import "${1:`!p snip.rv = re.sub(r'\..*$', '.h', fn)`}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Imp "#import <> (Imp)"
|
|
||||||
#import <${1:Cocoa/Cocoa.h}>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cl "020 Class (objc)"
|
|
||||||
@interface ${1:`!p
|
|
||||||
if len(fn):
|
|
||||||
snip.rv = re.sub(r'\..*$', '', fn)
|
|
||||||
else:
|
|
||||||
snip.rv = "object"
|
|
||||||
`} : ${2:NSObject}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation $1
|
|
||||||
- (id)init
|
|
||||||
{
|
|
||||||
if((self = [super init]))
|
|
||||||
{$0
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet array "NSArray (array)"
|
|
||||||
NSMutableArray *${1:array} = [NSMutableArray array];
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet dict "NSDictionary (dict)"
|
|
||||||
NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet forarray "for NSArray loop (forarray)"
|
|
||||||
unsigned int ${1:object}Count = [${2:array} count];
|
|
||||||
|
|
||||||
for(unsigned int index = 0; index < $1Count; index += 1)
|
|
||||||
{
|
|
||||||
${3:id} $1 = [$2 objectAtIndex:index];
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet objacc "Object Accessors (objacc)"
|
|
||||||
- (${1:id})${2:thing}
|
|
||||||
{
|
|
||||||
return $2;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)set${2/./\u$0/}:($1)aValue
|
|
||||||
{
|
|
||||||
$0${1/( \*)?$/(?1:$1: )/}old${2/./\u$0/} = $2;
|
|
||||||
$2 = [aValue retain];
|
|
||||||
[old${2/./\u$0/} release];
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sel "@selector"
|
|
||||||
@selector(${1:method}:)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cdacc "CoreData Accessors Implementation"
|
|
||||||
- (${1:id})${2:attribute}
|
|
||||||
{
|
|
||||||
[self willAccessValueForKey:@"$2"];
|
|
||||||
$1 value = [self primitiveValueForKey:@"$2"];
|
|
||||||
[self didAccessValueForKey:@"$2"];
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)set${2/./\u$0/}:($1)aValue
|
|
||||||
{
|
|
||||||
[self willChangeValueForKey:@"$2"];
|
|
||||||
[self setPrimitiveValue:aValue forKey:@"$2"];
|
|
||||||
[self didChangeValueForKey:@"$2"];
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet delegate "Delegate Responds to Selector"
|
|
||||||
if([${1:[self delegate]} respondsToSelector:@selector(${2:selfDidSomething:})])
|
|
||||||
[$1 ${3:${2/((^\s*([A-Za-z0-9_]*:)\s*)|(:\s*$)|(:\s*))/(?2:$2self :\:<>)(?4::)(?5: :)/g}}];
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet thread "Detach New NSThread"
|
|
||||||
[NSThread detachNewThreadSelector:@selector(${1:method}:) toTarget:${2:aTarget} withObject:${3:anArgument}]
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ibo "IBOutlet (ibo)"
|
|
||||||
IBOutlet ${1:NSSomeClass} *${2:${1/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet I "Initialize Implementation (I)"
|
|
||||||
+ (void)initialize
|
|
||||||
{
|
|
||||||
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
|
|
||||||
$0@"value", @"key",
|
|
||||||
nil]];
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet bind "Key:value binding (bind)"
|
|
||||||
bind:@"${1:binding}" toObject:${2:observableController} withKeyPath:@"${3:keyPath}" options:${4:nil}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet arracc "LoD array (arracc)"
|
|
||||||
- (void)addObjectTo${1:Things}:(${2:id})anObject
|
|
||||||
{
|
|
||||||
[${3:${1/./\l$0/}} addObject:anObject];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i
|
|
||||||
{
|
|
||||||
[$3 insertObject:anObject atIndex:i];
|
|
||||||
}
|
|
||||||
|
|
||||||
- ($2)objectIn$1AtIndex:(unsigned int)i
|
|
||||||
{
|
|
||||||
return [$3 objectAtIndex:i];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (unsigned int)indexOfObjectIn$1:($2)anObject
|
|
||||||
{
|
|
||||||
return [$3 indexOfObject:anObject];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)removeObjectFrom$1AtIndex:(unsigned int)i
|
|
||||||
{
|
|
||||||
[$3 removeObjectAtIndex:i];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (unsigned int)countOf$1
|
|
||||||
{
|
|
||||||
return [$3 count];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSArray *${1/./\l$0/}
|
|
||||||
{
|
|
||||||
return $3;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)set$1:(NSArray *)new$1
|
|
||||||
{
|
|
||||||
[$3 setArray:new$1];
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet arracc "LoD array interface (arracc)"
|
|
||||||
- (void)addObjectTo${1:Things}:(${2:id})anObject;
|
|
||||||
- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i;
|
|
||||||
- ($2)objectIn$1AtIndex:(unsigned int)i;
|
|
||||||
- (unsigned int)indexOfObjectIn$1:($2)anObject;
|
|
||||||
- (void)removeObjectFrom$1AtIndex:(unsigned int)i;
|
|
||||||
- (unsigned int)countOf$1;
|
|
||||||
- (NSArray *)${1/./\l$0/};
|
|
||||||
- (void)set$1:(NSArray *)new$1;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet focus "Lock Focus"
|
|
||||||
[self lockFocus];
|
|
||||||
$0
|
|
||||||
[self unlockFocus];
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pool "NSAutoreleasePool (pool)"
|
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
|
||||||
$0
|
|
||||||
[pool drain];
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet log "NSLog (log) 2"
|
|
||||||
NSLog(@"$1"${1/[^%]*(%)?.*/(?1:, :\);)/}$2${1/[^%]*(%)?.*/(?1:\);)/}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet alert "NSRunAlertPanel (alert)"
|
|
||||||
int choice = NSRunAlertPanel(@"${1:Something important!}", @"${2:Something important just happend, and now I need to ask you, do you want to continue?}", @"${3:Continue}", @"${4:Cancel}", nil);
|
|
||||||
if(choice == NSAlertDefaultReturn) // "$3"
|
|
||||||
{
|
|
||||||
$0;
|
|
||||||
}
|
|
||||||
else if(choice == NSAlertAlternateReturn) // "$4"
|
|
||||||
{
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet format "NSString stringWithFormat (format)"
|
|
||||||
[NSString stringWithFormat:@"$1", $2]$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet objacc "Object Accessors Interface (objacc)"
|
|
||||||
- (${1:id})${2:thing};
|
|
||||||
- (void)set${2/./\u$0/}:($1)aValue;
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet prop "Property"
|
|
||||||
@property (${1/^(e)$|.*/(?1:r)/}${1:r}${1/^(?:(r)|(e)|(c)|(a))$|.*/(?1:etain)(?2:adonly)(?3:opy)(?4:ssign)/}) ${2:NSSomeClass}$ *${3:${2/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet getprefs "Read from defaults (getprefs)"
|
|
||||||
[[NSUserDefaults standardUserDefaults] objectForKey:${1:key}];
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet obs "Register for Notification"
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:${1:self} selector:@selector(${3:${2/^([A-Z]{2})?(.+?)(Notification)?$/\l$2/}}:) name:${2:NSWindowDidBecomeMainNotification} object:${4:nil}];
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet responds "Responds to Selector"
|
|
||||||
if ([${1:self} respondsToSelector:@selector(${2:someSelector:})])
|
|
||||||
{
|
|
||||||
[$1 ${3:${2/((:\s*$)|(:\s*))/:<>(?3: )/g}}];
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet gsave "Save and Restore Graphics Context (gsave)"
|
|
||||||
[NSGraphicsContext saveGraphicsState];
|
|
||||||
$0
|
|
||||||
[NSGraphicsContext restoreGraphicsState];
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet acc "Scalar Accessors (acc)"
|
|
||||||
- (${1:unsigned int})${2:thing}
|
|
||||||
{
|
|
||||||
return ${3:$2};
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)set${2/./\u$0/}:(${1:unsigned int})new${2/./\u$0/}
|
|
||||||
{
|
|
||||||
$3 = new${2/./\u$0/};
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet acc "Scalar Accessors Interface (acc)"
|
|
||||||
- (${1:unsigned int})${2:thing};
|
|
||||||
- (void)set${2/./\u$0/}:($1)new${2/./\u$0/};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet stracc "String Accessors (stracc)"
|
|
||||||
- (NSString *)${1:thing}
|
|
||||||
{
|
|
||||||
return ${2:$1};
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)set${1/.*/\u$0/}:(NSString *)/})${3:a${1/.*/\u$0/}}
|
|
||||||
{
|
|
||||||
$3 = [$3 copy];
|
|
||||||
[$2 release];
|
|
||||||
$2 = $3;
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet syn "Synthesize"
|
|
||||||
@synthesize ${1:property};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet setprefs "Write to defaults (setprefs)"
|
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:${1:object} forKey:${2:key}];
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,174 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
snippet rs "raise" b
|
|
||||||
raise (${1:Not_found})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet open "open"
|
|
||||||
let open ${1:module} in
|
|
||||||
${2:e}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet try "try"
|
|
||||||
try ${1:e}
|
|
||||||
with ${2:Not_found} -> ${3:()}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ref "ref"
|
|
||||||
let ${1:name} = ref ${2:val} in
|
|
||||||
${3:e}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet matchl "pattern match on a list"
|
|
||||||
match ${1:list} with
|
|
||||||
| [] -> ${2:()}
|
|
||||||
| x::xs -> ${3:()}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet matcho "pattern match on an option type"
|
|
||||||
match ${1:x} with
|
|
||||||
| Some(${2:y}) -> ${3:()}
|
|
||||||
| None -> ${4:()}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fun "anonymous function"
|
|
||||||
(fun ${1:x} -> ${2:x})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cc "commment"
|
|
||||||
(* ${1:comment} *)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet let "let .. in binding"
|
|
||||||
let ${1:x} = ${2:v} in
|
|
||||||
${3:e}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lr "let rec"
|
|
||||||
let rec ${1:f} =
|
|
||||||
${2:expr}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if"
|
|
||||||
if ${1:(* condition *)} then
|
|
||||||
${2:(* A *)}
|
|
||||||
else
|
|
||||||
${3:(* B *)}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet If "If"
|
|
||||||
if ${1:(* condition *)} then
|
|
||||||
${2:(* A *)}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet while "while"
|
|
||||||
while ${1:(* condition *)} do
|
|
||||||
${2:(* A *)}
|
|
||||||
done
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for"
|
|
||||||
for ${1:i} = ${2:1} to ${3:10} do
|
|
||||||
${4:(* BODY *)}
|
|
||||||
done
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet match "match"
|
|
||||||
match ${1:(* e1 *)} with
|
|
||||||
| ${2:p} -> ${3:e2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Match "match"
|
|
||||||
match ${1:(* e1 *)} with
|
|
||||||
| ${2:p} -> ${3:e2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet class "class"
|
|
||||||
class ${1:name} = object
|
|
||||||
${2:methods}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet obj "obj"
|
|
||||||
object
|
|
||||||
${2:methods}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Obj "object"
|
|
||||||
object (self)
|
|
||||||
${2:methods}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet {{ "object functional update"
|
|
||||||
{< ${1:x} = ${2:y} >}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet beg "beg"
|
|
||||||
begin
|
|
||||||
${1:block}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ml "module instantiantion with functor"
|
|
||||||
module ${1:Mod} = ${2:Functor}(${3:Arg})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mod "module - no signature"
|
|
||||||
module ${1:(* Name *)} = struct
|
|
||||||
${2:(* BODY *)}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Mod "module with signature"
|
|
||||||
module ${1:(* Name *)} : ${2:(* SIG *)} = struct
|
|
||||||
${3:(* BODY *)}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sig "anonymous signature"
|
|
||||||
sig
|
|
||||||
${2:(* BODY *)}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sigf "functor signature or anonymous functor"
|
|
||||||
functor (${1:Arg} : ${2:ARG}) -> ${3:(* BODY *)}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet func "define functor - no signature"
|
|
||||||
module ${1:M} (${2:Arg} : ${3:ARG}) = struct
|
|
||||||
${4:(* BODY *)}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet Func "define functor - with signature"
|
|
||||||
module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct
|
|
||||||
${5:(* BODY *)}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mot "Declare module signature"
|
|
||||||
module type ${1:(* Name *)} = sig
|
|
||||||
${2:(* BODY *)}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet module "Module with anonymous signature"
|
|
||||||
module ${1:(* Name *)} : sig
|
|
||||||
${2:(* SIGNATURE *)}
|
|
||||||
end = struct
|
|
||||||
${3:(* BODY *)}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet oo "odoc"
|
|
||||||
(** ${1:odoc} *)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet qt "inline qtest"
|
|
||||||
(*$T ${1:name}
|
|
||||||
${2:test}
|
|
||||||
*)
|
|
||||||
endsnippet
|
|
@ -1,132 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# TextMate Snippets #
|
|
||||||
###########################################################################
|
|
||||||
snippet ife "Conditional if..else (ife)"
|
|
||||||
if ($1) {
|
|
||||||
${2:# body...}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
${3:# else...}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifee "Conditional if..elsif..else (ifee)"
|
|
||||||
if ($1) {
|
|
||||||
${2:# body...}
|
|
||||||
}
|
|
||||||
elsif ($3) {
|
|
||||||
${4:# elsif...}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
${5:# else...}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet xunless "Conditional one-line (unless)"
|
|
||||||
${1:expression} unless ${2:condition};
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet xif "Conditional one-line (xif)"
|
|
||||||
${1:expression} if ${2:condition};
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sub "Function (sub)"
|
|
||||||
sub ${1:function_name} {
|
|
||||||
${2:# body...}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet xfore "Loop one-line (xforeach)"
|
|
||||||
${1:expression} foreach @${2:array};
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet xwhile "Loop one-line (xwhile)"
|
|
||||||
${1:expression} while ${2:condition};
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet test "Test"
|
|
||||||
#!/usr/bin/env perl -w
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use Test::More tests => ${1:1};
|
|
||||||
use ${2:ModuleName};
|
|
||||||
|
|
||||||
ok(${3:assertion});
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet class "class"
|
|
||||||
package ${1:ClassName};
|
|
||||||
|
|
||||||
${2:use parent qw(${3:ParentClass});}${2/.+/\n\n/}sub new {
|
|
||||||
my $class = shift;
|
|
||||||
$class = ref $class if ref $class;
|
|
||||||
my $self = bless {}, $class;
|
|
||||||
$self;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet eval "eval"
|
|
||||||
local $@;
|
|
||||||
eval {
|
|
||||||
${1:# do something risky...}
|
|
||||||
};
|
|
||||||
if (my $${2:exception} = $@) {
|
|
||||||
${3:# handle failure...}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for"
|
|
||||||
for (my $${1:var} = 0; $$1 < ${2:expression}; $$1++) {
|
|
||||||
${3:# body...}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fore "foreach"
|
|
||||||
foreach ${1:my $${2:x}} (@${3:array}) {
|
|
||||||
${4:# body...}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if"
|
|
||||||
if ($1) {
|
|
||||||
${2:# body...}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet slurp "slurp"
|
|
||||||
my $${1:var} = do { local $/ = undef; open my $fh, '<', ${2:$file}; <$fh> };
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet unless "unless"
|
|
||||||
unless ($1) {
|
|
||||||
${2:# body...}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet while "while"
|
|
||||||
while ($1) {
|
|
||||||
${2:# body...}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,264 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
## Snippets from SnipMate, taken from
|
|
||||||
## https://github.com/scrooloose/snipmate-snippets.git
|
|
||||||
|
|
||||||
snippet array "array"
|
|
||||||
$${1:arrayName} = array('${2}' => ${3});${4}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet def "def"
|
|
||||||
define('${1}'${2});${3}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet do "do"
|
|
||||||
do {
|
|
||||||
${2:// code... }
|
|
||||||
} while (${1:/* condition */});"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet doc_f "doc_f"
|
|
||||||
/**
|
|
||||||
* $2
|
|
||||||
* @return ${4:void}
|
|
||||||
* @author ${5:`!v g:snips_author`}
|
|
||||||
**/
|
|
||||||
${1:public }function ${2:someFunc}(${3})
|
|
||||||
{${6}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet doc_i "doc_i"
|
|
||||||
/**
|
|
||||||
* $1
|
|
||||||
* @package ${2:default}
|
|
||||||
* @author ${3:`!v g:snips_author`}
|
|
||||||
**/
|
|
||||||
interface ${1:someClass}
|
|
||||||
{${4}
|
|
||||||
} // END interface $1"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet else "else"
|
|
||||||
else {
|
|
||||||
${1:// code...}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for"
|
|
||||||
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
|
||||||
${4:// code...}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet foreachk "foreachk"
|
|
||||||
foreach ($${1:variable} as $${2:key} => $${3:value}){
|
|
||||||
${4:// code...}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet get "get"
|
|
||||||
$_GET['${1}']${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if"
|
|
||||||
if (${1:/* condition */}) {
|
|
||||||
${2:// code...}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet inc "inc"
|
|
||||||
include '${1:file}';${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet log "log"
|
|
||||||
error_log(var_export(${1}, true));${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet post "post"
|
|
||||||
$_POST['${1}']${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet req1 "req1"
|
|
||||||
require_once '${1:file}';${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet session "session"
|
|
||||||
$_SESSION['${1}']${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t "t"
|
|
||||||
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet var "var"
|
|
||||||
var_export(${1});${2}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet getter "PHP Class Getter" b
|
|
||||||
/*
|
|
||||||
* Getter for $1
|
|
||||||
*/
|
|
||||||
public function get${1/\w+\s*/\u$0/}()
|
|
||||||
{
|
|
||||||
return $this->$1;$2
|
|
||||||
}
|
|
||||||
$4
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet setter "PHP Class Setter" b
|
|
||||||
/*
|
|
||||||
* Setter for $1
|
|
||||||
*/
|
|
||||||
public function set${1/\w+\s*/\u$0/}($$1)
|
|
||||||
{
|
|
||||||
$this->$1 = $$1;$3
|
|
||||||
${4:return $this;}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet gs "PHP Class Getter Setter" b
|
|
||||||
/*
|
|
||||||
* Getter for ${1/(\w+)\s*;/$1/}
|
|
||||||
*/
|
|
||||||
public function get${1/(\w+)\s*;/\u$1/}()
|
|
||||||
{
|
|
||||||
return $this->${1/(\w+)\s*;/$1/};$2
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Setter for ${1/(\w+)\s*;/$1/}
|
|
||||||
*/
|
|
||||||
public function set${1/(\w+)\s*;/\u$1/}($${1/(\w+)\s*;/$1/})
|
|
||||||
{
|
|
||||||
$this->${1/(\w+)\s*;/$1/} = $${1/(\w+)\s*;/$1/};$3
|
|
||||||
${4:return $this;}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pub "Public function" b
|
|
||||||
public function ${1:name}(${2:$param})
|
|
||||||
{
|
|
||||||
${VISUAL}${3:return null;}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pro "Protected function" b
|
|
||||||
protected function ${1:name}(${2:$param})
|
|
||||||
{
|
|
||||||
${VISUAL}${3:return null;}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pri "Private function" b
|
|
||||||
private function ${1:name}(${2:$param})
|
|
||||||
{
|
|
||||||
${VISUAL}${3:return null;}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pubs "Public static function" b
|
|
||||||
public static function ${1:name}(${2:$param})
|
|
||||||
{
|
|
||||||
${VISUAL}${3:return null;}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pros "Protected static function" b
|
|
||||||
protected static function ${1:name}(${2:$param})
|
|
||||||
{
|
|
||||||
${VISUAL}${3:return null;}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pris "Private static function" b
|
|
||||||
private static function ${1:name}(${2:$param})
|
|
||||||
{
|
|
||||||
${VISUAL}${3:return null;}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fu "Function snip" b
|
|
||||||
function ${1:name}(${2:$param})
|
|
||||||
{
|
|
||||||
${VISUAL}${3:return null;}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fore "Foreach loop"
|
|
||||||
foreach ($${1:variable} as $${3:value}){
|
|
||||||
${VISUAL}${4}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet new "New class instance" b
|
|
||||||
$$1 = new $1($2);
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ife "if else"
|
|
||||||
if (${1:/* condition */}) {
|
|
||||||
${2:// code...}
|
|
||||||
} else {
|
|
||||||
${3:// code...}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet class "Class declaration template" b
|
|
||||||
/**
|
|
||||||
* Class ${1:`!p snip.rv=snip.fn.split('.')[0]`}
|
|
||||||
* @author ${2:`!v g:snips_author`}
|
|
||||||
*/
|
|
||||||
class $1
|
|
||||||
{
|
|
||||||
public function ${3:__construct}(${4:$options})
|
|
||||||
{
|
|
||||||
${4:// code}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet construct "__construct()" b
|
|
||||||
/**
|
|
||||||
* @param $2mixed ${1/, /\n * \@param mixed /g}
|
|
||||||
*/
|
|
||||||
public function __construct(${1:$dependencies})
|
|
||||||
{${1/\$(\w+)(, )*/\n $this->$1 = $$1;/g}
|
|
||||||
}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pr "Dumb debug helper in HTML"
|
|
||||||
echo '<pre>' . var_export($1, 1) . '</pre>';$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pc "Dumb debug helper in cli"
|
|
||||||
var_export($1);$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# Symfony 2 based snippets
|
|
||||||
snippet sfa "Symfony 2 Controller action"
|
|
||||||
/**
|
|
||||||
* @Route("/${1:route_name}", name="$1")
|
|
||||||
* @Template()
|
|
||||||
*/
|
|
||||||
public function $1Action($2)
|
|
||||||
{
|
|
||||||
$3
|
|
||||||
return ${4:array();}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# :vim:ft=snippets:
|
|
@ -1,232 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
#########################################################################
|
|
||||||
# Python helper code #
|
|
||||||
#########################################################################
|
|
||||||
|
|
||||||
global !p
|
|
||||||
import vim
|
|
||||||
import os.path
|
|
||||||
def get_module_namespace_and_basename():
|
|
||||||
"""This function will try to guess the current class or define name you are
|
|
||||||
trying to create. Note that for this to work you should be using the module
|
|
||||||
structure as per the style guide. Examples inputs and it's output
|
|
||||||
* /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd
|
|
||||||
* /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql
|
|
||||||
"""
|
|
||||||
first_time = True
|
|
||||||
current_file_path_without_ext = vim.eval('expand("%:p:r")') or ""
|
|
||||||
if not current_file_path_without_ext:
|
|
||||||
return "name"
|
|
||||||
parts = os.path.split(current_file_path_without_ext)
|
|
||||||
namespace = ''
|
|
||||||
while parts[0] and parts[0] != '/':
|
|
||||||
if parts[1] == 'init' and first_time and not namespace:
|
|
||||||
first_time = False
|
|
||||||
parts = os.path.split(parts[0])
|
|
||||||
continue
|
|
||||||
if parts[1] == 'manifests':
|
|
||||||
return os.path.split(parts[0])[1] + ('::' + namespace).rstrip(':')
|
|
||||||
else:
|
|
||||||
namespace = parts[1] + '::' + namespace
|
|
||||||
parts = os.path.split(parts[0])
|
|
||||||
# couldn't guess the namespace. The user is editing a raw file in no module like the site.pp file
|
|
||||||
return "name"
|
|
||||||
endglobal
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Puppet Language Constructs #
|
|
||||||
# See http://docs.puppetlabs.com/puppet/latest/reference/lang_summary.html #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
snippet class "Class declaration" b
|
|
||||||
class ${1:`!p snip.rv = get_module_namespace_and_basename()`} {
|
|
||||||
${0:# body}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet define "Definition" b
|
|
||||||
define ${1:`!p snip.rv = get_module_namespace_and_basename()`} {
|
|
||||||
${0:# body}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
#################################################################
|
|
||||||
# Puppet Types #
|
|
||||||
# See http://docs.puppetlabs.com/references/latest/type.html #
|
|
||||||
#################################################################
|
|
||||||
|
|
||||||
snippet cron "Cron resource type" b
|
|
||||||
cron { '${1:name}':
|
|
||||||
user => ${2:user},
|
|
||||||
command => '${3:command}',
|
|
||||||
minute => ${3:minute},
|
|
||||||
hour => ${4:hour},
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet exec "Exec resource type" b
|
|
||||||
exec { '${1:command}':
|
|
||||||
refreshonly => true,
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet file "File resource type" b
|
|
||||||
file { '${1:name}':
|
|
||||||
source => "puppet://${2:path}",
|
|
||||||
mode => ${3:mode},
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet File "Defaults for file" b
|
|
||||||
File {
|
|
||||||
owner => ${1:username},
|
|
||||||
group => ${2:groupname},
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet group "Group resource type" b
|
|
||||||
group { '${1:groupname}':
|
|
||||||
ensure => ${3:present},
|
|
||||||
gid => ${2:gid},
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mount "Mount resource type" b
|
|
||||||
mount { '${1:path}':
|
|
||||||
device => '${2:/dev}',
|
|
||||||
fstype => '${3:filesystem}',
|
|
||||||
ensure => mounted,
|
|
||||||
options => 'rw,errors=remount-ro',
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet package "Package resource type" b
|
|
||||||
package { '${1:name}':
|
|
||||||
ensure => ${2:installed},
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet user "user resource type" b
|
|
||||||
user { '${1:username}':
|
|
||||||
ensure => ${2:present},
|
|
||||||
uid => ${3:uid},
|
|
||||||
gid => ${4:gid},
|
|
||||||
comment => ${5:gecos},
|
|
||||||
home => ${6:homedirectory},
|
|
||||||
managehome => false,
|
|
||||||
require => Group['${7:group'}],
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet service "Service resource type" b
|
|
||||||
service { '${1:name}':
|
|
||||||
hasstatus => true,
|
|
||||||
enable => true,
|
|
||||||
ensure => running,
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Puppet Functions #
|
|
||||||
# See http://docs.puppetlabs.com/references/latest/function.html #
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
snippet alert "Alert Function" b
|
|
||||||
alert("${1:message}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet crit "Crit Function" b
|
|
||||||
crit("${1:message}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet debug "Debug Function" b
|
|
||||||
debug("${1:message}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet defined "Defined Function" b
|
|
||||||
defined(${1:Resource}["${2:name}"])${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet emerg "Emerg Function" b
|
|
||||||
emerg("${1:message}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet extlookup "Simple Extlookup" b
|
|
||||||
$${1:Variable} = extlookup("${2:Lookup}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet extlookup "Extlookup with defaults" b
|
|
||||||
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default})${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet extlookup "Extlookup with defaults and custom data file" b
|
|
||||||
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default}, ${4:Data Source})${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fail "Fail Function" b
|
|
||||||
fail("${1:message}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hiera "Hiera Function" b
|
|
||||||
$${1:Variable} = hiera("${2:Lookup}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hiera "Hiera with defaults" b
|
|
||||||
$${1:Variable} = hiera("${2:Lookup}", ${3:Default})${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hiera "Hiera with defaults and override" b
|
|
||||||
$${1:Variable} = hiera("${2:Lookup}", ${3:Default}, ${4:Override})${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hiera_hash "Hiera Hash Function" b
|
|
||||||
$${1:Variable} = hiera_hash("${2:Lookup}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hiera_hash "Hiera Hash with defaults" b
|
|
||||||
$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default})${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hiera_hash "Hiera Hash with defaults and override" b
|
|
||||||
$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default}, ${4:Override})${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hiera_include "Hiera Include Function" b
|
|
||||||
hiera_include("${1:Lookup}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet include "Include Function" b
|
|
||||||
include ${1:classname}${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet info "Info Function" b
|
|
||||||
info("${1:message}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet inline_template "Inline Template Function" b
|
|
||||||
inline_template("<%= ${1:template} %>")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet notice "Notice Function" b
|
|
||||||
notice("${1:message}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet realize "Realize Function" b
|
|
||||||
realize(${1:Resource}["${2:name}"])${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet regsubst "Regsubst Function" b
|
|
||||||
regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet split "Split Function" b
|
|
||||||
$${1:Variable} = split($${1:Target}, '${2:regexp}')${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet versioncmp "Version Compare Function" b
|
|
||||||
$${1:Variable} = versioncmp('${1:version}', '${2:version}')${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet warning "Warning Function" b
|
|
||||||
warning("${1:message}")${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,533 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# TEXTMATE SNIPPETS #
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
#! header
|
|
||||||
snippet #! "Shebang header for python scripts" b
|
|
||||||
#!/usr/bin/env python
|
|
||||||
# encoding: utf-8
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifmain "ifmain" b
|
|
||||||
if __name__ == '__main__':
|
|
||||||
${1:main()}$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for loop" b
|
|
||||||
for ${1:item} in ${2:iterable}:
|
|
||||||
${3:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
##########
|
|
||||||
# COMMON #
|
|
||||||
##########
|
|
||||||
|
|
||||||
# The smart def and smart class snippets use a global option called
|
|
||||||
# "g:ultisnips_python_style" which, if set to "doxygen" will use doxygen
|
|
||||||
# style comments in docstrings.
|
|
||||||
|
|
||||||
global !p
|
|
||||||
|
|
||||||
NORMAL = 0x1
|
|
||||||
DOXYGEN = 0x2
|
|
||||||
SPHINX = 0x3
|
|
||||||
|
|
||||||
SINGLE_QUOTES = 0x1
|
|
||||||
DOUBLE_QUOTES = 0x2
|
|
||||||
|
|
||||||
def get_args(arglist):
|
|
||||||
args = [arg.split('=')[0].strip() for arg in arglist.split(',') if arg]
|
|
||||||
args = [arg for arg in args if arg and arg != "self"]
|
|
||||||
|
|
||||||
return args
|
|
||||||
|
|
||||||
|
|
||||||
def get_quoting_style(snip):
|
|
||||||
style = snip.opt("g:ultisnips_python_quoting_style", "double")
|
|
||||||
if style == 'single':
|
|
||||||
return SINGLE_QUOTES
|
|
||||||
return DOUBLE_QUOTES
|
|
||||||
|
|
||||||
def tripple_quotes(snip):
|
|
||||||
if get_quoting_style(snip) == SINGLE_QUOTES:
|
|
||||||
return "'''"
|
|
||||||
return '"""'
|
|
||||||
|
|
||||||
def get_style(snip):
|
|
||||||
style = snip.opt("g:ultisnips_python_style", "normal")
|
|
||||||
|
|
||||||
if style == "doxygen": return DOXYGEN
|
|
||||||
elif style == "sphinx": return SPHINX
|
|
||||||
else: return NORMAL
|
|
||||||
|
|
||||||
|
|
||||||
def format_arg(arg, style):
|
|
||||||
if style == DOXYGEN:
|
|
||||||
return "@param %s @todo" % arg
|
|
||||||
elif style == SPHINX:
|
|
||||||
return ":param %s: @todo" % arg
|
|
||||||
elif style == NORMAL:
|
|
||||||
return ":%s: @todo" % arg
|
|
||||||
|
|
||||||
|
|
||||||
def format_return(style):
|
|
||||||
if style == DOXYGEN:
|
|
||||||
return "@return: @todo"
|
|
||||||
elif style in (NORMAL, SPHINX):
|
|
||||||
return ":returns: @todo"
|
|
||||||
|
|
||||||
|
|
||||||
def write_docstring_args(args, snip):
|
|
||||||
if not args:
|
|
||||||
snip.rv += ' {0}'.format(tripple_quotes(snip))
|
|
||||||
return
|
|
||||||
|
|
||||||
snip.rv += '\n' + snip.mkline('', indent='')
|
|
||||||
|
|
||||||
style = get_style(snip)
|
|
||||||
|
|
||||||
for arg in args:
|
|
||||||
snip += format_arg(arg, style)
|
|
||||||
|
|
||||||
|
|
||||||
def write_init_body(args, parents, snip):
|
|
||||||
parents = [p.strip() for p in parents.split(",")]
|
|
||||||
parents = [p for p in parents if p != 'object']
|
|
||||||
|
|
||||||
for p in parents:
|
|
||||||
snip += p + ".__init__(self)"
|
|
||||||
|
|
||||||
if parents:
|
|
||||||
snip.rv += '\n' + snip.mkline('', indent='')
|
|
||||||
|
|
||||||
for arg in args:
|
|
||||||
snip += "self._%s = %s" % (arg, arg)
|
|
||||||
|
|
||||||
|
|
||||||
def write_slots_args(args, snip):
|
|
||||||
args = ['"_%s"' % arg for arg in args]
|
|
||||||
snip += '__slots__ = (%s,)' % ', '.join(args)
|
|
||||||
|
|
||||||
endglobal
|
|
||||||
|
|
||||||
########################################
|
|
||||||
# Class & Special Method Name Snippets #
|
|
||||||
########################################
|
|
||||||
|
|
||||||
snippet class "class with docstrings" b
|
|
||||||
class ${1:MyClass}(${2:object}):
|
|
||||||
|
|
||||||
`!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)`
|
|
||||||
|
|
||||||
def __init__(self$4):
|
|
||||||
`!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined1.}`!p
|
|
||||||
snip.rv = ""
|
|
||||||
snip >> 2
|
|
||||||
|
|
||||||
args = get_args(t[4])
|
|
||||||
|
|
||||||
write_docstring_args(args, snip)
|
|
||||||
if args:
|
|
||||||
snip.rv += '\n' + snip.mkline('', indent='')
|
|
||||||
snip += '{0}'.format(tripple_quotes(snip))
|
|
||||||
|
|
||||||
write_init_body(args, t[2], snip)
|
|
||||||
`
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet slotclass "class with slots and docstrings" b
|
|
||||||
class ${1:MyClass}(${2:object}):
|
|
||||||
|
|
||||||
`!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)`
|
|
||||||
`!p
|
|
||||||
snip >> 1
|
|
||||||
args = get_args(t[4])
|
|
||||||
write_slots_args(args, snip)
|
|
||||||
`
|
|
||||||
|
|
||||||
def __init__(self$4):
|
|
||||||
`!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined.}`!p
|
|
||||||
snip.rv = ""
|
|
||||||
snip >> 2
|
|
||||||
|
|
||||||
args = get_args(t[4])
|
|
||||||
|
|
||||||
write_docstring_args(args, snip)
|
|
||||||
if args:
|
|
||||||
snip.rv += '\n' + snip.mkline('', indent='')
|
|
||||||
snip += tripple_quotes(snip)
|
|
||||||
|
|
||||||
write_init_body(args, t[2], snip)
|
|
||||||
`
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet contain "methods for emulating a container type" b
|
|
||||||
def __len__(self):
|
|
||||||
${1:pass}
|
|
||||||
|
|
||||||
def __getitem__(self, key):
|
|
||||||
${2:pass}
|
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
|
||||||
${3:pass}
|
|
||||||
|
|
||||||
def __delitem__(self, key):
|
|
||||||
${4:pass}
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
${5:pass}
|
|
||||||
|
|
||||||
def __reversed__(self):
|
|
||||||
${6:pass}
|
|
||||||
|
|
||||||
def __contains__(self, item):
|
|
||||||
${7:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet context "context manager methods" b
|
|
||||||
def __enter__(self):
|
|
||||||
${1:pass}
|
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
|
||||||
${2:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet attr "methods for customizing attribute access" b
|
|
||||||
def __getattr__(self, name):
|
|
||||||
${1:pass}
|
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
|
||||||
${2:pass}
|
|
||||||
|
|
||||||
def __delattr__(self, name):
|
|
||||||
${3:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet desc "methods implementing descriptors" b
|
|
||||||
def __get__(self, instance, owner):
|
|
||||||
${1:pass}
|
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
|
||||||
${2:pass}
|
|
||||||
|
|
||||||
def __delete__(self, instance):
|
|
||||||
${3:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet cmp "methods implementing rich comparison"
|
|
||||||
def __eq__(self, other):
|
|
||||||
${1:pass}
|
|
||||||
|
|
||||||
def __ne__(self, other):
|
|
||||||
${2:pass}
|
|
||||||
|
|
||||||
def __lt__(self, other):
|
|
||||||
${3:pass}
|
|
||||||
|
|
||||||
def __le__(self, other):
|
|
||||||
${4:pass}
|
|
||||||
|
|
||||||
def __gt__(self, other):
|
|
||||||
${5:pass}
|
|
||||||
|
|
||||||
def __ge__(self, other):
|
|
||||||
${6:pass}
|
|
||||||
|
|
||||||
def __cmp__(self, other):
|
|
||||||
${7:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet repr "methods implementing string representation"
|
|
||||||
def __repr__(self):
|
|
||||||
${1:pass}
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
${2:pass}
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
${3:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# note: reflected operands and augmented arithmeitc assignements have been
|
|
||||||
# intentionally ommited to reduce verbosity.
|
|
||||||
snippet numeric "methods for emulating a numeric type" b
|
|
||||||
def __add__(self, other):
|
|
||||||
${1:pass}
|
|
||||||
|
|
||||||
def __sub__(self, other):
|
|
||||||
${2:pass}
|
|
||||||
|
|
||||||
def __mul__(self, other):
|
|
||||||
${3:pass}
|
|
||||||
|
|
||||||
def __div__(self, other):
|
|
||||||
${4:pass}
|
|
||||||
|
|
||||||
def __truediv__(self, other):
|
|
||||||
${5:pass}
|
|
||||||
|
|
||||||
def __floordiv__(self, other):
|
|
||||||
${6:pass}
|
|
||||||
|
|
||||||
|
|
||||||
def __mod__(self, other):
|
|
||||||
${7:pass}
|
|
||||||
|
|
||||||
def __divmod__(self, other):
|
|
||||||
${8:pass}
|
|
||||||
|
|
||||||
def __pow__(self, other):
|
|
||||||
${9:pass}
|
|
||||||
|
|
||||||
|
|
||||||
def __lshift__(self, other):
|
|
||||||
${10:pass}
|
|
||||||
|
|
||||||
def __rshift__(self, other):
|
|
||||||
${11:pass}
|
|
||||||
|
|
||||||
def __and__(self, other):
|
|
||||||
${12:pass}
|
|
||||||
|
|
||||||
def __xor__(self, other):
|
|
||||||
${13:pass}
|
|
||||||
|
|
||||||
def __or__(self, other):
|
|
||||||
${14:pass}
|
|
||||||
|
|
||||||
|
|
||||||
def __neg__(self):
|
|
||||||
${15:pass}
|
|
||||||
|
|
||||||
def __pos__(self):
|
|
||||||
${16:pass}
|
|
||||||
|
|
||||||
def __abs__(self):
|
|
||||||
${17:pass}
|
|
||||||
|
|
||||||
def __invert__(self):
|
|
||||||
${18:pass}
|
|
||||||
|
|
||||||
|
|
||||||
def __complex__(self):
|
|
||||||
${19:pass}
|
|
||||||
|
|
||||||
def __int__(self):
|
|
||||||
${20:pass}
|
|
||||||
|
|
||||||
def __long__(self):
|
|
||||||
${21:pass}
|
|
||||||
|
|
||||||
def __float__(self):
|
|
||||||
${22:pass}
|
|
||||||
|
|
||||||
|
|
||||||
def __oct__(self):
|
|
||||||
${22:pass}
|
|
||||||
|
|
||||||
def __hex__(self):
|
|
||||||
${23:pass}
|
|
||||||
|
|
||||||
|
|
||||||
def __index__(self):
|
|
||||||
${24:pass}
|
|
||||||
|
|
||||||
def __coerce__(self, other):
|
|
||||||
${25:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet def "function with docstrings" b
|
|
||||||
def ${1:function}(`!p
|
|
||||||
if snip.indent:
|
|
||||||
snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}):
|
|
||||||
`!p snip.rv = tripple_quotes(snip)`${4:@todo: Docstring for $1.}`!p
|
|
||||||
snip.rv = ""
|
|
||||||
snip >> 1
|
|
||||||
|
|
||||||
args = get_args(t[2])
|
|
||||||
if args:
|
|
||||||
write_docstring_args(args, snip)
|
|
||||||
|
|
||||||
style = get_style(snip)
|
|
||||||
snip += format_return(style)
|
|
||||||
snip.rv += '\n' + snip.mkline('', indent='')
|
|
||||||
snip += tripple_quotes(snip) `
|
|
||||||
${0:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
# doesn't expand when there is a word in front
|
|
||||||
snippet /(^|(?<=\W))\./ "self." r
|
|
||||||
self.
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet from "from module import name" b
|
|
||||||
from ${1:module} import ${2:Stuff}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
##############
|
|
||||||
# PROPERTIES #
|
|
||||||
##############
|
|
||||||
snippet roprop "Read Only Property" b
|
|
||||||
@property
|
|
||||||
def ${1:name}(self):
|
|
||||||
${2:return self._$1}$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rwprop "Read write property" b
|
|
||||||
def ${1:name}():
|
|
||||||
`!p snip.rv = tripple_quotes(snip) if t[2] else ''
|
|
||||||
`${2:@todo: Docstring for $1.}`!p
|
|
||||||
if t[2]:
|
|
||||||
snip >> 1
|
|
||||||
|
|
||||||
style = get_style(snip)
|
|
||||||
snip.rv += '\n' + snip.mkline('', indent='')
|
|
||||||
snip += format_return(style)
|
|
||||||
snip.rv += '\n' + snip.mkline('', indent='')
|
|
||||||
snip += tripple_quotes(snip)
|
|
||||||
else:
|
|
||||||
snip.rv = ""`
|
|
||||||
def fget(self):
|
|
||||||
return self._$1$0
|
|
||||||
|
|
||||||
def fset(self, value):
|
|
||||||
self._$1 = value
|
|
||||||
return locals()
|
|
||||||
|
|
||||||
$1 = property(**$1(), doc=$1.__doc__)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
####################
|
|
||||||
# If / Else / Elif #
|
|
||||||
####################
|
|
||||||
snippet if "If" b
|
|
||||||
if ${1:condition}:
|
|
||||||
${2:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ife "If / Else" b
|
|
||||||
if ${1:condition}:
|
|
||||||
${2:pass}
|
|
||||||
else:
|
|
||||||
${3:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifee "If / Elif / Else" b
|
|
||||||
if ${1:condition}:
|
|
||||||
${2:pass}
|
|
||||||
elif ${3:condition}:
|
|
||||||
${4:pass}
|
|
||||||
else:
|
|
||||||
${5:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# Try / Except / Finally #
|
|
||||||
##########################
|
|
||||||
snippet try "Try / Except" b
|
|
||||||
try:
|
|
||||||
${1:pass}
|
|
||||||
except ${2:Exception}, ${3:e}:
|
|
||||||
${4:raise $3}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet try "Try / Except / Else" b
|
|
||||||
try:
|
|
||||||
${1:pass}
|
|
||||||
except ${2:Exception}, ${3:e}:
|
|
||||||
${4:raise $3}
|
|
||||||
else:
|
|
||||||
${5:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet try "Try / Except / Finally" b
|
|
||||||
try:
|
|
||||||
${1:pass}
|
|
||||||
except ${2:Exception}, ${3:e}:
|
|
||||||
${4:raise $3}
|
|
||||||
finally:
|
|
||||||
${5:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet try "Try / Except / Else / Finally" b
|
|
||||||
try:
|
|
||||||
${1:pass}
|
|
||||||
except${2: ${3:Exception}, ${4:e}}:
|
|
||||||
${5:raise}
|
|
||||||
else:
|
|
||||||
${6:pass}
|
|
||||||
finally:
|
|
||||||
${7:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
#####################
|
|
||||||
# Assertions & Tests #
|
|
||||||
#####################
|
|
||||||
|
|
||||||
snippet pdb "Set PDB breakpoint" b
|
|
||||||
import pdb; pdb.set_trace()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ipdb "Set IPDB breakpoint" b
|
|
||||||
import ipdb; ipdb.set_trace()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pudb "Set PUDB breakpoint" b
|
|
||||||
import pudb; pudb.set_trace()
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ae "Assert equal" b
|
|
||||||
self.assertEqual(${1:first},${2:second})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet at "Assert True" b
|
|
||||||
self.assertTrue(${0:exp})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet af "Assert False" b
|
|
||||||
self.assertFalse(${1:expression})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet aae "Assert almost equal" b
|
|
||||||
self.assertAlmostEqual(${1:first},${2:second})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ar "Assert raises" b
|
|
||||||
self.assertRaises(${1:exception}, ${2:func}${3/.+/, /}${3:arguments})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet testcase "pyunit testcase" b
|
|
||||||
class Test${1:Class}(${2:unittest.TestCase}):
|
|
||||||
|
|
||||||
`!p snip.rv = tripple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = tripple_quotes(snip)`
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
${4:pass}
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
${5:pass}
|
|
||||||
|
|
||||||
def test_${6:name}(self):
|
|
||||||
${7:pass}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,904 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
snippet anaf "accepts_nested_attributes_for"
|
|
||||||
accepts_nested_attributes_for :${1:association_name}${2:${3:, :allow_destroy => true}${4:, :reject_if => proc \{ |obj| ${5:obj.blank?} \}}}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcbi "Create binary column"
|
|
||||||
t.binary :${1:title}${2:, :limit => ${3:2}.megabytes}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcb "Create boolean column"
|
|
||||||
t.boolean :${1:title}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cla "Create controller class"
|
|
||||||
class ${1:Model}Controller < ApplicationController
|
|
||||||
before_filter :find_${2:model}
|
|
||||||
|
|
||||||
$0
|
|
||||||
|
|
||||||
private
|
|
||||||
def find_${2}
|
|
||||||
@$2 = ${3:$1}.find(params[:id]) if params[:id]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcda "Create date column"
|
|
||||||
t.date :${1:title}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcdt "Create datetime column"
|
|
||||||
t.datetime :${1:title}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcd "Create decimal column"
|
|
||||||
t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcf "Create float column"
|
|
||||||
t.float :${1:title}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cla "Create functional test class"
|
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class ${1:Model}ControllerTest < ActionController::TestCase
|
|
||||||
test$0
|
|
||||||
end
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tci "Create integer column"
|
|
||||||
t.integer :${1:title}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcl "Create lock_version column"
|
|
||||||
t.integer :lock_version, :null => false, :default => 0
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# FIXME: handling literal bracket pair inside of nested tab groups?
|
|
||||||
snippet tcr "Create references column"
|
|
||||||
t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet resources "Create resources controller class"
|
|
||||||
class ${1:Model}sController < ApplicationController
|
|
||||||
before_filter :find_${1/./\l$0/}, :only => [:show, :edit, :update, :destroy]
|
|
||||||
|
|
||||||
# GET /${1/./\l$0/}s
|
|
||||||
# GET /${1/./\l$0/}s.xml
|
|
||||||
def index
|
|
||||||
@${1/./\l$0/}s = ${1:Model}.all
|
|
||||||
|
|
||||||
respond_to do |wants|
|
|
||||||
wants.html # index.html.erb
|
|
||||||
wants.xml { render :xml => @${1/./\l$0/}s }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /${1/./\l$0/}s/1
|
|
||||||
# GET /${1/./\l$0/}s/1.xml
|
|
||||||
def show
|
|
||||||
respond_to do |wants|
|
|
||||||
wants.html # show.html.erb
|
|
||||||
wants.xml { render :xml => @${1/./\l$0/} }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /${1/./\l$0/}s/new
|
|
||||||
# GET /${1/./\l$0/}s/new.xml
|
|
||||||
def new
|
|
||||||
@${1/./\l$0/} = ${1:Model}.new
|
|
||||||
|
|
||||||
respond_to do |wants|
|
|
||||||
wants.html # new.html.erb
|
|
||||||
wants.xml { render :xml => @${1/./\l$0/} }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /${1/./\l$0/}s/1/edit
|
|
||||||
def edit
|
|
||||||
end
|
|
||||||
|
|
||||||
# POST /${1/./\l$0/}s
|
|
||||||
# POST /${1/./\l$0/}s.xml
|
|
||||||
def create
|
|
||||||
@${1/./\l$0/} = ${1:Model}.new(params[:${1/./\l$0/}])
|
|
||||||
|
|
||||||
respond_to do |wants|
|
|
||||||
if @${1/./\l$0/}.save
|
|
||||||
flash[:notice] = '${1:Model} was successfully created.'
|
|
||||||
wants.html { redirect_to(@${1/./\l$0/}) }
|
|
||||||
wants.xml { render :xml => @${1/./\l$0/}, :status => :created, :location => @${1/./\l$0/} }
|
|
||||||
else
|
|
||||||
wants.html { render :action => "new" }
|
|
||||||
wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# PUT /${1/./\l$0/}s/1
|
|
||||||
# PUT /${1/./\l$0/}s/1.xml
|
|
||||||
def update
|
|
||||||
respond_to do |wants|
|
|
||||||
if @${1/./\l$0/}.update_attributes(params[:${1/./\l$0/}])
|
|
||||||
flash[:notice] = '${1:Model} was successfully updated.'
|
|
||||||
wants.html { redirect_to(@${1/./\l$0/}) }
|
|
||||||
wants.xml { head :ok }
|
|
||||||
else
|
|
||||||
wants.html { render :action => "edit" }
|
|
||||||
wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# DELETE /${1/./\l$0/}s/1
|
|
||||||
# DELETE /${1/./\l$0/}s/1.xml
|
|
||||||
def destroy
|
|
||||||
@${1/./\l$0/}.destroy
|
|
||||||
|
|
||||||
respond_to do |wants|
|
|
||||||
wants.html { redirect_to(${1/./\l$0/}s_url) }
|
|
||||||
wants.xml { head :ok }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
def find_${1/./\l$0/}
|
|
||||||
@${1/./\l$0/} = ${1:Model}.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcs "Create string column"
|
|
||||||
t.string :${1:title}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tct "Create text column"
|
|
||||||
t.text :${1:title}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcti "Create time column"
|
|
||||||
t.time :${1:title}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tcts "Create timestamp column"
|
|
||||||
t.timestamp :${1:title}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tctss "Create timestamps columns"
|
|
||||||
t.timestamps
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mcol "Migration Create Column (mcc)"
|
|
||||||
t.column ${1:title}, :${2:string}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mccc "Migration Create Column Continue (mccc)"
|
|
||||||
t.column ${1:title}, :${2:string}
|
|
||||||
mccc$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mtab "Migration Drop Create Table (mdct)"
|
|
||||||
drop_table :${1:table}${2: [press tab twice to generate create_table]}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mcol "Migration Remove and Add Column (mrac)"
|
|
||||||
remove_column :${1:table}, :${2:column}${3: [press tab twice to generate add_column]}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rdb "RAILS_DEFAULT_LOGGER.debug (rdb)"
|
|
||||||
RAILS_DEFAULT_LOGGER.debug "${1:message}"$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tre "Table column(s) rename"
|
|
||||||
t.rename(:${1:old_column_name}, :${2:new_column_name})
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet art "Test Assert Redirected To (art)"
|
|
||||||
assert_redirected_to ${2::action => "${1:index}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet asre "Test Assert Response (are)"
|
|
||||||
assert_response :${1:success}, @response.body$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet aftc "after_create"
|
|
||||||
after_create $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet aftd "after_destroy"
|
|
||||||
after_destroy $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet afts "after_save"
|
|
||||||
after_save $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet aftu "after_update"
|
|
||||||
after_update $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet aftv "after_validation"
|
|
||||||
after_validation $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet aftvoc "after_validation_on_create"
|
|
||||||
after_validation_on_create $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet aftvou "after_validation_on_update"
|
|
||||||
after_validation_on_update $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet asg "assert(var = assigns(:var))"
|
|
||||||
assert(${1:var} = assigns(:${1}), "Cannot find @${1}")
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet asd "assert_difference"
|
|
||||||
assert_difference "${1:Model}.${2:count}", ${3:1} do
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet asnd "assert_no_difference"
|
|
||||||
assert_no_difference "${1:Model}.${2:count}" do
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet artnpp "assert_redirected_to (nested path plural)"
|
|
||||||
assert_redirected_to ${10:${2:parent}_${3:child}_path(${4:@}${5:${2}})}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet artnp "assert_redirected_to (nested path)"
|
|
||||||
assert_redirected_to ${2:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet artpp "assert_redirected_to (path plural)"
|
|
||||||
assert_redirected_to ${10:${2:model}s_path}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet artp "assert_redirected_to (path)"
|
|
||||||
assert_redirected_to ${2:${12:model}_path(${13:@}${14:${12}})}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet asrj "assert_rjs"
|
|
||||||
assert_rjs :${1:replace}, ${2:"${3:dom id}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ass "assert_select"
|
|
||||||
assert_select '${1:path}'${2:, :${3:text} => ${4:'${5:inner_html}'}}${6: do
|
|
||||||
$0
|
|
||||||
end}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet befc "before_create"
|
|
||||||
before_create $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet befd "before_destroy"
|
|
||||||
before_destroy $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet befs "before_save"
|
|
||||||
before_save $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet befu "before_update"
|
|
||||||
before_update $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet befv "before_validation"
|
|
||||||
before_validation $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet befvoc "before_validation_on_create"
|
|
||||||
before_validation_on_create $0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet befvou "before_validation_on_update"
|
|
||||||
before_validation_on_update
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet bt "belongs_to (bt)"
|
|
||||||
belongs_to :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:${1}_id}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet crw "cattr_accessor"
|
|
||||||
cattr_accessor :${0:attr_names}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet defcreate "def create - resource"
|
|
||||||
def create
|
|
||||||
@${1:model} = ${2:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}.new(params[:$1])
|
|
||||||
$0
|
|
||||||
respond_to do |wants|
|
|
||||||
if @$1.save
|
|
||||||
flash[:notice] = '$2 was successfully created.'
|
|
||||||
wants.html { redirect_to(@$1) }
|
|
||||||
wants.xml { render :xml => @$1, :status => :created, :location => @$1 }
|
|
||||||
else
|
|
||||||
wants.html { render :action => "new" }
|
|
||||||
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet test "test do..end"
|
|
||||||
test "${1:something interesting}" do
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet deftg "def get request"
|
|
||||||
def test_should_get_${1:action}
|
|
||||||
${2:@${3:model} = ${4:$3s}(:${5:fixture_name})
|
|
||||||
}get :${1}${6:, :id => @$3.to_param}
|
|
||||||
assert_response :success
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet deftp "def post request"
|
|
||||||
def test_should_post_${1:action}
|
|
||||||
${3:@$2 = ${4:$2s}(:${5:fixture_name})
|
|
||||||
}post :${1}${6:, :id => @$2.to_param}, :${2:model} => { $0 }
|
|
||||||
assert_response :redirect
|
|
||||||
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fina "find(:all)"
|
|
||||||
find(:all${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet finf "find(:first)"
|
|
||||||
find(:first${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fini "find(id)"
|
|
||||||
find(${1:id})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fine "find_each"
|
|
||||||
find_each(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}|
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet finb "find_in_batches"
|
|
||||||
find_in_batches(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}s|
|
|
||||||
$4s.each do |$4|
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet habtm "has_and_belongs_to_many (habtm)"
|
|
||||||
has_and_belongs_to_many :${1:object}${2:, :join_table => "${3:table_name}", :foreign_key => "${4:${1}_id}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hm "has_many (hm)"
|
|
||||||
has_many :${1:object}s${2:, :class_name => "${1}", :foreign_key => "${4:reference}_id"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hmt "has_many (through)"
|
|
||||||
has_many :${1:objects}, :through => :${2:join_association}${3:, :source => :${4:${2}_table_foreign_key_to_${1}_table}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet hmd "has_many :dependent => :destroy"
|
|
||||||
has_many :${1:object}s${2:, :class_name => "${1}", :foreign_key => "${4:reference}_id"}, :dependent => :destroy$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ho "has_one (ho)"
|
|
||||||
has_one :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:${1}_id}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet logd "logger.debug"
|
|
||||||
${1:Rails.}logger.debug { "${1:message}" }$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet loge "logger.error"
|
|
||||||
logger.error { "${1:message}" }$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet logf "logger.fatal"
|
|
||||||
logger.fatal { "${1:message}" }$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet logi "logger.info"
|
|
||||||
logger.info { "${1:message}" }$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet logw "logger.warn"
|
|
||||||
logger.warn { "${1:message}" }$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mp "map(&:sym_proc)"
|
|
||||||
map(&:${1:id})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mapca "map.catch_all"
|
|
||||||
${1:map}.catch_all "*${2:anything}", :controller => "${3:default}", :action => "${4:error}"
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet map "map.named_route"
|
|
||||||
${1:map}.${2:connect} '${3::controller/:action/:id}'
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mapr "map.resource"
|
|
||||||
${1:map}.resource :${2:resource}${10: do |${11:$2}|
|
|
||||||
$0
|
|
||||||
end}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet maprs "map.resources"
|
|
||||||
${1:map}.resources :${2:resource}${10: do |${11:$2}|
|
|
||||||
$0
|
|
||||||
end}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mapwo "map.with_options"
|
|
||||||
${1:map}.with_options :${2:controller} => '${3:thing}' do |${4:$3}|
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mrw "mattr_accessor"
|
|
||||||
mattr_accessor :${0:attr_names}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ncl "named_scope lambda"
|
|
||||||
named_scope :name, lambda { |${1:param}| { :conditions => ${3:['${4:${5:field} = ?}', ${6:$1}]} } }
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet nc "named_scope"
|
|
||||||
named_scope :name${1:, :joins => :${2:table}}, :conditions => ${3:['${4:${5:field} = ?}', ${6:true}]}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet dscope "default_scope"
|
|
||||||
default_scope ${1:order(${2:'${3:created_at DESC}'})}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet flash "flash[...]"
|
|
||||||
flash[:${1:notice}] = "${2:Successfully created...}"$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rea "redirect_to (action)"
|
|
||||||
redirect_to :action => "${1:index}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet reai "redirect_to (action, id)"
|
|
||||||
redirect_to :action => "${1:show}", :id => ${0:@item}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rec "redirect_to (controller)"
|
|
||||||
redirect_to :controller => "${1:items}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet reca "redirect_to (controller, action)"
|
|
||||||
redirect_to :controller => "${1:items}", :action => "${2:list}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet recai "redirect_to (controller, action, id)"
|
|
||||||
redirect_to :controller => "${1:items}", :action => "${2:show}", :id => ${0:@item}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet renpp "redirect_to (nested path plural)"
|
|
||||||
redirect_to(${2:${10:parent}_${11:child}_path(${12:@}${13:${10}})})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet renp "redirect_to (nested path)"
|
|
||||||
redirect_to(${2:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet repp "redirect_to (path plural)"
|
|
||||||
redirect_to(${2:${10:model}s_path})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rep "redirect_to (path)"
|
|
||||||
redirect_to(${2:${12:model}_path(${13:@}${14:${12}})})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet reb "redirect_to :back"
|
|
||||||
redirect_to :back
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ra "render (action)... (ra)"
|
|
||||||
render :action => "${1:action}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ral "render (action,layout) (ral)"
|
|
||||||
render :action => "${1:action}", :layout => "${2:layoutname}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rf "render (file) (rf)"
|
|
||||||
render :file => "${1:filepath}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rfu "render (file,use_full_path) (rfu)"
|
|
||||||
render :file => "${1:filepath}", :use_full_path => ${2:false}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ri "render (inline) (ri)"
|
|
||||||
render :inline => "${1:<%= 'hello' %>}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ril "render (inline,locals) (ril)"
|
|
||||||
render :inline => "${1:<%= 'hello' %>}", :locals => { ${2::name} => "${3:value}"$4 }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rit "render (inline,type) (rit)"
|
|
||||||
render :inline => "${1:<%= 'hello' %>}", :type => ${2::rxml}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rl "render (layout) (rl)"
|
|
||||||
render :layout => "${1:layoutname}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rn "render (nothing) (rn)"
|
|
||||||
render :nothing => ${1:true}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rns "render (nothing,status) (rns)"
|
|
||||||
render :nothing => ${1:true}, :status => ${2:401}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rt "render (text) (rt)"
|
|
||||||
render :text => "${1:text to render...}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rtl "render (text,layout) (rtl)"
|
|
||||||
render :text => "${1:text to render...}", :layout => "${2:layoutname}"
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rtlt "render (text,layout => true) (rtlt)"
|
|
||||||
render :text => "${1:text to render...}", :layout => ${2:true}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rts "render (text,status) (rts)"
|
|
||||||
render :text => "${1:text to render...}", :status => ${2:401}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ru "render (update)"
|
|
||||||
render :update do |${2:page}|
|
|
||||||
$2.$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet rest "respond_to"
|
|
||||||
respond_to do |wants|
|
|
||||||
wants.${1:html}${2: { $0 \}}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet resw "respond_with"
|
|
||||||
respond_with(${1:@${2:model}})${3: do |format|
|
|
||||||
format.${4:html} { $0 \}
|
|
||||||
end}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# FIXME
|
|
||||||
snippet returning "returning do |variable| ... end"
|
|
||||||
returning ${1:variable} do${2/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1: |)/}${2:v}${2/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:|)/}
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.binary (tcbi)"
|
|
||||||
t.binary :${1:title}${2:, :limit => ${3:2}.megabytes}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.boolean (tcb)"
|
|
||||||
t.boolean :${1:title}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.date (tcda)"
|
|
||||||
t.date :${1:title}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.datetime (tcdt)"
|
|
||||||
t.datetime :${1:title}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.decimal (tcd)"
|
|
||||||
t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.float (tcf)"
|
|
||||||
t.float :${1:title}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.integer (tci)"
|
|
||||||
t.integer :${1:title}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.lock_version (tcl)"
|
|
||||||
t.integer :lock_version, :null => false, :default => 0
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.references (tcr)"
|
|
||||||
t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.rename (tre)"
|
|
||||||
t.rename(:${1:old_column_name}, :${2:new_column_name})
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.string (tcs)"
|
|
||||||
t.string :${1:title}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.text (tct)"
|
|
||||||
t.text :${1:title}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.time (tcti)"
|
|
||||||
t.time :${1:title}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.timestamp (tcts)"
|
|
||||||
t.timestamp :${1:title}
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t. "t.timestamps (tctss)"
|
|
||||||
t.timestamps
|
|
||||||
t.$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vaoif "validates_acceptance_of if"
|
|
||||||
validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}}, :if => proc { |obj| ${7:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vao "validates_acceptance_of"
|
|
||||||
validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet va "validates_associated (va)"
|
|
||||||
validates_associated :${1:attribute}${2:, :on => :${3:create}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vaif "validates_associated if (vaif)"
|
|
||||||
validates_associated :${1:attribute}${2:, :on => :${3:create}, :if => proc { |obj| ${5:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vc "validates_confirmation_of (vc)"
|
|
||||||
validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vcif "validates_confirmation_of if (vcif)"
|
|
||||||
validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}", :if => proc { |obj| ${5:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ve "validates_exclusion_of (ve)"
|
|
||||||
validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet veif "validates_exclusion_of if (veif)"
|
|
||||||
validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"}, :if => proc { |obj| ${7:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vfif "validates_format_of if"
|
|
||||||
validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"}, :if => proc { |obj| ${7:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vf "validates_format_of"
|
|
||||||
validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet viif "validates_inclusion_of if"
|
|
||||||
validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"}, :if => proc { |obj| ${7:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vi "validates_inclusion_of"
|
|
||||||
validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vl "validates_length_of (vl)"
|
|
||||||
validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vlif "validates_length_of if"
|
|
||||||
validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"}, :if => proc { |obj| ${6:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vnif "validates_numericality_of if"
|
|
||||||
validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"}, :if => proc { |obj| ${5:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vn "validates_numericality_of"
|
|
||||||
validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vp "validates_presence_of (vp)"
|
|
||||||
validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vpif "validates_presence_of if (vpif) 2"
|
|
||||||
validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"}, :if => proc { |obj| ${5:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vu "validates_uniqueness_of (vu)"
|
|
||||||
validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vuif "validates_uniqueness_of if (vuif)"
|
|
||||||
validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}", :if => proc { |obj| ${6:obj.condition?} }}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet verify "verify -- render"
|
|
||||||
verify :only => [:$1], :method => :post, :render => {:status => 500, :text => "use HTTP-POST"}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet verify "verify -- redirect"
|
|
||||||
verify :only => [:$1], :session => :user, :params => :id, :redirect_to => {:action => '${2:index}'}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wants "wants_format"
|
|
||||||
wants.${1:js|xml|html}${2: { $0 \}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet xdelete "xhr delete"
|
|
||||||
xhr :delete, :${1:destroy}, :id => ${2:1}$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet xget "xhr get"
|
|
||||||
xhr :get, :${1:show}${2:, :id => ${3:1}}$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet xpost "xhr post"
|
|
||||||
xhr :post, :${1:create}, :${2:object} => { $3 }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet xput "xhr put"
|
|
||||||
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { $4 }$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet finl "find(:last)"
|
|
||||||
find(:last${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sweeper "Create sweeper class"
|
|
||||||
class ${1:Model}Sweeper < ActionController::Caching::Sweeper
|
|
||||||
observe ${1:Model}
|
|
||||||
|
|
||||||
def after_save(${1/./\l$0/})
|
|
||||||
expire_cache(${1/./\l$0/})
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_destroy(${1/./\l$0/})
|
|
||||||
expire_cache(${1/./\l$0/})
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def expire_cache(${1/./\l$0/})
|
|
||||||
${0:expire_page ${1/./\l$0/}s_path
|
|
||||||
expire_page ${1/./\l$0/}_path(${1/./\l$0/})}
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet col "collection routes"
|
|
||||||
collection do
|
|
||||||
${1:get :${2:action}}
|
|
||||||
${3:put :${4:action}}
|
|
||||||
${5:post :${6:action}}
|
|
||||||
${7:delete :${8:action}}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet format "format (respond_with)"
|
|
||||||
format.${1:html|xml|json|js|any} { $0 }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet gem "gem"
|
|
||||||
gem '${1:name}'${2:${3:, "${4:1.0}"}${5:${6:, :require => ${7:"${8:$1}"}}${9:, :group => :${10:test}}}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet gemg "gem :git"
|
|
||||||
gem '${1:paperclip}', :git => "${2:git://github.com/thoughtbot/paperclip.git}"${3:, :branch => "${4:rails3}"}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet match "match"
|
|
||||||
match '${1:${2::controller}${3:/${4::action}${5:/${6::id}${7:(.:format)}}}}'${8: => '${9:$2}#${10:$4}'${11:, :as => :${12:$10}}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet member "member routes"
|
|
||||||
member do
|
|
||||||
${1:get :${2:action}}
|
|
||||||
${3:put :${4:action}}
|
|
||||||
${5:post :${6:action}}
|
|
||||||
${7:delete :${8:action}}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet res "resources"
|
|
||||||
resources :${1:posts}${2: do
|
|
||||||
$3
|
|
||||||
end}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet scope "scope"
|
|
||||||
scope :${1:name}, ${2:joins(:${3:table}).}where(${4:'${5:$3.${6:field}} = ?', ${7:'${8:value}'}})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet scopel "scope lambda"
|
|
||||||
scope :${1:name}, lambda { |${2:param}| ${3:where(${4::${5:field} => ${6:"${7:value}"}})} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet scopee "scope with extension"
|
|
||||||
scope :${1:name}, ${2:where(${3::${4:field} => ${5:'${6:value}'}})} do
|
|
||||||
def ${7:method_name}
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sb "scoped_by"
|
|
||||||
scoped_by_${1:attribute}(${2:id})
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet setup "setup do..end"
|
|
||||||
setup do
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet trans "Translation snippet"
|
|
||||||
I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}${3}', :default => "${1:some_text}"${4})${5:$0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet route_spec
|
|
||||||
it 'routes to #${1:action}' do
|
|
||||||
${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})${6}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,61 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# General Stuff #
|
|
||||||
###########################################################################
|
|
||||||
snippet part "Part" b
|
|
||||||
`!p snip.rv = len(t[1])*'#'`
|
|
||||||
${1:Part name}
|
|
||||||
`!p snip.rv = len(t[1])*'#'`
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sec "Section" b
|
|
||||||
${1:Section name}
|
|
||||||
`!p snip.rv = len(t[1])*'='`
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ssec "Subsection" b
|
|
||||||
${1:Section name}
|
|
||||||
`!p snip.rv = len(t[1])*'-'`
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sssec "Subsubsection" b
|
|
||||||
${1:Section name}
|
|
||||||
`!p snip.rv = len(t[1])*'^'`
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet chap "Chapter" b
|
|
||||||
`!p snip.rv = len(t[1])*'*'`
|
|
||||||
${1:Chapter name}
|
|
||||||
`!p snip.rv = len(t[1])*'*'`
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet para "Paragraph" b
|
|
||||||
${1:Paragraph name}
|
|
||||||
`!p snip.rv = len(t[1])*'"'`
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# More Specialized Stuff. #
|
|
||||||
###########################################################################
|
|
||||||
snippet cb "Code Block" b
|
|
||||||
.. code-block:: ${1:lua}
|
|
||||||
|
|
||||||
${2:code}
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,570 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
snippet "^#!" "#!/usr/bin/env ruby" r
|
|
||||||
#!/usr/bin/env ruby
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet "^# ?[uU][tT][fF]-?8" "# encoding: UTF-8" r
|
|
||||||
# encoding: UTF-8
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet If "<command> if <expression>"
|
|
||||||
${1:command} if ${0:expression}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Unless "<command> unless <expression>"
|
|
||||||
${1:command} unless ${0:expression}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet if "if <condition> ... end"
|
|
||||||
if ${1:condition}
|
|
||||||
${2:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet ife "if <condition> ... else ... end"
|
|
||||||
if ${1:condition}
|
|
||||||
${2:# TODO}
|
|
||||||
else
|
|
||||||
${3:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet ifee "if <condition> ... elseif <condition> ... else ... end"
|
|
||||||
if ${1:condition}
|
|
||||||
${2:# TODO}
|
|
||||||
elsif ${3:condition}
|
|
||||||
${4:# TODO}
|
|
||||||
else
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet unless "unless <condition> ... end"
|
|
||||||
unless ${1:condition}
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet unlesse "unless <condition> ... else ... end"
|
|
||||||
unless ${1:condition}
|
|
||||||
${2:# TODO}
|
|
||||||
else
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet unlesee "unless <condition> ... elseif <condition> ... else ... end"
|
|
||||||
unless ${1:condition}
|
|
||||||
${2:# TODO}
|
|
||||||
elsif ${3:condition}
|
|
||||||
${4:# TODO}
|
|
||||||
else
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "\b(de)?f" "def <name>..." r
|
|
||||||
def ${1:function_name}${2: ${3:*args}}
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet defi "def initialize ..."
|
|
||||||
def initialize${1: ${2:*args}}
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet defr "def <name> ... rescue ..."
|
|
||||||
def ${1:function_name}${2: ${3:*args}}
|
|
||||||
${4:# TODO}
|
|
||||||
rescue
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet For "(<from>..<to>).each { |<i>| <block> }"
|
|
||||||
(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet for "(<from>..<to>).each do |<i>| <block> end"
|
|
||||||
(${1:from}..${2:to}).each do |${3:i}|
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Merge!" ".merge!(<other_hash>) { |<key>,<oldval>,<newval>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) { |${2:key},${3:oldval},${4:newval}| ${5:block} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.merge!" ".merge!(<other_hash>) do |<key>,<oldval>,<newval>| <block> end" r
|
|
||||||
`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) do |${2:key},${3:oldval},${4:newval}|
|
|
||||||
${0:block}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} }
|
|
||||||
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}
|
|
||||||
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} }
|
|
||||||
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}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} }
|
|
||||||
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}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Select" ".select { |<item>| <block>}" r
|
|
||||||
`!p snip.rv=match.group(1)`.select { |${1:item}| ${2:block} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.select" ".select do |<item>| <block> end" r
|
|
||||||
`!p snip.rv=match.group(1)`.select do |${1:item}|
|
|
||||||
${0:block}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} }
|
|
||||||
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}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} }
|
|
||||||
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}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} }
|
|
||||||
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}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Each "<elements>.each { |<element>| <block> }"
|
|
||||||
${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet each "<elements>.each do |<element>| <block> end"
|
|
||||||
${1:elements}.each do |${2:${1/s$//}}|
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "each_?s(lice)?" "<array>.each_slice(n) do |slice| <block> end" r
|
|
||||||
${1:elements}.each_slice(${2:2}) do |${3:slice}|
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "Each_?s(lice)?" "<array>.each_slice(n) { |slice| <block> }" r
|
|
||||||
${1:elements}.each_slice(${2:2}) { |${3:slice}| ${0:# TODO} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Map" ".map { |<element>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.map { |${1:`!p
|
|
||||||
element_name = match.group(1).lstrip('$@')
|
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
|
||||||
try:
|
|
||||||
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
|
||||||
snip.rv = wmatch.group(1).lower()
|
|
||||||
except:
|
|
||||||
snip.rv = 'element'
|
|
||||||
`}| ${2:# TODO} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.map" ".map do |<element>| <block> end" r
|
|
||||||
`!p snip.rv=match.group(1)`.map do |${1:`!p
|
|
||||||
element_name = match.group(1).lstrip('$@')
|
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
|
||||||
try:
|
|
||||||
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
|
||||||
snip.rv = wmatch.group(1).lower()
|
|
||||||
except:
|
|
||||||
snip.rv = 'element'
|
|
||||||
`}|
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Rev(erse)?_?each" ".reverse_each { |<element>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.reverse_each { |${1:`!p
|
|
||||||
element_name = match.group(1).lstrip('$@')
|
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
|
||||||
try:
|
|
||||||
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
|
||||||
snip.rv = wmatch.group(1).lower()
|
|
||||||
except:
|
|
||||||
snip.rv = 'element'
|
|
||||||
`}| ${2:# TODO} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.rev(erse)?_?each" ".reverse_each do |<element>| <block> end" r
|
|
||||||
`!p snip.rv=match.group(1)`.reverse_each do |${1:`!p
|
|
||||||
element_name = match.group(1).lstrip('$@')
|
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
|
||||||
try:
|
|
||||||
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
|
||||||
snip.rv = wmatch.group(1).lower()
|
|
||||||
except:
|
|
||||||
snip.rv = 'element'
|
|
||||||
`}|
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Each" ".each { |<element>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.each { |${1:`!p
|
|
||||||
element_name = match.group(1).lstrip('$@')
|
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
|
||||||
try:
|
|
||||||
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
|
||||||
snip.rv = wmatch.group(1).lower()
|
|
||||||
except:
|
|
||||||
snip.rv = 'element'
|
|
||||||
`}| ${2:# TODO} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.each" ".each do |<element>| <block> end" r
|
|
||||||
`!p snip.rv=match.group(1)`.each do |${1:`!p
|
|
||||||
element_name = match.group(1).lstrip('$@')
|
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
|
||||||
try:
|
|
||||||
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
|
||||||
snip.rv = wmatch.group(1).lower()
|
|
||||||
except:
|
|
||||||
snip.rv = 'element'
|
|
||||||
`}|
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Each_?w(ith)?_?i(ndex)?" ".each_with_index { |<element>,<i>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.each_with_index { |${1:`!p
|
|
||||||
element_name = match.group(1).lstrip('$@')
|
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
|
||||||
try:
|
|
||||||
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
|
||||||
snip.rv = wmatch.group(1).lower()
|
|
||||||
except:
|
|
||||||
snip.rv = 'element'
|
|
||||||
`},${2:i}| ${3:# TODO} }$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.each_?w(ith)?_?i(ndex)?" ".each_with_index do |<element>,<i>| <block> end" r
|
|
||||||
`!p snip.rv=match.group(1)`.each_with_index do |${1:`!p
|
|
||||||
element_name = match.group(1).lstrip('$@')
|
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
|
||||||
try:
|
|
||||||
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
|
||||||
snip.rv = wmatch.group(1).lower()
|
|
||||||
except:
|
|
||||||
snip.rv = 'element'
|
|
||||||
`},${2:i}|
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} }
|
|
||||||
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}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.sub" ".sub(<expression>) { <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"replace_with"} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.gsub" ".gsub(<expression>) { <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"replace_with"} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.index" ".index { |item| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.index { |${1:item}| ${2:block} }
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Index" ".index do |item| ... end" r
|
|
||||||
`!p snip.rv=match.group(1)`.index do |${1:item}|
|
|
||||||
${0:block}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet do "do |<key>| ... end" i
|
|
||||||
do |${1:args}|
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Do "do ... end" i
|
|
||||||
do
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
snippet until "until <expression> ... end"
|
|
||||||
until ${1:expression}
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Until "begin ... end until <expression>"
|
|
||||||
begin
|
|
||||||
${0:# TODO}
|
|
||||||
end until ${1:expression}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet while "while <expression> ... end"
|
|
||||||
while ${1:expression}
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet While "begin ... end while <expression>"
|
|
||||||
begin
|
|
||||||
${0:# TODO}
|
|
||||||
end while ${1:expression}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "\b(r|attr)" "attr_reader :<attr_names>" r
|
|
||||||
attr_reader :${0:attr_names}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "\b(w|attr)" "attr_writer :<attr_names>" r
|
|
||||||
attr_writer :${0:attr_names}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "\b(rw|attr)" "attr_accessor :<attr_names>" r
|
|
||||||
attr_accessor :${0:attr_names}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet begin "begin ... rescue ... end"
|
|
||||||
begin
|
|
||||||
${1:# TODO}
|
|
||||||
rescue
|
|
||||||
${0:# TODO}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet begin "begin ... rescue ... else ... ensure ... end"
|
|
||||||
begin
|
|
||||||
${1:# Raise exception}
|
|
||||||
rescue Exception => e
|
|
||||||
puts e.message
|
|
||||||
puts e.backtrace.inspect
|
|
||||||
${2:# Rescue}
|
|
||||||
else
|
|
||||||
${3:# other exception}
|
|
||||||
ensure
|
|
||||||
${0:# always excute}
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet rescue
|
|
||||||
rescue Exception => e
|
|
||||||
puts e.message
|
|
||||||
puts e.backtrace.inspect
|
|
||||||
${0:# Rescue}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "\b(case|sw(itch)?)" "case <variable> when <expression> ... end" r
|
|
||||||
case ${1:variable}
|
|
||||||
when ${2:expression}
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet alias "alias :<new_name> :<old_name>"
|
|
||||||
alias :${1:new_name} :${2:old_name}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet class "class <class_name> def initialize ... end end"
|
|
||||||
class ${1:class_name}
|
|
||||||
def initialize ${2:*args}
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet module "module"
|
|
||||||
module ${1:module_name}
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet ###
|
|
||||||
=begin
|
|
||||||
$0
|
|
||||||
=end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2 expandtab:
|
|
@ -1,55 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
snippet /@?imp/ "@import '...';" br
|
|
||||||
@import '${1:file}';
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /@?inc/ "@include mixin(...);" br
|
|
||||||
@include ${1:mixin}(${2:arguments});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /@?ext?/ "@extend %placeholder;" br
|
|
||||||
@extend %${1:placeholder};
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /@?mixin/ "@mixin (...) { ... }" br
|
|
||||||
@mixin ${1:name}(${2:arguments}) {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /@?fun/ "@function (...) { ... }" br
|
|
||||||
@function ${1:name}(${2:arguments}) {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /@?if/ "@if (...) { ... }" br
|
|
||||||
@if ${1:condition} {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /(} )?@?else/ "@else { ... }" br
|
|
||||||
@else ${1:condition} {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /@?for/ "@for loop" br
|
|
||||||
@for ${1:$i} from ${2:1} through ${3:3} {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /@?each/ "@each loop" br
|
|
||||||
@each ${1:$item} in ${2:item, item, item} {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet /@?while/ "@while loop" br
|
|
||||||
@while ${1:$i} ${2:>} ${3:0} {
|
|
||||||
${VISUAL}$0
|
|
||||||
}
|
|
||||||
endsnippet
|
|
@ -1,92 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
global !p
|
|
||||||
import vim
|
|
||||||
|
|
||||||
# Tests for the existence of a variable declared by Vim's filetype detection
|
|
||||||
# suggesting the type of shell script of the current file
|
|
||||||
def testShell(scope, shell):
|
|
||||||
return vim.eval("exists('" + scope + ":is_" + shell + "')")
|
|
||||||
|
|
||||||
# Loops over the possible variables, checking for global variables
|
|
||||||
# first since they indicate an override by the user.
|
|
||||||
def getShell():
|
|
||||||
for scope in ["g", "b"]:
|
|
||||||
for shell in ["bash", "posix", "sh", "kornshell"]:
|
|
||||||
if testShell(scope, shell) == "1":
|
|
||||||
if shell == "kornshell":
|
|
||||||
return "ksh"
|
|
||||||
if shell == "posix":
|
|
||||||
return "sh"
|
|
||||||
return shell
|
|
||||||
return "sh"
|
|
||||||
endglobal
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# TextMate Snippets #
|
|
||||||
###########################################################################
|
|
||||||
snippet #!
|
|
||||||
`!p snip.rv = '#!/bin/' + getShell() + "\n\n" `
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet !env "#!/usr/bin/env (!env)"
|
|
||||||
`!p snip.rv = '#!/usr/bin/env ' + getShell() + "\n\n" `
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet temp "Tempfile"
|
|
||||||
${1:TMPFILE}="$(mktemp -t ${2:`!p
|
|
||||||
snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled"
|
|
||||||
`})"
|
|
||||||
${3:${4/(.+)/trap "/}${4:rm -f '$${1/.*\s//}'}${4/(.+)/" 0 # EXIT\n/}${5/(.+)/trap "/}${5:rm -f '$${1/.*\s//}'; exit 1}${5/(.+)/" 2 # INT\n/}${6/(.+)/trap "/}${6:rm -f '$${1/.*\s//}'; exit 1}${6/(.+)/" 1 15 # HUP TERM\n/}}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet case "case .. esac (case)"
|
|
||||||
case ${1:word} in
|
|
||||||
${2:pattern} )
|
|
||||||
$0;;
|
|
||||||
esac
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet elif "elif .. (elif)"
|
|
||||||
elif ${2:[[ ${1:condition} ]]}; then
|
|
||||||
${0:#statements}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for "for ... done (for)"
|
|
||||||
for (( i = 0; i < ${1:10}; i++ )); do
|
|
||||||
${0:#statements}
|
|
||||||
done
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet forin "for ... in ... done (forin)"
|
|
||||||
for ${1:i}${2/.+/ in /}${2:words}; do
|
|
||||||
${0:#statements}
|
|
||||||
done
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet here "here document (here)"
|
|
||||||
<<-${2:'${1:TOKEN}'}
|
|
||||||
$0
|
|
||||||
${1/['"`](.+)['"`]/$1/}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if ... then (if)"
|
|
||||||
if ${2:[[ ${1:condition} ]]}; then
|
|
||||||
${0:#statements}
|
|
||||||
fi
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet until "until ... (done)"
|
|
||||||
until ${2:[[ ${1:condition} ]]}; do
|
|
||||||
${0:#statements}
|
|
||||||
done
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet while "while ... (done)"
|
|
||||||
while ${2:[[ ${1:condition} ]]}; do
|
|
||||||
${0:#statements}
|
|
||||||
done
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,21 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
# We use a little hack so that the snippet is expanded
|
|
||||||
# and parsed correctly
|
|
||||||
snippet snip "Snippet definition" b
|
|
||||||
`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b}
|
|
||||||
$0
|
|
||||||
`!p snip.rv = "endsnippet"`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet global "Global snippet" b
|
|
||||||
`!p snip.rv = "global"` !p
|
|
||||||
$0
|
|
||||||
`!p snip.rv = "endglobal"`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet vis "${VISUAL}" i
|
|
||||||
\$\{VISUAL${1:${2:default}${3:/transform/}}\}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,52 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# TEXTMATE SNIPPETS #
|
|
||||||
###########################################################################
|
|
||||||
snippet for "for... (for)" b
|
|
||||||
for {${1:set i 0}} {${2:\$i < \$n}} {${3:incr i}} {
|
|
||||||
${4}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet foreach "foreach... (foreach)"
|
|
||||||
foreach ${1:var} ${2:\$list} {
|
|
||||||
${3}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if "if... (if)" b
|
|
||||||
if {${1:condition}} {
|
|
||||||
${2}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet proc "proc... (proc)" b
|
|
||||||
proc ${1:name} {${2:args}} \
|
|
||||||
{
|
|
||||||
${3}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet switch "switch... (switch)" b
|
|
||||||
switch ${1:-exact} -- ${2:\$var} {
|
|
||||||
${3:match} {
|
|
||||||
${4}
|
|
||||||
}
|
|
||||||
default {${5}}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet while "while... (while)" b
|
|
||||||
while {${1:condition}} {
|
|
||||||
${2}
|
|
||||||
}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,110 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
extends texmath
|
|
||||||
|
|
||||||
snippet "b(egin)?" "begin{} / end{}" br
|
|
||||||
\begin{${1:something}}
|
|
||||||
${0:${VISUAL}}
|
|
||||||
\end{$1}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet tab
|
|
||||||
\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}}
|
|
||||||
$0${2/((?<=.)c|l|r)|./(?1: & )/g}
|
|
||||||
\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fig "Figure environment" b
|
|
||||||
\begin{figure}${2:[htpb]}
|
|
||||||
\centering
|
|
||||||
\includegraphics[width=${3:0.8}\linewidth]{${4:name.ext}}
|
|
||||||
\caption{${4/(\w+)\.\w+/\u$1/}$0}
|
|
||||||
\label{fig:${4/(\w+)\.\w+/$1/}}
|
|
||||||
\end{figure}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet enum "Enumerate" b
|
|
||||||
\begin{enumerate}
|
|
||||||
\item $0
|
|
||||||
\end{enumerate}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet item "Itemize" b
|
|
||||||
\begin{itemize}
|
|
||||||
\item $0
|
|
||||||
\end{itemize}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet desc "Description" b
|
|
||||||
\begin{description}
|
|
||||||
\item[$1] $0
|
|
||||||
\end{description}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet it "Individual item" b
|
|
||||||
\item ${1}
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet part "Part" b
|
|
||||||
\part{${1:part name}}
|
|
||||||
\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}}
|
|
||||||
|
|
||||||
${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet cha "Chapter" b
|
|
||||||
\chapter{${1:chapter name}}
|
|
||||||
\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
||||||
|
|
||||||
${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sec "Section" b
|
|
||||||
\section{${1:section name}}
|
|
||||||
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
||||||
|
|
||||||
${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sub "Subsection" b
|
|
||||||
\subsection{${1:subsection name}}
|
|
||||||
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
||||||
|
|
||||||
${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ssub "Subsubsection" b
|
|
||||||
\subsubsection{${1:subsubsection name}}
|
|
||||||
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
||||||
|
|
||||||
${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet par "Paragraph" b
|
|
||||||
\paragraph{${1:paragraph name}}
|
|
||||||
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
||||||
|
|
||||||
${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet subp "Subparagraph" b
|
|
||||||
\subparagraph{${1:subparagraph name}}
|
|
||||||
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
||||||
|
|
||||||
${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ni "Non-indented paragraph" b
|
|
||||||
\noindent
|
|
||||||
${0}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet pac "Package" b
|
|
||||||
\usepackage[${1:options}]{${2:package}}$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lp "Long parenthesis"
|
|
||||||
\left(${1:${VISUAL:contents}}\right)$0
|
|
||||||
endsnippet
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,56 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
##############
|
|
||||||
# MATH STUFF #
|
|
||||||
##############
|
|
||||||
snippet eq "Equation" b
|
|
||||||
\begin{equation}
|
|
||||||
$0
|
|
||||||
\end{equation}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet eqnn "Equation without number" b
|
|
||||||
\begin{equation*}
|
|
||||||
$0
|
|
||||||
\end{equation*}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet eqa "Equation array" b
|
|
||||||
\begin{eqnarray}
|
|
||||||
$1 & $2 & $0
|
|
||||||
\end{eqnarray}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet eqann "Equation array without numbers" b
|
|
||||||
\begin{eqnarray*}
|
|
||||||
$1 & $2 & $0
|
|
||||||
\end{eqnarray*}
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
snippet frac "Fraction" w
|
|
||||||
\frac{${1:${VISUAL:nom}}}{${2:denom}}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet mat "Smart Matrix"
|
|
||||||
\begin{${1:p/b/v/V/B/small}matrix}
|
|
||||||
$0
|
|
||||||
\end{$1matrix}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lr( "left( right)" w
|
|
||||||
\left( ${1:${VISUAL}} \right)
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lr| "left| right|" w
|
|
||||||
\left| ${1:${VISUAL}} \right|
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lr{ "left\{ right\}" w
|
|
||||||
\left\\{ ${1:${VISUAL}} \right\\}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet lr[ "left[ right]" w
|
|
||||||
\left[ ${1:${VISUAL}} \right]
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,60 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# SnipMate Snippets #
|
|
||||||
###########################################################################
|
|
||||||
snippet header
|
|
||||||
" File: ${1:`!v expand('%:t')`}
|
|
||||||
" Author: ${2:`!v g:snips_author`}
|
|
||||||
" Description: ${3}
|
|
||||||
${4:" Last Modified: `!v strftime("%B %d, %Y")`}
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet gvar "Global / configuration variable"
|
|
||||||
if !exists("g:${1:MyUltraImportantVar}")
|
|
||||||
let g:$1 = ${2:"${3:<tab>}"}
|
|
||||||
endif
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet guard
|
|
||||||
if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700}
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let $1 = 1${3}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet f
|
|
||||||
fun ${1:function_name}(${2})
|
|
||||||
${3:" code}
|
|
||||||
endf
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet for
|
|
||||||
for ${1:needle} in ${2:haystack}
|
|
||||||
${3:" code}
|
|
||||||
endfor
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet wh
|
|
||||||
while ${1:condition}
|
|
||||||
${2:" code}
|
|
||||||
endw
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet if
|
|
||||||
if ${1:condition}
|
|
||||||
${2:" code}
|
|
||||||
endif
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ife
|
|
||||||
if ${1:condition}
|
|
||||||
${2}
|
|
||||||
else
|
|
||||||
${3}
|
|
||||||
endif
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,3 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
extends html
|
|
@ -1,16 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
snippet xml "XML declaration" b
|
|
||||||
<?xml version="1.0"?>
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet t "Simple tag" b
|
|
||||||
<${1:tag}>
|
|
||||||
${2:content}
|
|
||||||
</${1/([\w:._-]+).*/$1/}>
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ti "Inline tag" b
|
|
||||||
<${1:tag}>${2:content}</${1/([\w:._-]+).*/$1/}>
|
|
||||||
endsnippet
|
|
@ -1,17 +0,0 @@
|
|||||||
priority -50
|
|
||||||
|
|
||||||
extends sh
|
|
||||||
|
|
||||||
priority -49
|
|
||||||
|
|
||||||
snippet #! "shebang" b
|
|
||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet !env "#!/usr/bin/env (!env)" b
|
|
||||||
#!/usr/bin/env zsh
|
|
||||||
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
# vim:ft=snippets:
|
|
@ -1,38 +1,72 @@
|
|||||||
call UltiSnips#variables#WasRun()
|
if exists("b:did_autoload_ultisnips_map_keys") || !exists("g:_uspy")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_autoload_ultisnips_map_keys = 1
|
||||||
|
|
||||||
|
" The trigger used to expand a snippet.
|
||||||
|
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
||||||
|
if !exists("g:UltiSnipsExpandTrigger")
|
||||||
|
let g:UltiSnipsExpandTrigger = "<tab>"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" The trigger used to display all triggers that could possible
|
||||||
|
" match in the current position.
|
||||||
|
if !exists("g:UltiSnipsListSnippets")
|
||||||
|
let g:UltiSnipsListSnippets = "<c-tab>"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" The trigger used to jump forward to the next placeholder.
|
||||||
|
" NOTE: expansion and forward jumping can be the same trigger.
|
||||||
|
if !exists("g:UltiSnipsJumpForwardTrigger")
|
||||||
|
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" The trigger to jump backward inside a snippet
|
||||||
|
if !exists("g:UltiSnipsJumpBackwardTrigger")
|
||||||
|
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Should UltiSnips unmap select mode mappings automagically?
|
||||||
|
if !exists("g:UltiSnipsRemoveSelectModeMappings")
|
||||||
|
let g:UltiSnipsRemoveSelectModeMappings = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
" If UltiSnips should remove Mappings, which should be ignored
|
||||||
|
if !exists("g:UltiSnipsMappingsToIgnore")
|
||||||
|
let g:UltiSnipsMappingsToIgnore = []
|
||||||
|
endif
|
||||||
|
|
||||||
|
" UltiSnipsEdit will use this variable to decide if a new window
|
||||||
|
" is opened when editing. default is "normal", allowed are also
|
||||||
|
" "vertical", "horizontal", and "context".
|
||||||
|
if !exists("g:UltiSnipsEditSplit")
|
||||||
|
let g:UltiSnipsEditSplit = 'normal'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" A list of directory names that are searched for snippets.
|
||||||
|
if !exists("g:UltiSnipsSnippetDirectories")
|
||||||
|
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Enable or Disable snipmate snippet expansion.
|
||||||
|
if !exists("g:UltiSnipsEnableSnipMate")
|
||||||
|
let g:UltiSnipsEnableSnipMate = 1
|
||||||
|
endif
|
||||||
|
|
||||||
function! UltiSnips#map_keys#MapKeys()
|
function! UltiSnips#map_keys#MapKeys()
|
||||||
" Map the keys correctly
|
|
||||||
if g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger
|
if g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger
|
||||||
|
|
||||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippetOrJump()<cr>"
|
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippetOrJump()<cr>"
|
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||||
else
|
else
|
||||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippet()<cr>"
|
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippet()<cr>"
|
||||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippet()<cr>"
|
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippet()<cr>"
|
||||||
endif
|
endif
|
||||||
exec 'xnoremap ' . g:UltiSnipsExpandTrigger. ' :call UltiSnips#SaveLastVisualSelection()<cr>gvs'
|
exec "xnoremap <silent> " . g:UltiSnipsExpandTrigger. " :call UltiSnips#SaveLastVisualSelection()<cr>gvs"
|
||||||
exec "inoremap <silent> " . g:UltiSnipsListSnippets . " <C-R>=UltiSnips#ListSnippets()<cr>"
|
exec "inoremap <silent> " . g:UltiSnipsListSnippets . " <C-R>=UltiSnips#ListSnippets()<cr>"
|
||||||
exec "snoremap <silent> " . g:UltiSnipsListSnippets . " <Esc>:call UltiSnips#ListSnippets()<cr>"
|
exec "snoremap <silent> " . g:UltiSnipsListSnippets . " <Esc>:call UltiSnips#ListSnippets()<cr>"
|
||||||
|
|
||||||
snoremap <silent> <BS> <c-g>c
|
snoremap <silent> <BS> <c-g>c
|
||||||
snoremap <silent> <DEL> <c-g>c
|
snoremap <silent> <DEL> <c-g>c
|
||||||
snoremap <silent> <c-h> <c-g>c
|
snoremap <silent> <c-h> <c-g>c
|
||||||
endf
|
snoremap <c-r> <c-g>"_c<c-r>
|
||||||
|
|
||||||
function! UltiSnips#map_keys#MapInnerKeys()
|
|
||||||
if g:UltiSnipsExpandTrigger != g:UltiSnipsJumpForwardTrigger
|
|
||||||
exec "inoremap <buffer> <silent> " . g:UltiSnipsJumpForwardTrigger . " <C-R>=UltiSnips#JumpForwards()<cr>"
|
|
||||||
exec "snoremap <buffer> <silent> " . g:UltiSnipsJumpForwardTrigger . " <Esc>:call UltiSnips#JumpForwards()<cr>"
|
|
||||||
endif
|
|
||||||
exec "inoremap <buffer> <silent> " . g:UltiSnipsJumpBackwardTrigger . " <C-R>=UltiSnips#JumpBackwards()<cr>"
|
|
||||||
exec "snoremap <buffer> <silent> " . g:UltiSnipsJumpBackwardTrigger . " <Esc>:call UltiSnips#JumpBackwards()<cr>"
|
|
||||||
endf
|
|
||||||
|
|
||||||
function! UltiSnips#map_keys#RestoreInnerKeys()
|
|
||||||
if g:UltiSnipsExpandTrigger != g:UltiSnipsJumpForwardTrigger
|
|
||||||
exec "iunmap <buffer> " . g:UltiSnipsJumpForwardTrigger
|
|
||||||
exec "sunmap <buffer> " . g:UltiSnipsJumpForwardTrigger
|
|
||||||
endif
|
|
||||||
exec "iunmap <buffer> " . g:UltiSnipsJumpBackwardTrigger
|
|
||||||
exec "sunmap <buffer> " . g:UltiSnipsJumpBackwardTrigger
|
|
||||||
endf
|
endf
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
" Kludge to make sure that this file is really run.
|
|
||||||
function! UltiSnips#variables#WasRun()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" The trigger used to expand a snippet.
|
|
||||||
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
|
||||||
if !exists("g:UltiSnipsExpandTrigger")
|
|
||||||
let g:UltiSnipsExpandTrigger = "<tab>"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" The trigger used to display all triggers that could possible
|
|
||||||
" match in the current position.
|
|
||||||
if !exists("g:UltiSnipsListSnippets")
|
|
||||||
let g:UltiSnipsListSnippets = "<c-tab>"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" The trigger used to jump forward to the next placeholder.
|
|
||||||
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
|
||||||
if !exists("g:UltiSnipsJumpForwardTrigger")
|
|
||||||
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" The trigger to jump backward inside a snippet
|
|
||||||
if !exists("g:UltiSnipsJumpBackwardTrigger")
|
|
||||||
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Should UltiSnips unmap select mode mappings automagically?
|
|
||||||
if !exists("g:UltiSnipsRemoveSelectModeMappings")
|
|
||||||
let g:UltiSnipsRemoveSelectModeMappings = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
" If UltiSnips should remove Mappings, which should be ignored
|
|
||||||
if !exists("g:UltiSnipsMappingsToIgnore")
|
|
||||||
let g:UltiSnipsMappingsToIgnore = []
|
|
||||||
endif
|
|
||||||
|
|
||||||
" UltiSnipsEdit will use this variable to decide if a new window
|
|
||||||
" is opened when editing. default is "normal", allowed are also
|
|
||||||
" "vertical", "horizontal"
|
|
||||||
if !exists("g:UltiSnipsEditSplit")
|
|
||||||
let g:UltiSnipsEditSplit = 'normal'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" A list of directory names that are searched for snippets.
|
|
||||||
if !exists("g:UltiSnipsSnippetDirectories")
|
|
||||||
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
|
|
||||||
endif
|
|
@ -0,0 +1,32 @@
|
|||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
let s:source = {
|
||||||
|
\ 'name' : 'ultisnips',
|
||||||
|
\ 'kind' : 'keyword',
|
||||||
|
\ 'mark' : '[US]',
|
||||||
|
\ 'rank' : 8,
|
||||||
|
\ 'matchers' :
|
||||||
|
\ (g:neocomplete#enable_fuzzy_completion ?
|
||||||
|
\ ['matcher_fuzzy'] : ['matcher_head']),
|
||||||
|
\ }
|
||||||
|
|
||||||
|
function! s:source.gather_candidates(context)
|
||||||
|
let suggestions = []
|
||||||
|
let snippets = UltiSnips#SnippetsInCurrentScope()
|
||||||
|
for trigger in keys(snippets)
|
||||||
|
let description = get(snippets, trigger)
|
||||||
|
call add(suggestions, {
|
||||||
|
\ 'word' : trigger,
|
||||||
|
\ 'menu' : self.mark . ' '. description
|
||||||
|
\ })
|
||||||
|
endfor
|
||||||
|
return suggestions
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! neocomplete#sources#ultisnips#define()
|
||||||
|
return s:source
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
unlet s:save_cpo
|
@ -0,0 +1,82 @@
|
|||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
let s:unite_source = {
|
||||||
|
\ 'name': 'ultisnips',
|
||||||
|
\ 'hooks': {},
|
||||||
|
\ 'action_table': {},
|
||||||
|
\ 'syntax' : 'uniteSource__Ultisnips',
|
||||||
|
\ 'default_action': 'expand',
|
||||||
|
\ }
|
||||||
|
|
||||||
|
let s:unite_source.action_table.preview = {
|
||||||
|
\ 'description' : 'ultisnips snippets',
|
||||||
|
\ 'is_quit' : 0,
|
||||||
|
\ }
|
||||||
|
|
||||||
|
function! s:unite_source.hooks.on_syntax(args, context) abort
|
||||||
|
syntax case ignore
|
||||||
|
syntax match uniteSource__UltisnipsHeader /^.*$/
|
||||||
|
\ containedin=uniteSource__Ultisnips
|
||||||
|
syntax match uniteSource__UltisnipsTrigger /\v^\s.{-}\ze\s/ contained
|
||||||
|
\ containedin=uniteSource__UltisnipsHeader
|
||||||
|
\ nextgroup=uniteSource__UltisnipsDescription
|
||||||
|
syntax match uniteSource__UltisnipsDescription /\v.{3}\s\zs\w.*$/ contained
|
||||||
|
\ containedin=uniteSource__UltisnipsHeader
|
||||||
|
|
||||||
|
highlight default link uniteSource__UltisnipsTrigger Identifier
|
||||||
|
highlight default link uniteSource__UltisnipsDescription Statement
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:unite_source.action_table.preview.func(candidate)
|
||||||
|
" no nice preview at this point, cannot get snippet text
|
||||||
|
let snippet_preview = a:candidate['word']
|
||||||
|
echo snippet_preview
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let s:unite_source.action_table.expand = {
|
||||||
|
\ 'description': 'expand the current snippet',
|
||||||
|
\ 'is_quit': 1
|
||||||
|
\}
|
||||||
|
|
||||||
|
function! s:unite_source.action_table.expand.func(candidate)
|
||||||
|
let delCurrWord = (getline(".")[col(".")-1] == " ") ? "" : "diw"
|
||||||
|
exe "normal " . delCurrWord . "a" . a:candidate['trigger'] . " "
|
||||||
|
call UltiSnips#ExpandSnippet()
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:unite_source.get_longest_snippet_len(snippet_list)
|
||||||
|
let longest = 0
|
||||||
|
for snip in items(a:snippet_list)
|
||||||
|
if strlen(snip['word']) > longest
|
||||||
|
let longest = strlen(snip['word'])
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return longest
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:unite_source.gather_candidates(args, context)
|
||||||
|
let default_val = {'word': '', 'unite__abbr': '', 'is_dummy': 0, 'source':
|
||||||
|
\ 'ultisnips', 'unite__is_marked': 0, 'kind': 'command', 'is_matched': 1,
|
||||||
|
\ 'is_multiline': 0}
|
||||||
|
let snippet_list = UltiSnips#SnippetsInCurrentScope()
|
||||||
|
let max_len = s:unite_source.get_longest_snippet_len(snippet_list)
|
||||||
|
let canditates = []
|
||||||
|
for snip in items(snippet_list)
|
||||||
|
let curr_val = copy(default_val)
|
||||||
|
let curr_val['word'] = printf('%-*s', max_len, snip[0]) . " " . snip[1]
|
||||||
|
let curr_val['trigger'] = snip[0]
|
||||||
|
call add(canditates, curr_val)
|
||||||
|
endfor
|
||||||
|
return canditates
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! unite#sources#ultisnips#define()
|
||||||
|
return s:unite_source
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"unlet s:unite_source
|
||||||
|
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
unlet s:save_cpo
|
@ -0,0 +1,3 @@
|
|||||||
|
--langdef=UltiSnips
|
||||||
|
--langmap=UltiSnips:.snippets
|
||||||
|
--regex-UltiSnips=/^snippet (.*)/\1/s,snippet/
|
Binary file not shown.
After Width: | Height: | Size: 1.0 MiB |
@ -1,5 +1,17 @@
|
|||||||
" This has to be called before ftplugins are loaded. Therefore
|
" This has to be called before ftplugins are loaded. Therefore
|
||||||
" it is here in ftdetect though it maybe shouldn't
|
" it is here in ftdetect though it maybe shouldn't
|
||||||
if has("autocmd")
|
|
||||||
|
" This is necessary to prevent errors when using vim as a pager.
|
||||||
|
if exists("vimpager")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
if has("autocmd") && &loadplugins
|
||||||
|
augroup UltiSnipsFileType
|
||||||
|
autocmd!
|
||||||
autocmd FileType * call UltiSnips#FileTypeChanged()
|
autocmd FileType * call UltiSnips#FileTypeChanged()
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" restore 'filetypedetect' group declaration
|
||||||
|
augroup filetypedetect
|
||||||
endif
|
endif
|
||||||
|
@ -1,69 +1,57 @@
|
|||||||
" File: UltiSnips.vim
|
if exists('did_plugin_ultisnips') || &cp
|
||||||
" Author: Holger Rapp <SirVer@gmx.de>
|
finish
|
||||||
" Description: The Ultimate Snippets solution for Vim
|
endif
|
||||||
"
|
let did_plugin_ultisnips=1
|
||||||
" Testing Info:
|
|
||||||
" See directions at the top of the test.py script located one
|
if version < 704
|
||||||
" directory above this file.
|
echohl WarningMsg
|
||||||
|
echom "UltiSnips requires Vim >= 7.4"
|
||||||
|
echohl None
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
if exists('did_UltiSnips_plugin') || &cp || version < 700
|
if !exists("g:UltiSnipsUsePythonVersion")
|
||||||
|
let g:_uspy=":py3 "
|
||||||
|
if !has("python3")
|
||||||
|
if !has("python")
|
||||||
|
if !exists("g:UltiSnipsNoPythonWarning")
|
||||||
|
echohl WarningMsg
|
||||||
|
echom "UltiSnips requires py >= 2.7 or py3"
|
||||||
|
echohl None
|
||||||
|
endif
|
||||||
|
unlet g:_uspy
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let g:_uspy=":py "
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
" Use user-provided value, but check if it's available.
|
||||||
|
" This uses `has()`, because e.g. `exists(":python3")` is always 2.
|
||||||
|
if g:UltiSnipsUsePythonVersion == 2 && has('python')
|
||||||
|
let g:_uspy=":python "
|
||||||
|
elseif g:UltiSnipsUsePythonVersion == 3 && has('python3')
|
||||||
|
let g:_uspy=":python3 "
|
||||||
|
endif
|
||||||
|
if !exists('g:_uspy')
|
||||||
|
echohl WarningMsg
|
||||||
|
echom "UltiSnips: the Python version from g:UltiSnipsUsePythonVersion (".g:UltiSnipsUsePythonVersion.") is not available."
|
||||||
|
echohl None
|
||||||
finish
|
finish
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" The Commands we define.
|
" The Commands we define.
|
||||||
command! -nargs=? -complete=customlist,UltiSnips#FileTypeComplete UltiSnipsEdit
|
command! -bang -nargs=? -complete=customlist,UltiSnips#FileTypeComplete UltiSnipsEdit
|
||||||
\ :call UltiSnips#Edit(<q-args>)
|
\ :call UltiSnips#Edit(<q-bang>, <q-args>)
|
||||||
|
|
||||||
command! -nargs=1 UltiSnipsAddFiletypes :call UltiSnips#AddFiletypes(<q-args>)
|
command! -nargs=1 UltiSnipsAddFiletypes :call UltiSnips#AddFiletypes(<q-args>)
|
||||||
|
|
||||||
" Backwards compatible functions. Prefer the ones in autoload/.
|
augroup UltiSnips_AutoTrigger
|
||||||
function! UltiSnips_FileTypeChanged()
|
au!
|
||||||
echoerr "Deprecated UltiSnips_FileTypeChanged called. Please use UltiSnips#FileTypeChanged." | sleep 1
|
au InsertCharPre * call UltiSnips#TrackChange()
|
||||||
return UltiSnips#FileTypeChanged()
|
au TextChangedI * call UltiSnips#TrackChange()
|
||||||
endfunction
|
augroup END
|
||||||
|
|
||||||
function! UltiSnips_ExpandSnippet()
|
|
||||||
echoerr "Deprecated UltiSnips_ExpandSnippet called. Please use UltiSnips#ExpandSnippet." | sleep 1
|
|
||||||
return UltiSnips#ExpandSnippet()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! UltiSnips_ExpandSnippetOrJump()
|
|
||||||
echoerr "Deprecated UltiSnips_ExpandSnippetOrJump called. Please use UltiSnips#ExpandSnippetOrJump." | sleep 1
|
|
||||||
return UltiSnips#ExpandSnippetOrJump()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! UltiSnips_SnippetsInCurrentScope()
|
|
||||||
echoerr "Deprecated UltiSnips_SnippetsInCurrentScope called. Please use UltiSnips#SnippetsInCurrentScope." | sleep 1
|
|
||||||
return UltiSnips#SnippetsInCurrentScope()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! UltiSnips_JumpBackwards()
|
|
||||||
echoerr "Deprecated UltiSnips_JumpBackwards called. Please use UltiSnips#JumpBackwards." | sleep 1
|
|
||||||
return UltiSnips#JumpBackwards()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! UltiSnips_JumpForwards()
|
|
||||||
echoerr "Deprecated UltiSnips_JumpForwards called. Please use UltiSnips#JumpForwards." | sleep 1
|
|
||||||
return UltiSnips#JumpForwards()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! UltiSnips_AddSnippet(...)
|
|
||||||
echoerr "Deprecated UltiSnips_AddSnippet called. Please use UltiSnips#AddSnippetWithPriority." | sleep 1
|
|
||||||
return call(function('UltiSnips#AddSnippet'), a:000)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! UltiSnips_Anon(...)
|
|
||||||
echoerr "Deprecated UltiSnips_Anon called. Please use UltiSnips#Anon." | sleep 1
|
|
||||||
return call(function('UltiSnips#Anon'), a:000)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
au CursorMovedI * call UltiSnips#CursorMoved()
|
|
||||||
au CursorMoved * call UltiSnips#CursorMoved()
|
|
||||||
au BufLeave * call UltiSnips#LeavingBuffer()
|
|
||||||
au InsertLeave * call UltiSnips#LeavingInsertMode()
|
|
||||||
|
|
||||||
call UltiSnips#map_keys#MapKeys()
|
call UltiSnips#map_keys#MapKeys()
|
||||||
|
|
||||||
let did_UltiSnips_plugin=1
|
|
||||||
|
|
||||||
" vim: ts=8 sts=4 sw=4
|
" vim: ts=8 sts=4 sw=4
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
" File: snipMate_compatibility.vim
|
|
||||||
" Author: Phillip Berndt <phillip.berndt@gmail.com>
|
|
||||||
" Description: Snipmate compatibility helper functions for UltiSnips
|
|
||||||
"
|
|
||||||
" Snipmate defines a function named Filename and a variable called
|
|
||||||
" g:snips_author for use in snippet subtitutions. See
|
|
||||||
" https://github.com/msanders/snipmate.vim/blob/master/doc/snipMate.txt
|
|
||||||
" for details.
|
|
||||||
"
|
|
||||||
|
|
||||||
if exists('did_UltiSnips_snipmate_compatibility')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let did_UltiSnips_snipmate_compatibility = 1
|
|
||||||
|
|
||||||
" Define g:snips_author; some snipmate snippets use this
|
|
||||||
if ! exists('g:snips_author')
|
|
||||||
let g:snips_author = "John Doe"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Filename function, taken from snipMate.vim {{{
|
|
||||||
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
|
|
||||||
" }}}
|
|
||||||
|
|
@ -0,0 +1,224 @@
|
|||||||
|
# coding=utf8
|
||||||
|
|
||||||
|
import vim
|
||||||
|
import UltiSnips._vim
|
||||||
|
from UltiSnips.compatibility import as_unicode, as_vimencoding
|
||||||
|
from UltiSnips.position import Position
|
||||||
|
from UltiSnips._diff import diff
|
||||||
|
from UltiSnips import _vim
|
||||||
|
|
||||||
|
from contextlib import contextmanager
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def use_proxy_buffer(snippets_stack, vstate):
|
||||||
|
"""
|
||||||
|
Forward all changes made in the buffer to the current snippet stack while
|
||||||
|
function call.
|
||||||
|
"""
|
||||||
|
buffer_proxy = VimBufferProxy(snippets_stack, vstate)
|
||||||
|
old_buffer = _vim.buf
|
||||||
|
try:
|
||||||
|
_vim.buf = buffer_proxy
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
_vim.buf = old_buffer
|
||||||
|
buffer_proxy.validate_buffer()
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def suspend_proxy_edits():
|
||||||
|
"""
|
||||||
|
Prevents changes being applied to the snippet stack while function call.
|
||||||
|
"""
|
||||||
|
if not isinstance(_vim.buf, VimBufferProxy):
|
||||||
|
yield
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
_vim.buf._disable_edits()
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
_vim.buf._enable_edits()
|
||||||
|
|
||||||
|
|
||||||
|
class VimBufferProxy(_vim.VimBuffer):
|
||||||
|
"""
|
||||||
|
Proxy object used for tracking changes that made from snippet actions.
|
||||||
|
|
||||||
|
Unfortunately, vim by itself lacks of the API for changing text in
|
||||||
|
trackable maner.
|
||||||
|
|
||||||
|
Vim marks offers limited functionality for tracking line additions and
|
||||||
|
deletions, but nothing offered for tracking changes withing single line.
|
||||||
|
|
||||||
|
Instance of this class is passed to all snippet actions and behaves as
|
||||||
|
internal vim.current.window.buffer.
|
||||||
|
|
||||||
|
All changes that are made by user passed to diff algorithm, and resulting
|
||||||
|
diff applied to internal snippet structures to ensure they are in sync with
|
||||||
|
actual buffer contents.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, snippets_stack, vstate):
|
||||||
|
"""
|
||||||
|
Instantiate new object.
|
||||||
|
|
||||||
|
snippets_stack is a slice of currently active snippets.
|
||||||
|
"""
|
||||||
|
self._snippets_stack = snippets_stack
|
||||||
|
self._buffer = vim.current.buffer
|
||||||
|
self._change_tick = int(vim.eval("b:changedtick"))
|
||||||
|
self._forward_edits = True
|
||||||
|
self._vstate = vstate
|
||||||
|
|
||||||
|
def is_buffer_changed_outside(self):
|
||||||
|
"""
|
||||||
|
Returns true, if buffer was changed without using proxy object, like
|
||||||
|
with vim.command() or through internal vim.current.window.buffer.
|
||||||
|
"""
|
||||||
|
return self._change_tick < int(vim.eval("b:changedtick"))
|
||||||
|
|
||||||
|
def validate_buffer(self):
|
||||||
|
"""
|
||||||
|
Raises exception if buffer is changes beyound proxy object.
|
||||||
|
"""
|
||||||
|
if self.is_buffer_changed_outside():
|
||||||
|
raise RuntimeError('buffer was modified using vim.command or ' +
|
||||||
|
'vim.current.buffer; that changes are untrackable and leads to ' +
|
||||||
|
'errors in snippet expansion; use special variable `snip.buffer` '
|
||||||
|
'for buffer modifications.\n\n' +
|
||||||
|
'See :help UltiSnips-buffer-proxy for more info.')
|
||||||
|
|
||||||
|
def __setitem__(self, key, value):
|
||||||
|
"""
|
||||||
|
Behaves as vim.current.window.buffer.__setitem__ except it tracks
|
||||||
|
changes and applies them to the current snippet stack.
|
||||||
|
"""
|
||||||
|
if isinstance(key, slice):
|
||||||
|
value = [as_vimencoding(line) for line in value]
|
||||||
|
changes = list(self._get_diff(key.start, key.stop, value))
|
||||||
|
self._buffer[key.start:key.stop] = [
|
||||||
|
line.strip('\n') for line in value
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
value = as_vimencoding(value)
|
||||||
|
changes = list(self._get_line_diff(key, self._buffer[key], value))
|
||||||
|
self._buffer[key] = value
|
||||||
|
|
||||||
|
self._change_tick += 1
|
||||||
|
|
||||||
|
if self._forward_edits:
|
||||||
|
for change in changes:
|
||||||
|
self._apply_change(change)
|
||||||
|
if self._snippets_stack:
|
||||||
|
self._vstate.remember_buffer(self._snippets_stack[0])
|
||||||
|
|
||||||
|
def __setslice__(self, i, j, text):
|
||||||
|
"""
|
||||||
|
Same as __setitem__.
|
||||||
|
"""
|
||||||
|
self.__setitem__(slice(i, j), text)
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
"""
|
||||||
|
Just passing call to the vim.current.window.buffer.__getitem__.
|
||||||
|
"""
|
||||||
|
if isinstance(key, slice):
|
||||||
|
return [as_unicode(l) for l in self._buffer[key.start:key.stop]]
|
||||||
|
else:
|
||||||
|
return as_unicode(self._buffer[key])
|
||||||
|
|
||||||
|
def __getslice__(self, i, j):
|
||||||
|
"""
|
||||||
|
Same as __getitem__.
|
||||||
|
"""
|
||||||
|
return self.__getitem__(slice(i, j))
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
"""
|
||||||
|
Same as len(vim.current.window.buffer).
|
||||||
|
"""
|
||||||
|
return len(self._buffer)
|
||||||
|
|
||||||
|
def append(self, line, line_number=-1):
|
||||||
|
"""
|
||||||
|
Same as vim.current.window.buffer.append(), but with tracking changes.
|
||||||
|
"""
|
||||||
|
if line_number < 0:
|
||||||
|
line_number = len(self)
|
||||||
|
if not isinstance(line, list):
|
||||||
|
line = [line]
|
||||||
|
self[line_number:line_number] = [as_vimencoding(l) for l in line]
|
||||||
|
|
||||||
|
def __delitem__(self, key):
|
||||||
|
if isinstance(key, slice):
|
||||||
|
self.__setitem__(key, [])
|
||||||
|
else:
|
||||||
|
self.__setitem__(slice(key, key+1), [])
|
||||||
|
|
||||||
|
def _get_diff(self, start, end, new_value):
|
||||||
|
"""
|
||||||
|
Very fast diffing algorithm when changes are across many lines.
|
||||||
|
"""
|
||||||
|
for line_number in range(start, end):
|
||||||
|
if line_number < 0:
|
||||||
|
line_number = len(self._buffer) + line_number
|
||||||
|
yield ('D', line_number, 0, self._buffer[line_number])
|
||||||
|
|
||||||
|
if start < 0:
|
||||||
|
start = len(self._buffer) + start
|
||||||
|
for line_number in range(0, len(new_value)):
|
||||||
|
yield ('I', start+line_number, 0, new_value[line_number])
|
||||||
|
|
||||||
|
def _get_line_diff(self, line_number, before, after):
|
||||||
|
"""
|
||||||
|
Use precise diffing for tracking changes in single line.
|
||||||
|
"""
|
||||||
|
if before == '':
|
||||||
|
for change in self._get_diff(line_number, line_number+1, [after]):
|
||||||
|
yield change
|
||||||
|
else:
|
||||||
|
for change in diff(before, after):
|
||||||
|
yield (change[0], line_number, change[2], change[3])
|
||||||
|
|
||||||
|
def _apply_change(self, change):
|
||||||
|
"""
|
||||||
|
Apply changeset to current snippets stack, correctly moving around
|
||||||
|
snippet itself or its child.
|
||||||
|
"""
|
||||||
|
if not self._snippets_stack:
|
||||||
|
return
|
||||||
|
|
||||||
|
line_number = change[1]
|
||||||
|
column_number = change[2]
|
||||||
|
line_before = line_number <= self._snippets_stack[0]._start.line
|
||||||
|
column_before = column_number <= self._snippets_stack[0]._start.col
|
||||||
|
if line_before and column_before:
|
||||||
|
direction = 1
|
||||||
|
if change[0] == 'D':
|
||||||
|
direction = -1
|
||||||
|
|
||||||
|
self._snippets_stack[0]._move(
|
||||||
|
Position(line_number, 0),
|
||||||
|
Position(direction, 0)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
if line_number > self._snippets_stack[0]._end.line:
|
||||||
|
return
|
||||||
|
if column_number >= self._snippets_stack[0]._end.col:
|
||||||
|
return
|
||||||
|
self._snippets_stack[0]._do_edit(change)
|
||||||
|
|
||||||
|
def _disable_edits(self):
|
||||||
|
"""
|
||||||
|
Temporary disable applying changes to snippets stack. Should be done
|
||||||
|
while expanding anonymous snippet in the middle of jump to prevent
|
||||||
|
double tracking.
|
||||||
|
"""
|
||||||
|
self._forward_edits = False
|
||||||
|
|
||||||
|
def _enable_edits(self):
|
||||||
|
"""
|
||||||
|
Enables changes forwarding back.
|
||||||
|
"""
|
||||||
|
self._forward_edits = True
|
@ -1,26 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
"""Utilities to deal with text escaping."""
|
|
||||||
|
|
||||||
def unescape(text):
|
|
||||||
"""Removes '\\' escaping from 'text'."""
|
|
||||||
rv = ""
|
|
||||||
i = 0
|
|
||||||
while i < len(text):
|
|
||||||
if i+1 < len(text) and text[i] == '\\':
|
|
||||||
rv += text[i+1]
|
|
||||||
i += 1
|
|
||||||
else:
|
|
||||||
rv += text[i]
|
|
||||||
i += 1
|
|
||||||
return rv
|
|
||||||
|
|
||||||
def fill_in_whitespace(text):
|
|
||||||
"""Returns 'text' with escaped whitespace replaced through whitespaces."""
|
|
||||||
text = text.replace(r"\n", "\n")
|
|
||||||
text = text.replace(r"\t", "\t")
|
|
||||||
text = text.replace(r"\r", "\r")
|
|
||||||
text = text.replace(r"\a", "\a")
|
|
||||||
text = text.replace(r"\b", "\b")
|
|
||||||
return text
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
"""Sources of snippet definitions."""
|
|
||||||
|
|
||||||
# TODO(sirver): these should register themselves with the Manager, so that
|
|
||||||
# other plugins can extend them more easily.
|
|
||||||
from UltiSnips.providers.snippet_file import UltiSnipsFileProvider, \
|
|
||||||
base_snippet_files_for
|
|
||||||
from UltiSnips.providers.added_snippets_provider import AddedSnippetsProvider
|
|
@ -1,43 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
"""Base class for snippet providers."""
|
|
||||||
|
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
from UltiSnips.providers._snippet_dictionary import SnippetDictionary
|
|
||||||
|
|
||||||
class SnippetProvider(object):
|
|
||||||
"""See module docstring."""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self._snippets = defaultdict(SnippetDictionary)
|
|
||||||
|
|
||||||
def get_snippets(self, filetypes, before, possible):
|
|
||||||
"""Returns the snippets for all 'filetypes' (in order) and their
|
|
||||||
parents matching the text 'before'. If 'possible' is true, a partial
|
|
||||||
match is enough."""
|
|
||||||
found_snippets = []
|
|
||||||
for ft in filetypes:
|
|
||||||
found_snippets += self._find_snippets(ft, before, possible)
|
|
||||||
return found_snippets
|
|
||||||
|
|
||||||
def _find_snippets(self, ft, trigger, potentially=False, seen=None):
|
|
||||||
"""Find snippets matching 'trigger' for 'ft'. If 'potentially' is True,
|
|
||||||
partial matches are enough."""
|
|
||||||
snips = self._snippets.get(ft, None)
|
|
||||||
if not snips:
|
|
||||||
return []
|
|
||||||
if not seen:
|
|
||||||
seen = set()
|
|
||||||
seen.add(ft)
|
|
||||||
parent_results = []
|
|
||||||
# TODO(sirver): extends information is not bound to one
|
|
||||||
# provider. It should be tracked further up.
|
|
||||||
for parent_ft in snips.extends:
|
|
||||||
if parent_ft not in seen:
|
|
||||||
seen.add(parent_ft)
|
|
||||||
parent_results += self._find_snippets(parent_ft, trigger,
|
|
||||||
potentially, seen)
|
|
||||||
return parent_results + snips.get_matching_snippets(
|
|
||||||
trigger, potentially)
|
|
@ -1,80 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
"""Implements a container for parsed snippets."""
|
|
||||||
|
|
||||||
import hashlib
|
|
||||||
import os
|
|
||||||
|
|
||||||
def _hash_file(path):
|
|
||||||
"""Returns a hashdigest of 'path'"""
|
|
||||||
if not os.path.isfile(path):
|
|
||||||
return False
|
|
||||||
return hashlib.sha1(open(path, "rb").read()).hexdigest()
|
|
||||||
|
|
||||||
# TODO(sirver): This class should not hash any files nor keep track of extends.
|
|
||||||
class SnippetDictionary(object):
|
|
||||||
"""See module docstring."""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self._added = []
|
|
||||||
self._extends = []
|
|
||||||
self._files = {}
|
|
||||||
self._snippets = []
|
|
||||||
|
|
||||||
def add_snippet(self, snippet, filename):
|
|
||||||
"""Add 'snippet' to this dictionary. If 'filename' is given, also watch
|
|
||||||
the original file for changes."""
|
|
||||||
if filename:
|
|
||||||
self._snippets.append(snippet)
|
|
||||||
if filename not in self.files:
|
|
||||||
self.addfile(filename)
|
|
||||||
else:
|
|
||||||
self._added.append(snippet)
|
|
||||||
|
|
||||||
def get_matching_snippets(self, trigger, potentially):
|
|
||||||
"""Returns all snippets matching the given trigger. If 'potentially' is
|
|
||||||
true, returns all that could_match()."""
|
|
||||||
all_snippets = self._added + self._snippets
|
|
||||||
if not potentially:
|
|
||||||
return [s for s in all_snippets if s.matches(trigger)]
|
|
||||||
else:
|
|
||||||
return [s for s in all_snippets if s.could_match(trigger)]
|
|
||||||
|
|
||||||
def clear_snippets(self, triggers=None):
|
|
||||||
"""Remove all snippets that match each trigger in 'triggers'. When
|
|
||||||
'triggers' is None, empties this dictionary completely."""
|
|
||||||
if triggers is None:
|
|
||||||
triggers = []
|
|
||||||
if triggers:
|
|
||||||
for trigger in triggers:
|
|
||||||
for snippet in self.get_matching_snippets(trigger, False):
|
|
||||||
if snippet in self._snippets:
|
|
||||||
self._snippets.remove(snippet)
|
|
||||||
if snippet in self._added:
|
|
||||||
self._added.remove(snippet)
|
|
||||||
else:
|
|
||||||
self._snippets = []
|
|
||||||
self._added = []
|
|
||||||
|
|
||||||
def addfile(self, path):
|
|
||||||
"""Add this file to the files we read triggers from."""
|
|
||||||
self.files[path] = _hash_file(path)
|
|
||||||
|
|
||||||
def has_any_file_changed(self):
|
|
||||||
"""Returns True if any of our watched files has changed since we read
|
|
||||||
it last."""
|
|
||||||
for path, hash in self.files.items():
|
|
||||||
if not hash or hash != _hash_file(path):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
|
||||||
def files(self):
|
|
||||||
"""All files we have read snippets from."""
|
|
||||||
return self._files
|
|
||||||
|
|
||||||
@property
|
|
||||||
def extends(self):
|
|
||||||
"""The list of filetypes this filetype extends."""
|
|
||||||
return self._extends
|
|
@ -1,152 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
"""Code to provide access to UltiSnips files from disk."""
|
|
||||||
|
|
||||||
import glob
|
|
||||||
import os
|
|
||||||
|
|
||||||
from UltiSnips.providers._base import SnippetProvider
|
|
||||||
from UltiSnips.providers.ultisnips_file import parse_snippets_file
|
|
||||||
from UltiSnips.snippet_definition import SnippetDefinition
|
|
||||||
import UltiSnips._vim as _vim
|
|
||||||
|
|
||||||
def _plugin_dir():
|
|
||||||
"""Calculates the plugin directory for UltiSnips."""
|
|
||||||
directory = __file__
|
|
||||||
for _ in range(10):
|
|
||||||
directory = os.path.dirname(directory)
|
|
||||||
if (os.path.isdir(os.path.join(directory, "plugin")) and
|
|
||||||
os.path.isdir(os.path.join(directory, "doc"))):
|
|
||||||
return directory
|
|
||||||
raise Exception("Unable to find the plugin directory.")
|
|
||||||
|
|
||||||
def base_snippet_files_for(ft, default=True):
|
|
||||||
"""Returns a list of snippet files matching the given filetype (ft).
|
|
||||||
If default is set to false, it doesn't include shipped files.
|
|
||||||
|
|
||||||
Searches through each path in 'runtimepath' in reverse order,
|
|
||||||
in each of these, it searches each directory name listed in
|
|
||||||
'g:UltiSnipsSnippetDirectories' in order, then looks for files in these
|
|
||||||
directories called 'ft.snippets' or '*_ft.snippets' replacing ft with
|
|
||||||
the filetype.
|
|
||||||
"""
|
|
||||||
if _vim.eval("exists('b:UltiSnipsSnippetDirectories')") == "1":
|
|
||||||
snippet_dirs = _vim.eval("b:UltiSnipsSnippetDirectories")
|
|
||||||
else:
|
|
||||||
snippet_dirs = _vim.eval("g:UltiSnipsSnippetDirectories")
|
|
||||||
|
|
||||||
paths = _vim.eval("&runtimepath").split(',')
|
|
||||||
base_snippets = os.path.realpath(os.path.join(_plugin_dir(), "UltiSnips"))
|
|
||||||
ret = []
|
|
||||||
for rtp in paths:
|
|
||||||
for snippet_dir in snippet_dirs:
|
|
||||||
pth = os.path.realpath(os.path.expanduser(
|
|
||||||
os.path.join(rtp, snippet_dir)))
|
|
||||||
patterns = ["%s.snippets", "%s_*.snippets", os.path.join("%s", "*")]
|
|
||||||
if not default and pth == base_snippets:
|
|
||||||
patterns.remove("%s.snippets")
|
|
||||||
|
|
||||||
for pattern in patterns:
|
|
||||||
for fn in glob.glob(os.path.join(pth, pattern % ft)):
|
|
||||||
if fn not in ret:
|
|
||||||
ret.append(fn)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
class SnippetSyntaxError(RuntimeError):
|
|
||||||
"""Thrown when a syntax error is found in a file."""
|
|
||||||
def __init__(self, filename, line_index, msg):
|
|
||||||
RuntimeError.__init__(self, "%s in %s:%d" % (
|
|
||||||
msg, filename, line_index))
|
|
||||||
|
|
||||||
class UltiSnipsFileProvider(SnippetProvider):
|
|
||||||
"""Manages all snippets definitions found in rtp."""
|
|
||||||
|
|
||||||
def get_snippets(self, filetypes, before, possible):
|
|
||||||
for ft in filetypes:
|
|
||||||
self._ensure_loaded(ft)
|
|
||||||
|
|
||||||
return SnippetProvider.get_snippets(self, filetypes, before, possible)
|
|
||||||
|
|
||||||
def _ensure_loaded(self, ft, already_loaded=None):
|
|
||||||
"""Make sure that the snippets for 'ft' and everything it extends are
|
|
||||||
loaded."""
|
|
||||||
if not already_loaded:
|
|
||||||
already_loaded = set()
|
|
||||||
|
|
||||||
if ft in already_loaded:
|
|
||||||
return
|
|
||||||
already_loaded.add(ft)
|
|
||||||
|
|
||||||
if self._needs_update(ft):
|
|
||||||
self._load_snippets_for(ft)
|
|
||||||
|
|
||||||
for parent in self._snippets[ft].extends:
|
|
||||||
self._ensure_loaded(parent, already_loaded)
|
|
||||||
|
|
||||||
def _needs_update(self, ft):
|
|
||||||
"""Returns true if any files for 'ft' have changed and must be
|
|
||||||
reloaded."""
|
|
||||||
if ft not in self._snippets:
|
|
||||||
return True
|
|
||||||
elif self._snippets[ft].has_any_file_changed():
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
cur_snips = set(base_snippet_files_for(ft))
|
|
||||||
old_snips = set(self._snippets[ft].files)
|
|
||||||
if cur_snips - old_snips:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _load_snippets_for(self, ft):
|
|
||||||
"""Load all snippets for the given 'ft'."""
|
|
||||||
if ft in self._snippets:
|
|
||||||
del self._snippets[ft]
|
|
||||||
for fn in base_snippet_files_for(ft):
|
|
||||||
self._parse_snippets(ft, fn)
|
|
||||||
# Now load for the parents
|
|
||||||
for parent_ft in self._snippets[ft].extends:
|
|
||||||
if parent_ft not in self._snippets:
|
|
||||||
self._load_snippets_for(parent_ft)
|
|
||||||
|
|
||||||
def _parse_snippets(self, ft, filename):
|
|
||||||
"""Parse the file 'filename' for the given 'ft' and watch it for
|
|
||||||
changes in the future. 'file_data' can be injected in tests."""
|
|
||||||
current_snippet_priority = 0
|
|
||||||
self._snippets[ft].addfile(filename)
|
|
||||||
file_data = open(filename, "r").read()
|
|
||||||
for event, data in parse_snippets_file(file_data):
|
|
||||||
if event == "error":
|
|
||||||
msg, line_index = data
|
|
||||||
filename = _vim.eval("""fnamemodify(%s, ":~:.")""" %
|
|
||||||
_vim.escape(filename))
|
|
||||||
raise SnippetSyntaxError(filename, line_index, msg)
|
|
||||||
elif event == "clearsnippets":
|
|
||||||
# TODO(sirver): clear snippets should clear for
|
|
||||||
# more providers, not only ultisnips files.
|
|
||||||
triggers, = data
|
|
||||||
self._snippets[ft].clear_snippets(triggers)
|
|
||||||
elif event == "extends":
|
|
||||||
# TODO(sirver): extends information is more global
|
|
||||||
# than one snippet provider.
|
|
||||||
filetypes, = data
|
|
||||||
self._add_extending_info(ft, filetypes)
|
|
||||||
elif event == "snippet":
|
|
||||||
trigger, value, description, options, global_pythons = data
|
|
||||||
self._snippets[ft].add_snippet(
|
|
||||||
SnippetDefinition(current_snippet_priority, trigger, value,
|
|
||||||
description, options, global_pythons), filename
|
|
||||||
)
|
|
||||||
elif event == "priority":
|
|
||||||
priority, = data
|
|
||||||
current_snippet_priority = priority
|
|
||||||
else:
|
|
||||||
assert False, "Unhandled %s: %r" % (event, data)
|
|
||||||
|
|
||||||
def _add_extending_info(self, ft, parents):
|
|
||||||
"""Add the list of 'parents' as being extended by the 'ft'."""
|
|
||||||
sd = self._snippets[ft]
|
|
||||||
for parent in parents:
|
|
||||||
if parent in sd.extends:
|
|
||||||
continue
|
|
||||||
sd.extends.append(parent)
|
|
@ -1,125 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
"""Parsing of snippet files."""
|
|
||||||
|
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
class _LineIterator(object):
|
|
||||||
"""Convenience class that keeps track of line numbers."""
|
|
||||||
|
|
||||||
def __init__(self, text):
|
|
||||||
self._line_index = None
|
|
||||||
self._lines = enumerate(text.splitlines(True), 1)
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __next__(self):
|
|
||||||
"""Returns the next line."""
|
|
||||||
self._line_index, line = next(self._lines)
|
|
||||||
return line
|
|
||||||
next = __next__ # for python2
|
|
||||||
|
|
||||||
@property
|
|
||||||
def line_index(self):
|
|
||||||
"""The 1 based line index in the current file."""
|
|
||||||
return self._line_index
|
|
||||||
|
|
||||||
def _handle_snippet_or_global(line, lines, globals):
|
|
||||||
"""Parses the snippet that begins at the current line."""
|
|
||||||
|
|
||||||
descr = ""
|
|
||||||
opts = ""
|
|
||||||
|
|
||||||
# Ensure this is a snippet
|
|
||||||
snip = line.split()[0]
|
|
||||||
|
|
||||||
# Get and strip options if they exist
|
|
||||||
remain = line[len(snip):].strip()
|
|
||||||
words = remain.split()
|
|
||||||
if len(words) > 2:
|
|
||||||
# second to last word ends with a quote
|
|
||||||
if '"' not in words[-1] and words[-2][-1] == '"':
|
|
||||||
opts = words[-1]
|
|
||||||
remain = remain[:-len(opts) - 1].rstrip()
|
|
||||||
|
|
||||||
# Get and strip description if it exists
|
|
||||||
remain = remain.strip()
|
|
||||||
if len(remain.split()) > 1 and remain[-1] == '"':
|
|
||||||
left = remain[:-1].rfind('"')
|
|
||||||
if left != -1 and left != 0:
|
|
||||||
descr, remain = remain[left:], remain[:left]
|
|
||||||
|
|
||||||
# The rest is the trigger
|
|
||||||
trig = remain.strip()
|
|
||||||
if len(trig.split()) > 1 or "r" in opts:
|
|
||||||
if trig[0] != trig[-1]:
|
|
||||||
return "error", ("Invalid multiword trigger: '%s'" % trig,
|
|
||||||
lines.line_index)
|
|
||||||
trig = trig[1:-1]
|
|
||||||
end = "end" + snip
|
|
||||||
content = ""
|
|
||||||
|
|
||||||
found_end = False
|
|
||||||
for line in lines:
|
|
||||||
if line.rstrip() == end:
|
|
||||||
content = content[:-1] # Chomp the last newline
|
|
||||||
found_end = True
|
|
||||||
break
|
|
||||||
content += line
|
|
||||||
|
|
||||||
if not found_end:
|
|
||||||
return "error", ("Missing 'endsnippet' for %r" % trig, lines.line_index)
|
|
||||||
|
|
||||||
if snip == "global":
|
|
||||||
globals[trig].append(content)
|
|
||||||
elif snip == "snippet":
|
|
||||||
return "snippet", (trig, content, descr, opts, globals)
|
|
||||||
else:
|
|
||||||
return "error", ("Invalid snippet type: '%s'" % snip, lines.line_index)
|
|
||||||
|
|
||||||
def _head_tail(line):
|
|
||||||
"""Returns the first word in 'line' and the rest of 'line' or None if the
|
|
||||||
line is too short."""
|
|
||||||
generator = (t.strip() for t in line.split(None, 1))
|
|
||||||
head = next(generator).strip()
|
|
||||||
tail = ''
|
|
||||||
try:
|
|
||||||
tail = next(generator).strip()
|
|
||||||
except StopIteration:
|
|
||||||
pass
|
|
||||||
return head, tail
|
|
||||||
|
|
||||||
|
|
||||||
def parse_snippets_file(data):
|
|
||||||
"""Parse 'data' assuming it is a snippet file. Yields events in the
|
|
||||||
file."""
|
|
||||||
|
|
||||||
globals = defaultdict(list)
|
|
||||||
lines = _LineIterator(data)
|
|
||||||
for line in lines:
|
|
||||||
if not line.strip():
|
|
||||||
continue
|
|
||||||
|
|
||||||
head, tail = _head_tail(line)
|
|
||||||
if head == "extends":
|
|
||||||
if tail:
|
|
||||||
yield "extends", ([p.strip() for p in tail.split(',')],)
|
|
||||||
else:
|
|
||||||
yield "error", ("'extends' without file types",
|
|
||||||
lines.line_index)
|
|
||||||
elif head in ("snippet", "global"):
|
|
||||||
snippet = _handle_snippet_or_global(line, lines, globals)
|
|
||||||
if snippet is not None:
|
|
||||||
yield snippet
|
|
||||||
elif head == "clearsnippets":
|
|
||||||
yield "clearsnippets", (tail.split(),)
|
|
||||||
elif head == "priority":
|
|
||||||
try:
|
|
||||||
priority = int(tail.split()[0])
|
|
||||||
yield "priority", (priority,)
|
|
||||||
except (ValueError, IndexError):
|
|
||||||
yield "error", ("Invalid priority %r" % tail, lines.line_index)
|
|
||||||
elif head and not head.startswith('#'):
|
|
||||||
yield "error", ("Invalid line %r" % line.rstrip(), lines.line_index)
|
|
@ -0,0 +1 @@
|
|||||||
|
"""Code related to snippets."""
|
@ -0,0 +1,4 @@
|
|||||||
|
"""In memory representation of snippet definitions."""
|
||||||
|
|
||||||
|
from UltiSnips.snippet.definition.ultisnips import UltiSnipsSnippetDefinition
|
||||||
|
from UltiSnips.snippet.definition.snipmate import SnipMateSnippetDefinition
|
@ -0,0 +1,433 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""Snippet representation after parsing."""
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
import vim
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
from UltiSnips import _vim
|
||||||
|
from UltiSnips.compatibility import as_unicode
|
||||||
|
from UltiSnips.indent_util import IndentUtil
|
||||||
|
from UltiSnips.position import Position
|
||||||
|
from UltiSnips.text import escape
|
||||||
|
from UltiSnips.text_objects import SnippetInstance
|
||||||
|
from UltiSnips.text_objects._python_code import SnippetUtilCursor, SnippetUtilForAction
|
||||||
|
|
||||||
|
__WHITESPACE_SPLIT = re.compile(r"\s")
|
||||||
|
def split_at_whitespace(string):
|
||||||
|
"""Like string.split(), but keeps empty words as empty words."""
|
||||||
|
return re.split(__WHITESPACE_SPLIT, string)
|
||||||
|
|
||||||
|
def _words_for_line(trigger, before, num_words=None):
|
||||||
|
"""Gets the final 'num_words' words from 'before'.
|
||||||
|
|
||||||
|
If num_words is None, then use the number of words in 'trigger'.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if num_words is None:
|
||||||
|
num_words = len(split_at_whitespace(trigger))
|
||||||
|
|
||||||
|
word_list = split_at_whitespace(before)
|
||||||
|
if len(word_list) <= num_words:
|
||||||
|
return before.strip()
|
||||||
|
else:
|
||||||
|
before_words = before
|
||||||
|
for i in range(-1, -(num_words + 1), -1):
|
||||||
|
left = before_words.rfind(word_list[i])
|
||||||
|
before_words = before_words[:left]
|
||||||
|
return before[len(before_words):].strip()
|
||||||
|
|
||||||
|
|
||||||
|
class SnippetDefinition(object):
|
||||||
|
|
||||||
|
"""Represents a snippet as parsed from a file."""
|
||||||
|
|
||||||
|
_INDENT = re.compile(r"^[ \t]*")
|
||||||
|
_TABS = re.compile(r"^\t*")
|
||||||
|
|
||||||
|
def __init__(self, priority, trigger, value, description,
|
||||||
|
options, globals, location, context, actions):
|
||||||
|
self._priority = int(priority)
|
||||||
|
self._trigger = as_unicode(trigger)
|
||||||
|
self._value = as_unicode(value)
|
||||||
|
self._description = as_unicode(description)
|
||||||
|
self._opts = options
|
||||||
|
self._matched = ''
|
||||||
|
self._last_re = None
|
||||||
|
self._globals = globals
|
||||||
|
self._location = location
|
||||||
|
self._context_code = context
|
||||||
|
self._context = None
|
||||||
|
self._actions = actions
|
||||||
|
|
||||||
|
# Make sure that we actually match our trigger in case we are
|
||||||
|
# immediately expanded.
|
||||||
|
self.matches(self._trigger)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '_SnippetDefinition(%r,%s,%s,%s)' % (
|
||||||
|
self._priority, self._trigger, self._description, self._opts)
|
||||||
|
|
||||||
|
def _re_match(self, trigger):
|
||||||
|
"""Test if a the current regex trigger matches `trigger`.
|
||||||
|
|
||||||
|
If so, set _last_re and _matched.
|
||||||
|
|
||||||
|
"""
|
||||||
|
for match in re.finditer(self._trigger, trigger):
|
||||||
|
if match.end() != len(trigger):
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
self._matched = trigger[match.start():match.end()]
|
||||||
|
|
||||||
|
self._last_re = match
|
||||||
|
return match
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _context_match(self, visual_content):
|
||||||
|
# skip on empty buffer
|
||||||
|
if len(vim.current.buffer) == 1 and vim.current.buffer[0] == "":
|
||||||
|
return
|
||||||
|
|
||||||
|
locals = {
|
||||||
|
'context': None,
|
||||||
|
'visual_mode': '',
|
||||||
|
'visual_text': '',
|
||||||
|
'last_placeholder': None
|
||||||
|
}
|
||||||
|
|
||||||
|
if visual_content:
|
||||||
|
locals['visual_mode'] = visual_content.mode
|
||||||
|
locals['visual_text'] = visual_content.text
|
||||||
|
locals['last_placeholder'] = visual_content.placeholder
|
||||||
|
|
||||||
|
return self._eval_code('snip.context = ' + self._context_code,
|
||||||
|
locals).context
|
||||||
|
|
||||||
|
def _eval_code(self, code, additional_locals={}):
|
||||||
|
code = "\n".join([
|
||||||
|
'import re, os, vim, string, random',
|
||||||
|
'\n'.join(self._globals.get('!p', [])).replace('\r\n', '\n'),
|
||||||
|
code
|
||||||
|
])
|
||||||
|
|
||||||
|
current = vim.current
|
||||||
|
|
||||||
|
locals = {
|
||||||
|
'window': current.window,
|
||||||
|
'buffer': current.buffer,
|
||||||
|
'line': current.window.cursor[0]-1,
|
||||||
|
'column': current.window.cursor[1]-1,
|
||||||
|
'cursor': SnippetUtilCursor(current.window.cursor),
|
||||||
|
}
|
||||||
|
|
||||||
|
locals.update(additional_locals)
|
||||||
|
|
||||||
|
snip = SnippetUtilForAction(locals)
|
||||||
|
|
||||||
|
try:
|
||||||
|
exec(code, {'snip': snip})
|
||||||
|
except Exception as e:
|
||||||
|
e.snippet_info = textwrap.dedent("""
|
||||||
|
Defined in: {}
|
||||||
|
Trigger: {}
|
||||||
|
Description: {}
|
||||||
|
Context: {}
|
||||||
|
Pre-expand: {}
|
||||||
|
Post-expand: {}
|
||||||
|
""").format(
|
||||||
|
self._location,
|
||||||
|
self._trigger,
|
||||||
|
self._description,
|
||||||
|
self._context_code if self._context_code else '<none>',
|
||||||
|
self._actions['pre_expand'] if 'pre_expand' in self._actions
|
||||||
|
else '<none>',
|
||||||
|
self._actions['post_expand'] if 'post_expand' in self._actions
|
||||||
|
else '<none>',
|
||||||
|
code,
|
||||||
|
)
|
||||||
|
|
||||||
|
e.snippet_code = code
|
||||||
|
|
||||||
|
raise
|
||||||
|
|
||||||
|
return snip
|
||||||
|
|
||||||
|
def _execute_action(
|
||||||
|
self,
|
||||||
|
action,
|
||||||
|
context,
|
||||||
|
additional_locals={}
|
||||||
|
):
|
||||||
|
mark_to_use = '`'
|
||||||
|
with _vim.save_mark(mark_to_use):
|
||||||
|
_vim.set_mark_from_pos(mark_to_use, _vim.get_cursor_pos())
|
||||||
|
|
||||||
|
cursor_line_before = _vim.buf.line_till_cursor
|
||||||
|
|
||||||
|
locals = {
|
||||||
|
'context': context,
|
||||||
|
}
|
||||||
|
|
||||||
|
locals.update(additional_locals)
|
||||||
|
|
||||||
|
snip = self._eval_code(action, locals)
|
||||||
|
|
||||||
|
if snip.cursor.is_set():
|
||||||
|
vim.current.window.cursor = snip.cursor.to_vim_cursor()
|
||||||
|
else:
|
||||||
|
new_mark_pos = _vim.get_mark_pos(mark_to_use)
|
||||||
|
|
||||||
|
cursor_invalid = False
|
||||||
|
|
||||||
|
if _vim._is_pos_zero(new_mark_pos):
|
||||||
|
cursor_invalid = True
|
||||||
|
else:
|
||||||
|
_vim.set_cursor_from_pos(new_mark_pos)
|
||||||
|
if cursor_line_before != _vim.buf.line_till_cursor:
|
||||||
|
cursor_invalid = True
|
||||||
|
|
||||||
|
if cursor_invalid:
|
||||||
|
raise RuntimeError(
|
||||||
|
'line under the cursor was modified, but ' +
|
||||||
|
'"snip.cursor" variable is not set; either set set ' +
|
||||||
|
'"snip.cursor" to new cursor position, or do not ' +
|
||||||
|
'modify cursor line'
|
||||||
|
)
|
||||||
|
|
||||||
|
return snip
|
||||||
|
|
||||||
|
def has_option(self, opt):
|
||||||
|
"""Check if the named option is set."""
|
||||||
|
return opt in self._opts
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description(self):
|
||||||
|
"""Descriptive text for this snippet."""
|
||||||
|
return ('(%s) %s' % (self._trigger, self._description)).strip()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def priority(self):
|
||||||
|
"""The snippets priority, which defines which snippet will be preferred
|
||||||
|
over others with the same trigger."""
|
||||||
|
return self._priority
|
||||||
|
|
||||||
|
@property
|
||||||
|
def trigger(self):
|
||||||
|
"""The trigger text for the snippet."""
|
||||||
|
return self._trigger
|
||||||
|
|
||||||
|
@property
|
||||||
|
def matched(self):
|
||||||
|
"""The last text that matched this snippet in match() or
|
||||||
|
could_match()."""
|
||||||
|
return self._matched
|
||||||
|
|
||||||
|
@property
|
||||||
|
def location(self):
|
||||||
|
"""Where this snippet was defined."""
|
||||||
|
return self._location
|
||||||
|
|
||||||
|
@property
|
||||||
|
def context(self):
|
||||||
|
"""The matched context."""
|
||||||
|
return self._context
|
||||||
|
|
||||||
|
def matches(self, before, visual_content=None):
|
||||||
|
"""Returns True if this snippet matches 'before'."""
|
||||||
|
# If user supplies both "w" and "i", it should perhaps be an
|
||||||
|
# error, but if permitted it seems that "w" should take precedence
|
||||||
|
# (since matching at word boundary and within a word == matching at word
|
||||||
|
# boundary).
|
||||||
|
self._matched = ''
|
||||||
|
|
||||||
|
words = _words_for_line(self._trigger, before)
|
||||||
|
|
||||||
|
if 'r' in self._opts:
|
||||||
|
match = self._re_match(before)
|
||||||
|
elif 'w' in self._opts:
|
||||||
|
words_len = len(self._trigger)
|
||||||
|
words_prefix = words[:-words_len]
|
||||||
|
words_suffix = words[-words_len:]
|
||||||
|
match = (words_suffix == self._trigger)
|
||||||
|
if match and words_prefix:
|
||||||
|
# Require a word boundary between prefix and suffix.
|
||||||
|
boundary_chars = escape(words_prefix[-1:] +
|
||||||
|
words_suffix[:1], r'\"')
|
||||||
|
match = _vim.eval(
|
||||||
|
'"%s" =~# "\\\\v.<."' %
|
||||||
|
boundary_chars) != '0'
|
||||||
|
elif 'i' in self._opts:
|
||||||
|
match = words.endswith(self._trigger)
|
||||||
|
else:
|
||||||
|
match = (words == self._trigger)
|
||||||
|
|
||||||
|
# By default, we match the whole trigger
|
||||||
|
if match and not self._matched:
|
||||||
|
self._matched = self._trigger
|
||||||
|
|
||||||
|
# Ensure the match was on a word boundry if needed
|
||||||
|
if 'b' in self._opts and match:
|
||||||
|
text_before = before.rstrip()[:-len(self._matched)]
|
||||||
|
if text_before.strip(' \t') != '':
|
||||||
|
self._matched = ''
|
||||||
|
return False
|
||||||
|
|
||||||
|
self._context = None
|
||||||
|
if match and self._context_code:
|
||||||
|
self._context = self._context_match(visual_content)
|
||||||
|
if not self.context:
|
||||||
|
match = False
|
||||||
|
|
||||||
|
return match
|
||||||
|
|
||||||
|
def could_match(self, before):
|
||||||
|
"""Return True if this snippet could match the (partial) 'before'."""
|
||||||
|
self._matched = ''
|
||||||
|
|
||||||
|
# List all on whitespace.
|
||||||
|
if before and before[-1] in (' ', '\t'):
|
||||||
|
before = ''
|
||||||
|
if before and before.rstrip() is not before:
|
||||||
|
return False
|
||||||
|
|
||||||
|
words = _words_for_line(self._trigger, before)
|
||||||
|
|
||||||
|
if 'r' in self._opts:
|
||||||
|
# Test for full match only
|
||||||
|
match = self._re_match(before)
|
||||||
|
elif 'w' in self._opts:
|
||||||
|
# Trim non-empty prefix up to word boundary, if present.
|
||||||
|
qwords = escape(words, r'\"')
|
||||||
|
words_suffix = _vim.eval(
|
||||||
|
'substitute("%s", "\\\\v^.+<(.+)", "\\\\1", "")' % qwords)
|
||||||
|
match = self._trigger.startswith(words_suffix)
|
||||||
|
self._matched = words_suffix
|
||||||
|
|
||||||
|
# TODO: list_snippets() function cannot handle partial-trigger
|
||||||
|
# matches yet, so for now fail if we trimmed the prefix.
|
||||||
|
if words_suffix != words:
|
||||||
|
match = False
|
||||||
|
elif 'i' in self._opts:
|
||||||
|
# TODO: It is hard to define when a inword snippet could match,
|
||||||
|
# therefore we check only for full-word trigger.
|
||||||
|
match = self._trigger.startswith(words)
|
||||||
|
else:
|
||||||
|
match = self._trigger.startswith(words)
|
||||||
|
|
||||||
|
# By default, we match the words from the trigger
|
||||||
|
if match and not self._matched:
|
||||||
|
self._matched = words
|
||||||
|
|
||||||
|
# Ensure the match was on a word boundry if needed
|
||||||
|
if 'b' in self._opts and match:
|
||||||
|
text_before = before.rstrip()[:-len(self._matched)]
|
||||||
|
if text_before.strip(' \t') != '':
|
||||||
|
self._matched = ''
|
||||||
|
return False
|
||||||
|
|
||||||
|
return match
|
||||||
|
|
||||||
|
def instantiate(self, snippet_instance, initial_text, indent):
|
||||||
|
"""Parses the content of this snippet and brings the corresponding text
|
||||||
|
objects alive inside of Vim."""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def do_pre_expand(self, visual_content, snippets_stack):
|
||||||
|
if 'pre_expand' in self._actions:
|
||||||
|
locals = {'buffer': _vim.buf, 'visual_content': visual_content}
|
||||||
|
|
||||||
|
snip = self._execute_action(
|
||||||
|
self._actions['pre_expand'], self._context, locals
|
||||||
|
)
|
||||||
|
|
||||||
|
self._context = snip.context
|
||||||
|
|
||||||
|
return snip.cursor.is_set()
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def do_post_expand(self, start, end, snippets_stack):
|
||||||
|
if 'post_expand' in self._actions:
|
||||||
|
locals = {
|
||||||
|
'snippet_start': start,
|
||||||
|
'snippet_end': end,
|
||||||
|
'buffer': _vim.buf
|
||||||
|
}
|
||||||
|
|
||||||
|
snip = self._execute_action(
|
||||||
|
self._actions['post_expand'], snippets_stack[-1].context, locals
|
||||||
|
)
|
||||||
|
|
||||||
|
snippets_stack[-1].context = snip.context
|
||||||
|
|
||||||
|
return snip.cursor.is_set()
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def do_post_jump(
|
||||||
|
self, tabstop_number, jump_direction, snippets_stack, current_snippet
|
||||||
|
):
|
||||||
|
if 'post_jump' in self._actions:
|
||||||
|
start = current_snippet.start
|
||||||
|
end = current_snippet.end
|
||||||
|
|
||||||
|
locals = {
|
||||||
|
'tabstop': tabstop_number,
|
||||||
|
'jump_direction': jump_direction,
|
||||||
|
'tabstops': current_snippet.get_tabstops(),
|
||||||
|
'snippet_start': start,
|
||||||
|
'snippet_end': end,
|
||||||
|
'buffer': _vim.buf
|
||||||
|
}
|
||||||
|
|
||||||
|
snip = self._execute_action(
|
||||||
|
self._actions['post_jump'], current_snippet.context, locals
|
||||||
|
)
|
||||||
|
|
||||||
|
current_snippet.context = snip.context
|
||||||
|
|
||||||
|
return snip.cursor.is_set()
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def launch(self, text_before, visual_content, parent, start, end):
|
||||||
|
"""Launch this snippet, overwriting the text 'start' to 'end' and
|
||||||
|
keeping the 'text_before' on the launch line.
|
||||||
|
|
||||||
|
'Parent' is the parent snippet instance if any.
|
||||||
|
|
||||||
|
"""
|
||||||
|
indent = self._INDENT.match(text_before).group(0)
|
||||||
|
lines = (self._value + '\n').splitlines()
|
||||||
|
ind_util = IndentUtil()
|
||||||
|
|
||||||
|
# Replace leading tabs in the snippet definition via proper indenting
|
||||||
|
initial_text = []
|
||||||
|
for line_num, line in enumerate(lines):
|
||||||
|
if 't' in self._opts:
|
||||||
|
tabs = 0
|
||||||
|
else:
|
||||||
|
tabs = len(self._TABS.match(line).group(0))
|
||||||
|
line_ind = ind_util.ntabs_to_proper_indent(tabs)
|
||||||
|
if line_num != 0:
|
||||||
|
line_ind = indent + line_ind
|
||||||
|
|
||||||
|
result_line = line_ind + line[tabs:]
|
||||||
|
if 'm' in self._opts:
|
||||||
|
result_line = result_line.rstrip()
|
||||||
|
initial_text.append(result_line)
|
||||||
|
initial_text = '\n'.join(initial_text)
|
||||||
|
|
||||||
|
snippet_instance = SnippetInstance(
|
||||||
|
self, parent, initial_text, start, end, visual_content,
|
||||||
|
last_re=self._last_re, globals=self._globals,
|
||||||
|
context=self._context)
|
||||||
|
self.instantiate(snippet_instance, initial_text, indent)
|
||||||
|
|
||||||
|
snippet_instance.update_textobjects()
|
||||||
|
return snippet_instance
|
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""A snipMate snippet after parsing."""
|
||||||
|
|
||||||
|
from UltiSnips.snippet.definition._base import SnippetDefinition
|
||||||
|
from UltiSnips.snippet.parsing.snipmate import parse_and_instantiate
|
||||||
|
|
||||||
|
|
||||||
|
class SnipMateSnippetDefinition(SnippetDefinition):
|
||||||
|
|
||||||
|
"""See module doc."""
|
||||||
|
|
||||||
|
SNIPMATE_SNIPPET_PRIORITY = -1000
|
||||||
|
|
||||||
|
def __init__(self, trigger, value, description, location):
|
||||||
|
SnippetDefinition.__init__(self, self.SNIPMATE_SNIPPET_PRIORITY,
|
||||||
|
trigger, value, description, '', {}, location,
|
||||||
|
None, {})
|
||||||
|
|
||||||
|
def instantiate(self, snippet_instance, initial_text, indent):
|
||||||
|
parse_and_instantiate(snippet_instance, initial_text, indent)
|
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""A UltiSnips snippet after parsing."""
|
||||||
|
|
||||||
|
from UltiSnips.snippet.definition._base import SnippetDefinition
|
||||||
|
from UltiSnips.snippet.parsing.ultisnips import parse_and_instantiate
|
||||||
|
|
||||||
|
|
||||||
|
class UltiSnipsSnippetDefinition(SnippetDefinition):
|
||||||
|
|
||||||
|
"""See module doc."""
|
||||||
|
|
||||||
|
def instantiate(self, snippet_instance, initial_text, indent):
|
||||||
|
return parse_and_instantiate(snippet_instance, initial_text, indent)
|
@ -0,0 +1 @@
|
|||||||
|
"""Code related to turning text into snippets."""
|
@ -0,0 +1,68 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""Common functionality of the snippet parsing codes."""
|
||||||
|
|
||||||
|
from UltiSnips.position import Position
|
||||||
|
from UltiSnips.snippet.parsing._lexer import tokenize, TabStopToken
|
||||||
|
from UltiSnips.text_objects import TabStop
|
||||||
|
|
||||||
|
from UltiSnips.text_objects import Mirror
|
||||||
|
from UltiSnips.snippet.parsing._lexer import MirrorToken
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_ambiguity(all_tokens, seen_ts):
|
||||||
|
"""$1 could be a Mirror or a TabStop.
|
||||||
|
|
||||||
|
This figures this out.
|
||||||
|
|
||||||
|
"""
|
||||||
|
for parent, token in all_tokens:
|
||||||
|
if isinstance(token, MirrorToken):
|
||||||
|
if token.number not in seen_ts:
|
||||||
|
seen_ts[token.number] = TabStop(parent, token)
|
||||||
|
else:
|
||||||
|
Mirror(parent, seen_ts[token.number], token)
|
||||||
|
|
||||||
|
|
||||||
|
def tokenize_snippet_text(snippet_instance, text, indent,
|
||||||
|
allowed_tokens_in_text, allowed_tokens_in_tabstops,
|
||||||
|
token_to_textobject):
|
||||||
|
"""Turns 'text' into a stream of tokens and creates the text objects from
|
||||||
|
those tokens that are mentioned in 'token_to_textobject' assuming the
|
||||||
|
current 'indent'.
|
||||||
|
|
||||||
|
The 'allowed_tokens_in_text' define which tokens will be recognized
|
||||||
|
in 'text' while 'allowed_tokens_in_tabstops' are the tokens that
|
||||||
|
will be recognized in TabStop placeholder text.
|
||||||
|
|
||||||
|
"""
|
||||||
|
seen_ts = {}
|
||||||
|
all_tokens = []
|
||||||
|
|
||||||
|
def _do_parse(parent, text, allowed_tokens):
|
||||||
|
"""Recursive function that actually creates the objects."""
|
||||||
|
tokens = list(tokenize(text, indent, parent.start, allowed_tokens))
|
||||||
|
for token in tokens:
|
||||||
|
all_tokens.append((parent, token))
|
||||||
|
if isinstance(token, TabStopToken):
|
||||||
|
ts = TabStop(parent, token)
|
||||||
|
seen_ts[token.number] = ts
|
||||||
|
_do_parse(ts, token.initial_text,
|
||||||
|
allowed_tokens_in_tabstops)
|
||||||
|
else:
|
||||||
|
klass = token_to_textobject.get(token.__class__, None)
|
||||||
|
if klass is not None:
|
||||||
|
klass(parent, token)
|
||||||
|
_do_parse(snippet_instance, text, allowed_tokens_in_text)
|
||||||
|
return all_tokens, seen_ts
|
||||||
|
|
||||||
|
|
||||||
|
def finalize(all_tokens, seen_ts, snippet_instance):
|
||||||
|
"""Adds a tabstop 0 if non is in 'seen_ts' and brings the text of the
|
||||||
|
snippet instance into Vim."""
|
||||||
|
if 0 not in seen_ts:
|
||||||
|
mark = all_tokens[-1][1].end # Last token is always EndOfText
|
||||||
|
m1 = Position(mark.line, mark.col)
|
||||||
|
TabStop(snippet_instance, 0, mark, m1)
|
||||||
|
snippet_instance.replace_initial_text()
|
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""Parses a snipMate snippet definition and launches it into Vim."""
|
||||||
|
|
||||||
|
from UltiSnips.snippet.parsing._base import tokenize_snippet_text, finalize, resolve_ambiguity
|
||||||
|
from UltiSnips.snippet.parsing._lexer import EscapeCharToken, \
|
||||||
|
VisualToken, TabStopToken, MirrorToken, ShellCodeToken
|
||||||
|
from UltiSnips.text_objects import EscapedChar, Mirror, VimLCode, Visual
|
||||||
|
|
||||||
|
_TOKEN_TO_TEXTOBJECT = {
|
||||||
|
EscapeCharToken: EscapedChar,
|
||||||
|
VisualToken: Visual,
|
||||||
|
ShellCodeToken: VimLCode, # `` is VimL in snipMate
|
||||||
|
}
|
||||||
|
|
||||||
|
__ALLOWED_TOKENS = [
|
||||||
|
EscapeCharToken, VisualToken, TabStopToken, MirrorToken, ShellCodeToken
|
||||||
|
]
|
||||||
|
|
||||||
|
__ALLOWED_TOKENS_IN_TABSTOPS = [
|
||||||
|
EscapeCharToken, VisualToken, MirrorToken, ShellCodeToken
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def parse_and_instantiate(parent_to, text, indent):
|
||||||
|
"""Parses a snippet definition in snipMate format from 'text' assuming the
|
||||||
|
current 'indent'.
|
||||||
|
|
||||||
|
Will instantiate all the objects and link them as children to
|
||||||
|
parent_to. Will also put the initial text into Vim.
|
||||||
|
|
||||||
|
"""
|
||||||
|
all_tokens, seen_ts = tokenize_snippet_text(parent_to, text, indent,
|
||||||
|
__ALLOWED_TOKENS, __ALLOWED_TOKENS_IN_TABSTOPS,
|
||||||
|
_TOKEN_TO_TEXTOBJECT)
|
||||||
|
resolve_ambiguity(all_tokens, seen_ts)
|
||||||
|
finalize(all_tokens, seen_ts, parent_to)
|
@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""Parses a UltiSnips snippet definition and launches it into Vim."""
|
||||||
|
|
||||||
|
from UltiSnips.snippet.parsing._base import tokenize_snippet_text, finalize, resolve_ambiguity
|
||||||
|
from UltiSnips.snippet.parsing._lexer import EscapeCharToken, \
|
||||||
|
VisualToken, TransformationToken, TabStopToken, MirrorToken, \
|
||||||
|
PythonCodeToken, VimLCodeToken, ShellCodeToken
|
||||||
|
from UltiSnips.text_objects import EscapedChar, Mirror, PythonCode, \
|
||||||
|
ShellCode, TabStop, Transformation, VimLCode, Visual
|
||||||
|
|
||||||
|
_TOKEN_TO_TEXTOBJECT = {
|
||||||
|
EscapeCharToken: EscapedChar,
|
||||||
|
VisualToken: Visual,
|
||||||
|
ShellCodeToken: ShellCode,
|
||||||
|
PythonCodeToken: PythonCode,
|
||||||
|
VimLCodeToken: VimLCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
__ALLOWED_TOKENS = [
|
||||||
|
EscapeCharToken, VisualToken, TransformationToken, TabStopToken,
|
||||||
|
MirrorToken, PythonCodeToken, VimLCodeToken, ShellCodeToken
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _create_transformations(all_tokens, seen_ts):
|
||||||
|
"""Create the objects that need to know about tabstops."""
|
||||||
|
for parent, token in all_tokens:
|
||||||
|
if isinstance(token, TransformationToken):
|
||||||
|
if token.number not in seen_ts:
|
||||||
|
raise RuntimeError(
|
||||||
|
'Tabstop %i is not known but is used by a Transformation'
|
||||||
|
% token.number)
|
||||||
|
Transformation(parent, seen_ts[token.number], token)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_and_instantiate(parent_to, text, indent):
|
||||||
|
"""Parses a snippet definition in UltiSnips format from 'text' assuming the
|
||||||
|
current 'indent'.
|
||||||
|
|
||||||
|
Will instantiate all the objects and link them as children to
|
||||||
|
parent_to. Will also put the initial text into Vim.
|
||||||
|
|
||||||
|
"""
|
||||||
|
all_tokens, seen_ts = tokenize_snippet_text(parent_to, text, indent,
|
||||||
|
__ALLOWED_TOKENS, __ALLOWED_TOKENS, _TOKEN_TO_TEXTOBJECT)
|
||||||
|
resolve_ambiguity(all_tokens, seen_ts)
|
||||||
|
_create_transformations(all_tokens, seen_ts)
|
||||||
|
finalize(all_tokens, seen_ts, parent_to)
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""Sources of snippet definitions."""
|
||||||
|
|
||||||
|
from UltiSnips.snippet.source._base import SnippetSource
|
||||||
|
from UltiSnips.snippet.source.added import AddedSnippetsSource
|
||||||
|
from UltiSnips.snippet.source.file.snipmate import SnipMateFileSource
|
||||||
|
from UltiSnips.snippet.source.file.ultisnips import UltiSnipsFileSource, \
|
||||||
|
find_all_snippet_files, find_snippet_files
|
@ -0,0 +1,97 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""Base class for snippet sources."""
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
from UltiSnips.snippet.source._snippet_dictionary import SnippetDictionary
|
||||||
|
|
||||||
|
|
||||||
|
class SnippetSource(object):
|
||||||
|
|
||||||
|
"""See module docstring."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._snippets = defaultdict(SnippetDictionary)
|
||||||
|
self._extends = defaultdict(set)
|
||||||
|
|
||||||
|
def ensure(self, filetypes, cached):
|
||||||
|
"""Update/reload the snippets in the source when needed.
|
||||||
|
|
||||||
|
It makes sure that the snippets are not outdated.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def loaded(self, filetypes):
|
||||||
|
return len(self._snippets) > 0
|
||||||
|
|
||||||
|
def _get_existing_deep_extends(self, base_filetypes):
|
||||||
|
"""Helper for get all existing filetypes extended by base filetypes."""
|
||||||
|
deep_extends = self.get_deep_extends(base_filetypes)
|
||||||
|
return [ft for ft in deep_extends if ft in self._snippets]
|
||||||
|
|
||||||
|
def get_snippets(self, filetypes, before, possible, autotrigger_only,
|
||||||
|
visual_content):
|
||||||
|
"""Returns the snippets for all 'filetypes' (in order) and their
|
||||||
|
parents matching the text 'before'. If 'possible' is true, a partial
|
||||||
|
match is enough. Base classes can override this method to provide means
|
||||||
|
of creating snippets on the fly.
|
||||||
|
|
||||||
|
Returns a list of SnippetDefinition s.
|
||||||
|
|
||||||
|
"""
|
||||||
|
result = []
|
||||||
|
for ft in self._get_existing_deep_extends(filetypes):
|
||||||
|
snips = self._snippets[ft]
|
||||||
|
result.extend(snips.get_matching_snippets(before, possible,
|
||||||
|
autotrigger_only,
|
||||||
|
visual_content))
|
||||||
|
return result
|
||||||
|
|
||||||
|
def get_clear_priority(self, filetypes):
|
||||||
|
"""Get maximum clearsnippets priority without arguments for specified
|
||||||
|
filetypes, if any.
|
||||||
|
|
||||||
|
It returns None if there are no clearsnippets.
|
||||||
|
|
||||||
|
"""
|
||||||
|
pri = None
|
||||||
|
for ft in self._get_existing_deep_extends(filetypes):
|
||||||
|
snippets = self._snippets[ft]
|
||||||
|
if pri is None or snippets._clear_priority > pri:
|
||||||
|
pri = snippets._clear_priority
|
||||||
|
return pri
|
||||||
|
|
||||||
|
def get_cleared(self, filetypes):
|
||||||
|
"""Get a set of cleared snippets marked by clearsnippets with arguments
|
||||||
|
for specified filetypes."""
|
||||||
|
cleared = {}
|
||||||
|
for ft in self._get_existing_deep_extends(filetypes):
|
||||||
|
snippets = self._snippets[ft]
|
||||||
|
for key, value in snippets._cleared.items():
|
||||||
|
if key not in cleared or value > cleared[key]:
|
||||||
|
cleared[key] = value
|
||||||
|
return cleared
|
||||||
|
|
||||||
|
def update_extends(self, child_ft, parent_fts):
|
||||||
|
"""Update the extending relation by given child filetype and its parent
|
||||||
|
filetypes."""
|
||||||
|
self._extends[child_ft].update(parent_fts)
|
||||||
|
|
||||||
|
def get_deep_extends(self, base_filetypes):
|
||||||
|
"""Get a list of filetypes that is either directed or indirected
|
||||||
|
extended by given base filetypes.
|
||||||
|
|
||||||
|
Note that the returned list include the root filetype itself.
|
||||||
|
|
||||||
|
"""
|
||||||
|
seen = set(base_filetypes)
|
||||||
|
todo_fts = list(set(base_filetypes))
|
||||||
|
while todo_fts:
|
||||||
|
todo_ft = todo_fts.pop()
|
||||||
|
unseen_extends = set(
|
||||||
|
ft for ft in self._extends[todo_ft] if ft not in seen)
|
||||||
|
seen.update(unseen_extends)
|
||||||
|
todo_fts.extend(unseen_extends)
|
||||||
|
return seen
|
@ -0,0 +1,60 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""Implements a container for parsed snippets."""
|
||||||
|
|
||||||
|
class SnippetDictionary(object):
|
||||||
|
|
||||||
|
"""See module docstring."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._snippets = []
|
||||||
|
self._cleared = {}
|
||||||
|
self._clear_priority = float("-inf")
|
||||||
|
|
||||||
|
def add_snippet(self, snippet):
|
||||||
|
"""Add 'snippet' to this dictionary."""
|
||||||
|
self._snippets.append(snippet)
|
||||||
|
|
||||||
|
def get_matching_snippets(self, trigger, potentially, autotrigger_only,
|
||||||
|
visual_content):
|
||||||
|
"""Returns all snippets matching the given trigger.
|
||||||
|
|
||||||
|
If 'potentially' is true, returns all that could_match().
|
||||||
|
|
||||||
|
If 'autotrigger_only' is true, function will return only snippets which
|
||||||
|
are marked with flag 'A' (should be automatically expanded without
|
||||||
|
trigger key press).
|
||||||
|
It's handled specially to avoid walking down the list of all snippets,
|
||||||
|
which can be very slow, because function will be called on each change
|
||||||
|
made in insert mode.
|
||||||
|
|
||||||
|
"""
|
||||||
|
all_snippets = self._snippets
|
||||||
|
if autotrigger_only:
|
||||||
|
all_snippets = [s for s in all_snippets if s.has_option('A')]
|
||||||
|
|
||||||
|
if not potentially:
|
||||||
|
return [s for s in all_snippets if s.matches(trigger,
|
||||||
|
visual_content)]
|
||||||
|
else:
|
||||||
|
return [s for s in all_snippets if s.could_match(trigger)]
|
||||||
|
|
||||||
|
def clear_snippets(self, priority, triggers):
|
||||||
|
"""Clear the snippets by mark them as cleared.
|
||||||
|
|
||||||
|
If trigger is None, it updates the value of clear priority
|
||||||
|
instead.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if not triggers:
|
||||||
|
if self._clear_priority is None or priority > self._clear_priority:
|
||||||
|
self._clear_priority = priority
|
||||||
|
else:
|
||||||
|
for trigger in triggers:
|
||||||
|
if (trigger not in self._cleared or
|
||||||
|
priority > self._cleared[trigger]):
|
||||||
|
self._cleared[trigger] = priority
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self._snippets)
|
@ -0,0 +1 @@
|
|||||||
|
"""Snippet sources that are file based."""
|
@ -0,0 +1,112 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""Code to provide access to UltiSnips files from disk."""
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
|
import hashlib
|
||||||
|
import os
|
||||||
|
|
||||||
|
from UltiSnips import _vim
|
||||||
|
from UltiSnips import compatibility
|
||||||
|
from UltiSnips.snippet.source._base import SnippetSource
|
||||||
|
|
||||||
|
|
||||||
|
def _hash_file(path):
|
||||||
|
"""Returns a hashdigest of 'path'."""
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
return False
|
||||||
|
return hashlib.sha1(open(path, 'rb').read()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
class SnippetSyntaxError(RuntimeError):
|
||||||
|
|
||||||
|
"""Thrown when a syntax error is found in a file."""
|
||||||
|
|
||||||
|
def __init__(self, filename, line_index, msg):
|
||||||
|
RuntimeError.__init__(self, '%s in %s:%d' % (
|
||||||
|
msg, filename, line_index))
|
||||||
|
|
||||||
|
|
||||||
|
class SnippetFileSource(SnippetSource):
|
||||||
|
|
||||||
|
"""Base class that abstracts away 'extends' info and file hashes."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
SnippetSource.__init__(self)
|
||||||
|
self._files_for_ft = defaultdict(set)
|
||||||
|
self._file_hashes = defaultdict(lambda: None)
|
||||||
|
self._ensure_cached = False
|
||||||
|
|
||||||
|
def ensure(self, filetypes, cached):
|
||||||
|
if cached and self._ensure_cached:
|
||||||
|
return
|
||||||
|
|
||||||
|
for ft in self.get_deep_extends(filetypes):
|
||||||
|
if self._needs_update(ft):
|
||||||
|
self._load_snippets_for(ft)
|
||||||
|
|
||||||
|
self._ensure_cached = True
|
||||||
|
|
||||||
|
def _get_all_snippet_files_for(self, ft):
|
||||||
|
"""Returns a set of all files that define snippets for 'ft'."""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def _parse_snippet_file(self, filedata, filename):
|
||||||
|
"""Parses 'filedata' as a snippet file and yields events."""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def _needs_update(self, ft):
|
||||||
|
"""Returns true if any files for 'ft' have changed and must be
|
||||||
|
reloaded."""
|
||||||
|
existing_files = self._get_all_snippet_files_for(ft)
|
||||||
|
if existing_files != self._files_for_ft[ft]:
|
||||||
|
self._files_for_ft[ft] = existing_files
|
||||||
|
return True
|
||||||
|
|
||||||
|
for filename in self._files_for_ft[ft]:
|
||||||
|
if _hash_file(filename) != self._file_hashes[filename]:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _load_snippets_for(self, ft):
|
||||||
|
"""Load all snippets for the given 'ft'."""
|
||||||
|
if ft in self._snippets:
|
||||||
|
del self._snippets[ft]
|
||||||
|
del self._extends[ft]
|
||||||
|
try:
|
||||||
|
for fn in self._files_for_ft[ft]:
|
||||||
|
self._parse_snippets(ft, fn)
|
||||||
|
except:
|
||||||
|
del self._files_for_ft[ft]
|
||||||
|
raise
|
||||||
|
# Now load for the parents
|
||||||
|
for parent_ft in self.get_deep_extends([ft]):
|
||||||
|
if parent_ft != ft and self._needs_update(parent_ft):
|
||||||
|
self._load_snippets_for(parent_ft)
|
||||||
|
|
||||||
|
def _parse_snippets(self, ft, filename):
|
||||||
|
"""Parse the 'filename' for the given 'ft' and watch it for changes in
|
||||||
|
the future."""
|
||||||
|
self._file_hashes[filename] = _hash_file(filename)
|
||||||
|
file_data = compatibility.open_ascii_file(filename, 'r').read()
|
||||||
|
for event, data in self._parse_snippet_file(file_data, filename):
|
||||||
|
if event == 'error':
|
||||||
|
msg, line_index = data
|
||||||
|
filename = _vim.eval("""fnamemodify(%s, ":~:.")""" %
|
||||||
|
_vim.escape(filename))
|
||||||
|
raise SnippetSyntaxError(filename, line_index, msg)
|
||||||
|
elif event == 'clearsnippets':
|
||||||
|
priority, triggers = data
|
||||||
|
self._snippets[ft].clear_snippets(priority, triggers)
|
||||||
|
elif event == 'extends':
|
||||||
|
# TODO(sirver): extends information is more global
|
||||||
|
# than one snippet source.
|
||||||
|
filetypes, = data
|
||||||
|
self.update_extends(ft, filetypes)
|
||||||
|
elif event == 'snippet':
|
||||||
|
snippet, = data
|
||||||
|
self._snippets[ft].add_snippet(snippet)
|
||||||
|
else:
|
||||||
|
assert False, 'Unhandled %s: %r' % (event, data)
|
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
"""Common code for snipMate and UltiSnips snippet files."""
|
||||||
|
|
||||||
|
|
||||||
|
def handle_extends(tail, line_index):
|
||||||
|
"""Handles an extends line in a snippet."""
|
||||||
|
if tail:
|
||||||
|
return 'extends', ([p.strip() for p in tail.split(',')],)
|
||||||
|
else:
|
||||||
|
return 'error', ("'extends' without file types", line_index)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_action(head, tail, line_index):
|
||||||
|
if tail:
|
||||||
|
action = tail.strip('"').replace(r'\"', '"').replace(r'\\\\', r'\\')
|
||||||
|
return head, (action,)
|
||||||
|
else:
|
||||||
|
return 'error', ("'{}' without specified action".format(head),
|
||||||
|
line_index)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue