89 lines
1.7 KiB
Plaintext
89 lines
1.7 KiB
Plaintext
snippet fn "function declaration" i
|
|
// @name $1
|
|
// @return $3
|
|
// @brief ${4:Description}
|
|
// @param $2
|
|
fn $1($2) `!p
|
|
if t[3] == "":
|
|
snip.rv = ""
|
|
else:
|
|
snip.rv = " -> "` $3 {
|
|
$5
|
|
}
|
|
$0
|
|
endsnippet
|
|
|
|
snippet doxygen "Doxygen comment" b
|
|
// @name ${1:name}
|
|
// @return ${2:Return type}
|
|
// @param ${3:Parameter}
|
|
// @brief ${4:Description}
|
|
endsnippet
|
|
|
|
snippet struct "struct declaration"
|
|
// $1
|
|
// ${2:Description}
|
|
struct ${1:Name} {
|
|
$3
|
|
}
|
|
$0
|
|
endsnippet
|
|
|
|
snippet impl "implement struct"
|
|
// Implementation of $1
|
|
// ${2:Desciption}
|
|
impl ${1:struct} {
|
|
$3
|
|
}
|
|
$0
|
|
endsnippet
|
|
|
|
snippet for "for-loop"
|
|
for ${1:i} in ${2:$3..$4} {
|
|
$5
|
|
}$0
|
|
endsnippet
|
|
|
|
snippet while "while loop"
|
|
while $1 {
|
|
$2
|
|
} $0
|
|
endsnippet
|
|
|
|
global !p
|
|
import re
|
|
def create_parameter_placeholders(snip):
|
|
placeholders_amount = int(snip.buffer[snip.line].strip())
|
|
|
|
snip.buffer[snip.line] = ''
|
|
|
|
anon_snippet_body = 'println!("' + '{}'.join(['$' + str(i+1) for i in range(placeholders_amount)]) + f"${placeholders_amount}" + '"'
|
|
|
|
if placeholders_amount > 0:
|
|
anon_snippet_body = anon_snippet_body + ', '
|
|
|
|
anon_snippet_body = anon_snippet_body + ', '.join(['$' + str(i+1) for i in range(placeholders_amount, 2*placeholders_amount)]) + ");"
|
|
|
|
snip.expand_anon(anon_snippet_body)
|
|
endglobal
|
|
|
|
post_jump "create_parameter_placeholders(snip)"
|
|
snippet "print\d+" "println" rA
|
|
`!p snip.rv = match.group(1)`
|
|
endsnippet
|
|
|
|
snippet println "println" A
|
|
println!("$1");$0
|
|
endsnippet
|
|
|
|
snippet docstring "Document head" b
|
|
/*
|
|
* Filename: `!p snip.rv = fn`
|
|
* Author: ${1:Yannick Reiss}
|
|
* Project: ${2:Project Name}
|
|
* Copyright: ${3:None} => You • 9 months ago • Move of Snippets into repository
|
|
* Description: ${4:Funny module}
|
|
*
|
|
*/$0
|
|
endsnippet
|