Skip to content

Commit 344ac6e

Browse files
committed
new policies for if, eif, el
What about wh(ile)? drop some placeholder comments which don't add (enough) value to keep for patterns used very often.
1 parent eaa01e7 commit 344ac6e

27 files changed

+177
-120
lines changed

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,43 @@ of the snippets by setting the "always_use_first_snippet" option to 1.
5050
If you have VimL only (vim without python support) your best option is using
5151
garbas/vim-snipmate and cope with the minor bugs found in the engine.
5252

53+
54+
Policies / for contributors
55+
===========================
56+
some snippets are useful for all languages, so let's try to have the same
57+
triggers for all languages:
58+
59+
```
60+
if : if without else
61+
ife: if $1 else $2
62+
eif : else if ($1) { .. }
63+
el : else ..
64+
```
65+
66+
If you're not satisfied with these defaults, open a ticket that we implement
67+
aliasing. Then you can remap "else" to "el" or the like.
68+
69+
70+
Don't add stupid placeholder default texts like
71+
```
72+
if (${1:condition){
73+
${2:some code here}
74+
}
75+
```
76+
instead use:
77+
78+
```
79+
if (${1){
80+
${2}
81+
}
82+
```
83+
84+
Exception: Functions which are used less often, such as Vim's matchall(), matchstr()
85+
functions which case hints may be helpful to remember order. In the VimL case
86+
get vim-dev plugin which has function completion
87+
88+
Thus for conditions (while, if ..) and block bodies just use ${N} - Thanks
89+
5390
Related repositories
5491
====================
5592
We also encourage people to maintain sets of snippets for particular use cases

