Add fancy procedure and function snippet for Ada
Test Neovim config on push / build (ubuntu-20.04) (push) Failing after 29s
Details
Test Neovim config on push / build (ubuntu-20.04) (push) Failing after 29s
Details
This commit is contained in:
parent
7f8f120b7b
commit
61fb308e60
|
@ -1,3 +1,40 @@
|
||||||
|
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) + ")"
|
||||||
|
|
||||||
|
def find_candidate(tabstop, search_type):
|
||||||
|
# Split up the tabstop on semicolons
|
||||||
|
items = tabstop.replace("\n", "").replace(" ", "").split(";")
|
||||||
|
|
||||||
|
# find multiple same time assignments (a, b : Integer)
|
||||||
|
single_items = []
|
||||||
|
for item in items:
|
||||||
|
if (len(item.split(",")) > 1) and (len(item.split(":")) > 1):
|
||||||
|
variables = item.split(":")[0]
|
||||||
|
multi_type = item.split(":")[1]
|
||||||
|
for variable in variables.split(","):
|
||||||
|
single_items.append(f"{variable}:{multi_type}")
|
||||||
|
else:
|
||||||
|
single_items.append(item)
|
||||||
|
for candidate in single_items:
|
||||||
|
if len(candidate.split(":")) > 1:
|
||||||
|
name = candidate.split(":")[0]
|
||||||
|
candidate_type = candidate.split(":")[1]
|
||||||
|
else:
|
||||||
|
name = "None"
|
||||||
|
candidate_type = ""
|
||||||
|
|
||||||
|
if candidate_type == search_type:
|
||||||
|
return name
|
||||||
|
return "None"
|
||||||
|
endglobal
|
||||||
|
|
||||||
snippet helloworld "Hello world example to test features" b
|
snippet helloworld "Hello world example to test features" b
|
||||||
-- `!p snip.rv = fn`
|
-- `!p snip.rv = fn`
|
||||||
-- Created on: `date`
|
-- Created on: `date`
|
||||||
|
@ -15,11 +52,11 @@ begin
|
||||||
end $1;$0
|
end $1;$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet docstring "Document String with most important infor" b
|
snippet docstring "Document String with most important information" b
|
||||||
-- `!p snip.rv = fn`
|
-- `!p snip.rv = fn`
|
||||||
-- Created on: `date`
|
-- Created on: `date`
|
||||||
-- Author(s): ${1:Yannick Reiß}
|
-- Author(s): ${1:Yannick Reiß}
|
||||||
-- Content: ${2: Function `!p snip.rv = fn.split('.')[0]`}
|
-- Description: ${2:`!p snip.rv = fn.split('.')[0]`}
|
||||||
$0
|
$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
@ -31,54 +68,69 @@ snip.rv = ""
|
||||||
if t[2].startswith("l"):
|
if t[2].startswith("l"):
|
||||||
parameters = []
|
parameters = []
|
||||||
else:
|
else:
|
||||||
parameters = t[2].replace("\n", "").split(";");
|
parameters = t[2].replace("; ", ";").split(";");
|
||||||
for parameter in parameters:
|
for parameter in parameters:
|
||||||
if not parameter == "" and not parameter.startswith("typ"):
|
if not parameter == "" and not parameter.startswith("typ"):
|
||||||
paramless = parameter.replace("\t", "")
|
parameterless = parameter.replace("\t", "")
|
||||||
snip.rv += f"-- @variable {paramless}\n"
|
snip.rv += f"-- @parameter {parameterless}\n"
|
||||||
`-- @description $3
|
``!p
|
||||||
procedure ${1:Name} is
|
snip.rv = ""
|
||||||
$2
|
if t[3].startswith("l"):
|
||||||
|
variables = []
|
||||||
|
else:
|
||||||
|
variables = t[3].replace("\n", "").split(";");
|
||||||
|
for variable in variables:
|
||||||
|
if not variable == "" and not variable.startswith("typ"):
|
||||||
|
variableless = variable.replace("\t", "").replace (" ", "")
|
||||||
|
snip.rv += f"-- @variable {variableless}\n"
|
||||||
|
`-- @description $4
|
||||||
|
procedure ${1:`!p snip.rv = fn.split('.')[0].capitalize()`} `!p snip.rv = "" if t[2] == "" else "("`${2:N : Natural}`!p snip.rv = "" if t[2] == "" else ")"` is
|
||||||
|
$3
|
||||||
begin
|
begin
|
||||||
$4
|
$5
|
||||||
end $1;$0
|
end $1;$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet function "insert function" b
|
snippet function "insert function" b
|
||||||
-- @name $1
|
-- @name $1
|
||||||
-- @return $3
|
-- @return $3
|
||||||
-- @param $2
|
|
||||||
`!p
|
`!p
|
||||||
snip.rv = ""
|
snip.rv = ""
|
||||||
if t[4].startswith("l"):
|
if t[2].startswith("l"):
|
||||||
parameters = []
|
parameters = []
|
||||||
else:
|
else:
|
||||||
parameters = t[4].replace("\n", "").split(";")
|
parameters = t[2].replace("; ", ";").split(";");
|
||||||
for parameter in parameters:
|
for parameter in parameters:
|
||||||
if not parameter.startswith("typ") and not parameter == "":
|
if not parameter == "" and not parameter.startswith("typ"):
|
||||||
paramless = parameter.replace("\t", "")
|
parameterless = parameter.replace("\t", "")
|
||||||
snip.rv += f"-- @variable {paramless}\n"
|
snip.rv += f"-- @parameter {parameterless}\n"
|
||||||
|
``!p
|
||||||
|
snip.rv = ""
|
||||||
|
if t[4].startswith("l"):
|
||||||
|
variables = []
|
||||||
|
else:
|
||||||
|
variables = t[4].replace("\n", "").split(";");
|
||||||
|
for variable in variables:
|
||||||
|
if not variable == "" and not variable.startswith("typ") and not variable.startswith("--"):
|
||||||
|
variableless = variable.replace("\t", "").replace (" ", "")
|
||||||
|
snip.rv += f"-- @variable {variableless}\n"
|
||||||
`-- @description $5
|
`-- @description $5
|
||||||
function ${1:Name}${2:a, b: Integer}`!p if (t[2] != "" and not t[2].startswith("(")):
|
function ${1:`!p snip.rv = fn.split('.')[0].capitalize()`} `!p snip.rv = "" if t[2] == "" else "("`${2:N : Natural}`!p snip.rv = "" if t[2] == "" else ")"` return ${3:Natural} is
|
||||||
t[2] = f"({t[2]})"` return ${3:Integer} is
|
|
||||||
$4
|
$4
|
||||||
begin
|
begin
|
||||||
$7
|
$6
|
||||||
return ${6:`!p snip.rv = t[3]`};
|
|
||||||
|
return `!p
|
||||||
|
candidate = find_candidate(t[4], t[3])
|
||||||
|
if candidate == "None":
|
||||||
|
candidate = find_candidate(t[2], t[3])
|
||||||
|
if candidate == "None":
|
||||||
|
candidate = t[1]
|
||||||
|
snip.rv = candidate
|
||||||
|
`;
|
||||||
end $1;$0
|
end $1;$0
|
||||||
endsnippet
|
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
|
snippet if "If condition" b
|
||||||
if $1 then
|
if $1 then
|
||||||
$2
|
$2
|
||||||
|
@ -107,19 +159,6 @@ while ${1:Condition} loop
|
||||||
end loop;$0
|
end loop;$0
|
||||||
endsnippet
|
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
|
snippet type "declare a new type" bA
|
||||||
type ${1:TypeName} is ${2:array($3..$4) of }`!p
|
type ${1:TypeName} is ${2:array($3..$4) of }`!p
|
||||||
if t[2] == "record":
|
if t[2] == "record":
|
||||||
|
|
Loading…
Reference in New Issue