Ultisnips

This commit is contained in:
Yannick Reiß 2023-09-24 13:04:03 +02:00
parent 890a432a4e
commit 370f9e845f
No known key found for this signature in database
GPG Key ID: 5A3AF456F0A0338C
3 changed files with 21 additions and 13 deletions

View File

@ -8,13 +8,13 @@ endsnippet
snippet fun "New Function"
${1:int} ${2:MyFunc} (${3:void}) {
`!p
if t[1] != "void":
snip.rv = f"{t[1]} rv = 0;"
if t[1].replace('static ', '') != "void":
snip.rv = f"{t[1].replace('static ', '')} rv = 0;"
else:
snip.rv = ""`
$5
`!p
if t[1] != "void":
if t[1].replace('static ', '') != "void":
snip.rv = f"return rv;"
else:
snip.rv = ""`
@ -25,13 +25,13 @@ endsnippet
snippet "(\w+)->fun" "Struct function" r
${1:int} ${2:Name} (`!p snip.rv = match.group(1)`* self, ${4:void}) {
`!p
if t[1] != "void":
snip.rv = f"{t[1]} rv = 0;"
if t[1].replace('static ', '') != "void":
snip.rv = f"{t[1].replace('static ', '')} rv = 0;"
else:
snip.rv = ""`
$5
`!p
if t[1] != "void":
if t[1].replace('static ', '') != "void":
snip.rv = f"return rv;"
else:
snip.rv = ""`
@ -74,13 +74,13 @@ snip.rv = rval`
*/
${1:int} ${2:MyFunc} (${3:void}) {
`!p
if t[1] != "void":
snip.rv = f"{t[1]} rv = 0;"
if t[1].replace('static ', '') != "void":
snip.rv = f"{t[1].replace('static ', '')} rv = 0;"
else:
snip.rv = ""`
$5
`!p
if t[1] != "void":
if t[1].replace('static ', '') != "void":
snip.rv = f"return rv;"
else:
snip.rv = ""`

View File

@ -17,7 +17,7 @@ endsnippet
snippet exfun "New Function with Documentation"
/**
* @name $2
* @return $1
* @return `!p t[1].replace("static ", "")`
* @brief ${4: Description}
*
`!p
@ -31,12 +31,12 @@ snip.rv = rval`
${1:int} ${2:MyFunc} (${3:void}) {
`!p
if t[1] != "void":
snip.rv = f"{t[1]} rv = 0;"
snip.rv = f"{t[1].replace('static ', '')} rv = 0;"
else:
snip.rv = ""`
$5
`!p
if t[1] != "void":
if t[1].replace("static ", "") != "void":
snip.rv = f"return rv;"
else:
snip.rv = ""`
@ -49,7 +49,7 @@ ${1:int} ${2:Name} (${3:void}) {
$5
return ${6:`!p
if t[1] != "void":
if t[1].replace("static ", "") != "void":
snip.rv = f"0"
else:
snip.rv = ""`};

View File

@ -13,6 +13,14 @@ $1
$0
endsnippet
snippet cc "C Code" b
\`\`\`c
$1
\`\`\`
$0
endsnippet
snippet csql "SQL Code"
\`\`\`sql
$1