UltiSnips/coffee.snippets

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ else
2222
${3:# body...}
2323
endsnippet
2424

25-
snippet elif "Else if" b
25+
snippet eif "Else if" b
2626
else if ${1:condition}
2727
${0:# body...}
2828
endsnippet

UltiSnips/d.snippets

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ else
126126
}
127127
endsnippet
128128

129-
snippet elif "else if (elif)" b
129+
snippet eif "else if (elif)" b
130130
else if(${1:/*condition*/})
131131
{
132132
${VISUAL}${0:/*code*/}

UltiSnips/django.snippets

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ snippet if
7676
{% endif %}
7777
endsnippet
7878

79-
snippet else
79+
snippet el
8080
{% else %}
8181
${1}
8282
endsnippet

UltiSnips/eruby.snippets

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ snippet st "submit_tag"
263263
`!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)`
264264
endsnippet
265265

266-
snippet else "else (ERB)"
266+
snippet el "else (ERB)"
267267
<% else %>
268268

269269
endsnippet

UltiSnips/haskell.snippets

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
snippet if "if ... then ... else ..."
1+
snippet ife "if ... then ... else ..."
22
if ${1:condition}
33
then ${2:expression}
44
else ${3:expression}
55
endsnippet
66

77
snippet case "case ... of ..."
8-
case ${1:expression} of
9-
${2:pattern} -> ${3:expression}
10-
${4:pattern} -> ${5:expression}
8+
case ${1} of
9+
${2} -> ${3}
10+
${4} -> ${5}
1111
endsnippet
1212

1313
snippet :: "Type signature"

UltiSnips/java.snippets

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ default:
5959
$0
6060
endsnippet
6161

62-
snippet elif "else if" b
62+
snippet eif "else if" b
6363
else if ($1)`!p nl(snip)`{
6464
$0
6565
}

UltiSnips/javascript.snippets

+9-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@ function ${1:function_name} (${2:argument}) {
5050
}
5151
endsnippet
5252

53+
# for one line if .. else you usually use a ? b : c
5354
snippet ife "if ___ else"
54-
if (${1:true}) {$0} else{};
55+
if (${1}) {
56+
{$2}
57+
} else {
58+
{$3}
59+
};
5560
endsnippet
5661

5762
snippet if "if"
58-
if (${1:true}) {$0};
63+
if (${1}) {
64+
{$2}
65+
};
5966
endsnippet
6067

6168
snippet timeout "setTimeout function"

UltiSnips/ocaml.snippets

+38-43
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ endsnippet
44

55
snippet open "open"
66
let open ${1:module} in
7-
${2:e}
7+
${2}
88
endsnippet
99

1010
snippet try "try"
11-
try ${1:e}
11+
try ${1}
1212
with ${2:Not_found} -> ${3:()}
1313
endsnippet
1414

1515
snippet ref "ref"
16-
let ${1:name} = ref ${2:val} in
17-
${3:e}
16+
let ${1} = ref ${2} in
17+
${3}
1818
endsnippet
1919

2020
snippet matchl "pattern match on a list"
@@ -24,88 +24,83 @@ match ${1:list} with
2424
endsnippet
2525

2626
snippet matcho "pattern match on an option type"
27-
match ${1:x} with
28-
| Some(${2:y}) -> ${3:()}
27+
match ${1} with
28+
| Some(${2}) -> ${3:()}
2929
| None -> ${4:()}
3030
endsnippet
3131

3232
snippet fun "anonymous function"
33-
(fun ${1:x} -> ${2:x})
33+
(fun ${1} -> ${2})
3434
endsnippet
3535

3636
snippet cc "commment"
37-
(* ${1:comment} *)
37+
(* ${1} *)
3838
endsnippet
3939

4040
snippet let "let .. in binding"
41-
let ${1:x} = ${2:v} in
42-
${3:e}
41+
let ${1} = ${2} in
42+
${3}
4343
endsnippet
4444

4545
snippet lr "let rec"
46-
let rec ${1:f} =
47-
${2:expr}
46+
let rec ${1} =
47+
${2}
4848
endsnippet
4949

50-
snippet if "if"
51-
if ${1:(* condition *)} then
52-
${2:(* A *)}
50+
snippet ife "if"
51+
if ${1} then
52+
${2}
5353
else
54-
${3:(* B *)}
54+
${3}
5555
endsnippet
5656

57-
snippet If "If"
58-
if ${1:(* condition *)} then
59-
${2:(* A *)}
57+
snippet if "If"
58+
if ${1} then
59+
${2}
6060
endsnippet
6161

6262
snippet while "while"
63-
while ${1:(* condition *)} do
64-
${2:(* A *)}
63+
while ${1} do
64+
${2}
6565
done
6666
endsnippet
6767

6868
snippet for "for"
6969
for ${1:i} = ${2:1} to ${3:10} do
70-
${4:(* BODY *)}
70+
${4}
7171
done
7272
endsnippet
7373

7474
snippet match "match"
75-
match ${1:(* e1 *)} with
76-
| ${2:p} -> ${3:e2}
77-
endsnippet
78-
79-
snippet Match "match"
80-
match ${1:(* e1 *)} with
81-
| ${2:p} -> ${3:e2}
75+
match ${1} with
76+
| ${2} -> ${3}
8277
endsnippet
8378

8479
snippet class "class"
8580
class ${1:name} = object
86-
${2:methods}
81+
${2}
8782
end
8883
endsnippet
8984

9085
snippet obj "obj"
9186
object
92-
${2:methods}
87+
${2}
9388
end
9489
endsnippet
9590

9691
snippet Obj "object"
9792
object (self)
98-
${2:methods}
93+
${2}
9994
end
10095
endsnippet
10196

10297
snippet {{ "object functional update"
103-
{< ${1:x} = ${2:y} >}
98+
{< ${1} = ${2} >}
10499
endsnippet
105100

106101
snippet beg "beg"
107102
begin
108-
${1:block}
103+
${1}${VISUAL}
109104
end
110105
endsnippet
111106

@@ -115,19 +110,19 @@ endsnippet
115110

116111
snippet mod "module - no signature"
117112
module ${1:(* Name *)} = struct
118-
${2:(* BODY *)}
113+
${2}
119114
end
120115
endsnippet
121116

122117
snippet Mod "module with signature"
123118
module ${1:(* Name *)} : ${2:(* SIG *)} = struct
124-
${3:(* BODY *)}
119+
${3}
125120
end
126121
endsnippet
127122

128123
snippet sig "anonymous signature"
129124
sig
130-
${2:(* BODY *)}
125+
${2}
131126
end
132127
endsnippet
133128

@@ -137,32 +132,32 @@ endsnippet
137132

138133
snippet func "define functor - no signature"
139134
module ${1:M} (${2:Arg} : ${3:ARG}) = struct
140-
${4:(* BODY *)}
135+
${4}
141136
end
142137
endsnippet
143138

144139
snippet Func "define functor - with signature"
145140
module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct
146-
${5:(* BODY *)}
141+
${5}
147142
end
148143
endsnippet
149144

150145
snippet mot "Declare module signature"
151146
module type ${1:(* Name *)} = sig
152-
${2:(* BODY *)}
147+
${2}
153148
end
154149
endsnippet
155150

156151
snippet module "Module with anonymous signature"
157152
module ${1:(* Name *)} : sig
158-
${2:(* SIGNATURE *)}
153+
${2}
159154
end = struct
160-
${3:(* BODY *)}
155+
${3}
161156
end
162157
endsnippet
163158

164159
snippet oo "odoc"
165-
(** ${1:odoc} *)
160+
(** ${1} *)
166161
endsnippet
167162

168163
snippet qt "inline qtest"

UltiSnips/php.snippets

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ endsnippet
1111

1212
snippet do "do"
1313
do {
14-
${2:// code... }
15-
} while (${1:/* condition */});"
14+
${2}
15+
} while (${1});"
1616
endsnippet
1717

1818
snippet doc_f "doc_f"
@@ -37,21 +37,21 @@ interface ${1:someClass}
3737
} // END interface $1"
3838
endsnippet
3939

40-
snippet else "else"
40+
snippet el "else"
4141
else {
42-
${1:// code...}
42+
${1}
4343
}
4444
endsnippet
4545

4646
snippet for "for"
4747
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
48-
${4:// code...}
48+
${4}
4949
}
5050
endsnippet
5151

5252
snippet foreachk "foreachk"
5353
foreach ($${1:variable} as $${2:key} => $${3:value}){
54-
${4:// code...}
54+
${4}
5555
}
5656
endsnippet
5757

@@ -60,8 +60,8 @@ $_GET['${1}']${2}
6060
endsnippet
6161

6262
snippet if "if"
63-
if (${1:/* condition */}) {
64-
${2:// code...}
63+
if (${1}) {
64+
${2}
6565
}
6666
endsnippet
6767

@@ -210,9 +210,9 @@ endsnippet
210210

211211
snippet ife "if else"
212212
if (${1:/* condition */}) {
213-
${2:// code...}
213+
${2}
214214
} else {
215-
${3:// code...}
215+
${3}
216216
}
217217
$0
218218
endsnippet
@@ -227,7 +227,7 @@ class $1
227227
{
228228
public function ${3:__construct}(${4:$options})
229229
{
230-
${4:// code}
230+
${4}
231231
}
232232
}
233233
$0

0 commit comments

Comments
 (0)