Add A,B:Type Syntax to Ultisnips function snippet
This commit is contained in:
parent
f9ae3dfe99
commit
99e59d66e3
|
@ -100,7 +100,19 @@ if t[2].startswith("l"):
|
|||
parameters = []
|
||||
else:
|
||||
parameters = t[2].replace("; ", ";").split(";");
|
||||
parameter_list = []
|
||||
for parameter in parameters:
|
||||
if len(parameter.split(',')) == 1:
|
||||
parameter_list.append(parameter)
|
||||
else:
|
||||
try:
|
||||
list_type = parameter.split(':')[1]
|
||||
except:
|
||||
list_type = "???"
|
||||
list_parameters = parameter.split(':')[0].replace(' ', '').split(',')
|
||||
for sub_parameter in list_parameters:
|
||||
parameter_list.append(f"{sub_parameter} : {list_type}")
|
||||
for parameter in parameter_list:
|
||||
if not parameter == "" and not parameter.startswith("typ"):
|
||||
parameterless = parameter.replace("\t", "")
|
||||
snip.rv += f"-- @parameter {parameterless}\n"
|
||||
|
@ -114,7 +126,7 @@ 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:`!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
|
||||
$4
|
||||
begin
|
||||
|
@ -159,3 +171,9 @@ if t[6] == "y":
|
|||
system(f"mkdir -p {t[3]}")
|
||||
system(f"mkdir -p {t[4]}")`
|
||||
endsnippet
|
||||
|
||||
snippet package "Create package configuration" b
|
||||
package ${1:body }${2:`!p snip.rv = fn.split('.')[0]`} is
|
||||
$0
|
||||
end $2;
|
||||
endsnippet
|
||||
|
|
|
@ -21,3 +21,10 @@ endsnippet
|
|||
snippet -- "Add multiline comment" A
|
||||
(* $1 *)$0
|
||||
endsnippet
|
||||
|
||||
snippet begin "Create Code Block" b
|
||||
begin
|
||||
$1
|
||||
end;
|
||||
$0
|
||||
endsnippet
|
||||
|
|
Loading…
Reference in New Issue