132 lines
2.8 KiB
Plaintext
132 lines
2.8 KiB
Plaintext
snippet textio "Insert Textio import" b
|
|
with Ada.Text_IO;$0
|
|
endsnippet
|
|
|
|
snippet procedure "insert procedure" b
|
|
-- @name $1
|
|
-- @return
|
|
`!p
|
|
snip.rv = ""
|
|
if t[2].startswith("l"):
|
|
parameters = []
|
|
else:
|
|
parameters = t[2].replace("\n", "").split(";");
|
|
for parameter in parameters:
|
|
if not parameter == "" and not parameter.startswith("typ"):
|
|
paramless = parameter.replace("\t", "")
|
|
snip.rv += f"-- @variable {paramless}\n"
|
|
`-- @description $3
|
|
procedure ${1:Name} is
|
|
$2
|
|
begin
|
|
$4
|
|
end $1;$0
|
|
endsnippet
|
|
|
|
snippet function "insert function" b
|
|
-- @name $1
|
|
-- @return $3
|
|
-- @param $2
|
|
`!p
|
|
snip.rv = ""
|
|
if t[4].startswith("l"):
|
|
parameters = []
|
|
else:
|
|
parameters = t[4].replace("\n", "").split(";")
|
|
for parameter in parameters:
|
|
if not parameter.startswith("typ") and not parameter == "":
|
|
paramless = parameter.replace("\t", "")
|
|
snip.rv += f"-- @variable {paramless}\n"
|
|
`-- @description $5
|
|
function ${1:Name}${2:a, b: Integer}`!p if (t[2] != "" and not t[2].startswith("(")):
|
|
t[2] = f"({t[2]})"` return ${3:Integer} is
|
|
$4
|
|
begin
|
|
$7
|
|
return ${6:`!p snip.rv = t[3]`};
|
|
end $1;$0
|
|
endsnippet
|
|
|
|
global !p
|
|
def complete(t, opts):
|
|
if t:
|
|
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
|
|
if len(opts) == 1:
|
|
return opts[0]
|
|
if len(opts) > 5:
|
|
opts = opts[0:5]
|
|
return "(" + "|".join(opts) + ")"
|
|
endglobal
|
|
|
|
snippet if "If condition" b
|
|
if $1 then
|
|
$2
|
|
$3`!p snip.rv = complete(t[3], ["elsif", "else", "end if;"])` ${4:`!p if t[3] == "elsif":
|
|
snip.rv = "condition"
|
|
else:
|
|
snip.rv = ""`} `!p
|
|
if t[3] == "elsif":
|
|
snip.rv = "then"`
|
|
$5
|
|
`!p if t[3] == "end if;":
|
|
snip.rv = ""
|
|
else:
|
|
snip.rv = "end if;"`$0
|
|
endsnippet
|
|
|
|
snippet for "For loop" b
|
|
for ${1:i} ${2:in ${3:1}..${4:10}} loop
|
|
$5
|
|
end loop;$0
|
|
endsnippet
|
|
|
|
snippet while "While loop" b
|
|
while ${1:Condition} loop
|
|
$2
|
|
end loop;$0
|
|
endsnippet
|
|
|
|
snippet let "Create new Variable" bA
|
|
${1:letName}`!p if not t[1].startswith("let"):
|
|
t[1] = t[1].capitalize()``!p snip.rv = "\t:\t"`${2}`!p if t[2].startswith("!"):
|
|
snip.rv = ""
|
|
else:
|
|
snip.rv = complete(t[2], ["Integer", "Boolean", "Float", "Natural", "Positive", "Negative", "Long_Float", "String"])
|
|
``!p if t[3] == "":
|
|
snip.rv = ""
|
|
else:
|
|
snip.rv = " := "
|
|
`$3;
|
|
endsnippet
|
|
|
|
snippet type "declare a new type" bA
|
|
type ${1:TypeName} is ${2:array($3..$4) of }`!p
|
|
if t[2] == "record":
|
|
snip.rv = "\n\t\t"
|
|
else:
|
|
snip.rv = ""`$5`!p
|
|
if t[2] == "record":
|
|
snip.rv = "\n\tend record"
|
|
else:
|
|
snip.rv = ""
|
|
`;$0
|
|
endsnippet
|
|
|
|
snippet docstring "Document String with most important infor" b
|
|
-- `!p snip.rv = fn`
|
|
-- Created on: `date`
|
|
-- Author(s): ${1:Yannick Reiß}
|
|
-- Content: ${2: Function `!p snip.rv = fn.split('.')[0]`}
|
|
$0
|
|
endsnippet
|
|
|
|
snippet project "Project" b
|
|
project ${1:Default} is
|
|
for Source_Dirs use ("${2:src}");
|
|
for Object_Dir use "${3:obj}";
|
|
for Exec_Dir use "${4:bin}";
|
|
for Main use ("${5:main.adb}");
|
|
for Languages use ("Ada");
|
|
end $1;
|
|
endsnippet
|