Class and shebang snippet for python
Some checks failed
Test Neovim config on push / build (ubuntu-20.04) (push) Has been cancelled
Some checks failed
Test Neovim config on push / build (ubuntu-20.04) (push) Has been cancelled
This commit is contained in:
@@ -44,3 +44,39 @@ if t[4] != "" and len(t[4].split(":")) > 1:
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet class "Python class description" b
|
||||
class ${1:`!p snip.rv = fn.split('.')[0]`}`!p
|
||||
if t[2] != "":
|
||||
snip.rv = " ("
|
||||
else:
|
||||
snip.rv = ""`${2:object}`!p
|
||||
if t[2] == "":
|
||||
snip.rv = ""
|
||||
else:
|
||||
snip.rv = ")"`:
|
||||
"""
|
||||
${3:Description of module $1.}
|
||||
"""
|
||||
def __init__(${4:self}`!p
|
||||
if not t[4].startswith("self"):
|
||||
t[4] = f"self, {t[4]}"
|
||||
t[4] = t[4].replace(' ', '')
|
||||
t[4] = t[4].replace(':', ': ')
|
||||
t[4] = t[4].replace(',', ', ')`):
|
||||
"""`!p
|
||||
parameters: list = t[4].split(", ")
|
||||
snip.rv = "\n"
|
||||
for parameter in parameters:
|
||||
parameter_meta = parameter.split(": ")
|
||||
if len(parameter_meta) == 1:
|
||||
snip.rv += f"\t\tnotype:\t{parameter_meta[0]}\n"
|
||||
else:
|
||||
snip.rv += f"\t\t{parameter_meta[0]}:\t{parameter_meta[1]}\n"`
|
||||
"""
|
||||
endsnippet
|
||||
|
||||
snippet #! "Environment Shebang" b
|
||||
#!/usr/bin/env bash
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
Reference in New Issue
Block a user