nvim/UltiSnips/python.snippets

47 lines
765 B
Plaintext

snippet helloworld "Hello world example" b
"""
File: `!p snip.rv = fn`
Author: Nicki
Created on: `date`
Description: Hello world python example
"""
if __name__ == "__main__":
print("Hello world!")
$0
endsnippet
snippet docmodule "Documentation for modules"
"""
File: `!p snip.rv = fn`
Author: ${1:Yannick Reiß}
Created on: `date`
Description: ${2:No further description}
"""
$0
endsnippet
snippet def "Python Function"
def ${1:function}(${2}):
"""
@name $1
@brief ${3:function description}
Args:
`!p
params = t[2].replace(", ", ",").split(",")
snip.rv = ""
for param in params:
snip.rv += f"\t\t@param {param}\n"
`
Returns:
@return $4
"""
$5
`!p
if t[4] != "" and len(t[4].split(":")) > 1:
snip.rv = f"return {t[4].split(':')[0]}"`
$0
endsnippet