Skip to content

Commit af5fad4

Browse files
committed
Merge pull request honza#425 from obaoba/master
add Ada snippets
2 parents 90723f6 + f7d4aa5 commit af5fad4

File tree

2 files changed

+579
-0
lines changed

2 files changed

+579
-0
lines changed

UltiSnips/ada.snippets

Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
priority -50
2+
3+
global !p
4+
5+
def ada_case(word):
6+
out = word[0].upper()
7+
for i in range(1, len(word)):
8+
if word[i - 1] == '_':
9+
out = out + word[i].upper()
10+
else:
11+
out = out + word[i]
12+
return out
13+
14+
def get_year():
15+
import time
16+
return time.strftime("%Y")
17+
18+
endglobal
19+
20+
snippet wi "with"
21+
with $1;$0
22+
endsnippet
23+
24+
snippet pac "package"
25+
package ${1:`!p snip.rv = ada_case(snip.basename)`} is
26+
$0
27+
end $1;
28+
endsnippet
29+
30+
snippet pacb "package body"
31+
package body ${1:`!p snip.rv = ada_case(snip.basename)`} is
32+
$0
33+
end $1;
34+
endsnippet
35+
36+
snippet ent "entry ... when"
37+
entry $1($2) when $3 is
38+
begin
39+
$0
40+
end $1;
41+
endsnippet
42+
43+
snippet task "task"
44+
task $1 is
45+
entry $0
46+
end $1;
47+
endsnippet
48+
49+
snippet taskb "task body"
50+
task body $1 is
51+
$2
52+
begin
53+
$0
54+
end $1;
55+
endsnippet
56+
57+
snippet acc "accept"
58+
accept $1($2) do
59+
$0
60+
end $1;
61+
endsnippet
62+
63+
snippet prot "protected type"
64+
protected type $1($2) is
65+
$0
66+
end $1;
67+
endsnippet
68+
69+
snippet prob "protected body"
70+
protected body $1 is
71+
$2
72+
begin
73+
$0
74+
end $1;
75+
endsnippet
76+
77+
snippet gen "generic type"
78+
generic
79+
type $1 is $2;$0
80+
endsnippet
81+
82+
snippet ty "type"
83+
type $1 is $2;$0
84+
endsnippet
85+
86+
snippet tyd "type with default value"
87+
type $1 is $2
88+
with Default_Value => $3;$0
89+
endsnippet
90+
91+
snippet subty "subtype"
92+
subtype $1 is $2;$0
93+
endsnippet
94+
95+
snippet dec "declare block"
96+
declare
97+
$1
98+
begin
99+
$0
100+
end;
101+
endsnippet
102+
103+
snippet decn "declare named block"
104+
$1:
105+
declare
106+
$2
107+
begin
108+
$0
109+
end $1;
110+
endsnippet
111+
112+
snippet ifex "if expression"
113+
if $1 then $2 else $0
114+
endsnippet
115+
116+
snippet casex "case expression"
117+
case $1 is
118+
when $2 => $3,$0
119+
endsnippet
120+
121+
snippet fora "for all"
122+
for all $1 ${2:in} $3 => $0
123+
endsnippet
124+
125+
snippet fors "for some"
126+
for some $1 ${2:in} $3 => $0
127+
endsnippet
128+
129+
snippet if "if"
130+
if $1 then
131+
$0
132+
end if;
133+
endsnippet
134+
135+
snippet ife "if ... else"
136+
if $1 then
137+
$2
138+
else
139+
$0
140+
end if;
141+
endsnippet
142+
143+
snippet el "else"
144+
else
145+
$0
146+
endsnippet
147+
148+
snippet eif "elsif"
149+
elsif $1 then
150+
$0
151+
endsnippet
152+
153+
snippet wh "while"
154+
while $1 loop
155+
$0
156+
end loop;
157+
endsnippet
158+
159+
snippet nwh "named while"
160+
$1:
161+
while $2 loop
162+
$0
163+
end loop $1;
164+
endsnippet
165+
166+
snippet for "for"
167+
for ${1:I} in $2 loop
168+
$0
169+
end loop;
170+
endsnippet
171+
172+
snippet fore "for each"
173+
for $1 of $2 loop
174+
$0
175+
end loop;
176+
endsnippet
177+
178+
snippet nfor "named for"
179+
$1:
180+
for ${2:I} in $3 loop
181+
$0
182+
end loop $1;
183+
endsnippet
184+
185+
snippet nfore "named for each"
186+
$1:
187+
for $2 of $3 loop
188+
$0
189+
end loop $1;
190+
endsnippet
191+
192+
snippet proc "procedure"
193+
procedure $1($2) is
194+
$3
195+
begin
196+
$0
197+
end $1;
198+
endsnippet
199+
200+
snippet procd "procedure declaration"
201+
procedure $1;$0
202+
endsnippet
203+
204+
snippet fun "function"
205+
function $1($2) return $3 is
206+
$4
207+
begin
208+
$0
209+
end $1;
210+
endsnippet
211+
212+
snippet fune "expression function"
213+
function $1 return $2 is
214+
($3);$0
215+
endsnippet
216+
217+
snippet fund "function declaration"
218+
function $1 return $2;$0
219+
endsnippet
220+
221+
snippet ret "extended return"
222+
return $1 do
223+
$0
224+
end return;
225+
endsnippet
226+
227+
snippet rec "record"
228+
record
229+
$0
230+
end record;
231+
endsnippet
232+
233+
snippet case "case"
234+
case $1 is
235+
when $2 => $3;$0
236+
end case;
237+
endsnippet
238+
239+
snippet whe "when"
240+
when $1 => $2;$0
241+
endsnippet
242+
243+
snippet wheo "when others"
244+
when others => $1;$0
245+
endsnippet
246+
247+
snippet lo "loop"
248+
loop
249+
$0
250+
end loop;
251+
endsnippet
252+
253+
snippet nlo "named loop"
254+
$1:
255+
loop
256+
$0
257+
end loop $1;
258+
endsnippet
259+
260+
snippet ex "exit when"
261+
exit when $1;$0
262+
endsnippet
263+
264+
snippet put "Ada.Text_IO.Put"
265+
Ada.Text_IO.Put($1);$0
266+
endsnippet
267+
268+
snippet putl "Ada.Text_IO.Put_Line"
269+
Ada.Text_IO.Put_Line($1);$0
270+
endsnippet
271+
272+
snippet get "Ada.Text_IO.Get"
273+
Ada.Text_IO.Get($1);$0
274+
endsnippet
275+
276+
snippet getl "Ada.Text_IO.Get_Line"
277+
Ada.Text_IO.Get_Line($1);$0
278+
endsnippet
279+
280+
snippet newline "Ada.Text_IO.New_Line"
281+
Ada.Text_IO.New_Line(${1:1});$0
282+
endsnippet
283+
284+
snippet gpl "GPL license header"
285+
-- This program is free software; you can redistribute it and/or modify
286+
-- it under the terms of the GNU ${1}General Public License as published by
287+
-- the Free Software Foundation; either version ${2:3} of the License, or
288+
-- (at your option) any later version.
289+
--
290+
-- This program is distributed in the hope that it will be useful,
291+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
292+
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
293+
-- GNU $1General Public License for more details.
294+
--
295+
-- You should have received a copy of the GNU $1General Public License
296+
-- along with this program; if not, see <http://www.gnu.org/licenses/>.
297+
--
298+
-- Copyright (C) ${3:Author}, ${4:`!p snip.rv = get_year()`}
299+
300+
$0
301+
endsnippet
302+
303+
snippet gplf "GPL file license header"
304+
-- This file is part of ${1:Program-Name}.
305+
--
306+
-- $1 is free software: you can redistribute it and/or modify
307+
-- it under the terms of the GNU ${2}General Public License as published by
308+
-- the Free Software Foundation, either version ${3:3} of the License, or
309+
-- (at your option) any later version.
310+
--
311+
-- $1 is distributed in the hope that it will be useful,
312+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
313+
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
314+
-- GNU $2General Public License for more details.
315+
--
316+
-- You should have received a copy of the GNU $2General Public License
317+
-- along with $1. If not, see <http://www.gnu.org/licenses/>.
318+
--
319+
-- Copyright (C) ${4:Author}, ${5:`!p snip.rv = get_year()`}
320+
321+
$0
322+
endsnippet
323+
324+
# vim:ft=snippets:

0 commit comments

Comments
 (0)