mirror of
https://github.com/foo-dogsquared/dotfiles.git
synced 2025-01-31 10:57:58 +00:00
0681d1fd7c
It's been a while but I've been using NixOS (or anything styled like it like GuixSD, for example) and distro-hopped from Arch Linux. I think it's high noon for making the structure of this setup to be truer to one of the big objectives which is how easy to transfer this between different setups. Which means I removed some things such as the package lists, systemd config files, and package manager-specific configs. While the solution is easy (which is to simply ignore the system-specific files) but I'm not going with the pragmatic solution not because I'm a dumbass but because I'm so smart that I want to create a challenge for myself to solve a puzzle on figuring out a way on how to structure my dotfiles. :) Such a productive use of my time, that's for sure.
73 lines
1.8 KiB
Plaintext
Executable File
73 lines
1.8 KiB
Plaintext
Executable File
global !p
|
|
# Smartly automate inserting of certain characters.
|
|
# Mainly used for smart space insertion.
|
|
def smart_space(next_str, auto_str=" ", loose=False):
|
|
next_word = ""
|
|
|
|
if next_str:
|
|
if loose == True:
|
|
next_word = auto_str
|
|
elif next_str[0] in [",", ".", "-", "!", "?", " "]:
|
|
next_word = auto_str
|
|
|
|
return next_word
|
|
endglobal
|
|
|
|
snippet def "Define function with autocompleting docstrings" iw
|
|
def ${1:function_name}($2):
|
|
"""
|
|
${3:To be defined}
|
|
`!p
|
|
arguments = [ arg.strip() for arg in t[2].split(',') if arg != "self" or len(arg.strip()) > 0 ]
|
|
|
|
# Format the string with an indent.
|
|
snip >> 1
|
|
for arg in arguments:
|
|
split_arg = arg.split('=')
|
|
|
|
param = split_arg[0].strip()
|
|
if param:
|
|
snip += f":param: {param} - @TODO"
|
|
`
|
|
"""
|
|
endsnippet
|
|
|
|
# Quickly create a class definition.
|
|
# This is inspired from the demo GIF from the official GitHub page at https://github.com/sirver/UltiSnips.
|
|
snippet class "Class keyword with autocompleting docstrings" iw
|
|
class ${1:PICK_A_NAME_CLASS}`!p snip.rv = smart_space(t[2], '(', loose=True)`$2`!p snip.rv = smart_space(t[2], ')', loose=True)`:
|
|
""" ${3:Docstring for $1} """
|
|
|
|
def __init__(${4:self}):
|
|
"""
|
|
${5:Creates an instance of $1}
|
|
`!p
|
|
arguments = [ arg.strip() for arg in t[4].split(',') if arg != "self" or len(arg.strip()) > 0 ]
|
|
|
|
# Format the string with an indent.
|
|
snip >> 2
|
|
|
|
for arg in arguments:
|
|
split_arg = arg.split('=')
|
|
|
|
param = split_arg[0].strip()
|
|
|
|
if param:
|
|
snip += f":param: {param} - @TODO"
|
|
`
|
|
"""
|
|
|
|
`!p
|
|
# Shift by two indentation level
|
|
snip >> 2
|
|
snip += "" if not t[2] else f"{t[2]}.__init__(self)"
|
|
`
|
|
$6
|
|
endsnippet
|
|
|
|
snippet if_main "If __main__" biw
|
|
if __name__ == "__main__":
|
|
${1:print("Hello world!")}
|
|
endsnippet
|
|
|