dotfiles/nvim/own-snippets/all.snippets
Gabriel Arazas 0681d1fd7c Structure the project with NixOS-styled distros
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.
2020-09-11 03:12:26 +08:00

98 lines
2.3 KiB
Plaintext
Executable File

global !p
from datetime import datetime, timedelta
def relative_date(days = 0):
time_difference = timedelta(days=int(days))
calculated_date = datetime.today() + time_difference
return calculated_date
endglobal
snippet "reldate (\d+)( ".+")?" "Prints out the relative date in ISO format." ri
`!p
reldate = relative_date(match.group(1))
date_format = match.group(2).strip(" \"") if match.group(2) is not None else "%F"
snip.rv = reldate.strftime(date_format)
`
endsnippet
snippet today "Prints out today's date in ISO format" i
`!p
from datetime import datetime
snip.rv = datetime.today().strftime("%F")
`
endsnippet
# Quick formatting.
snippet sign "Quick signature" i
${1:Sincerely,}
${2:Gabriel Arazas}
$0
endsnippet
snippet retrieve "Quick retrieval date in informal format" i
(retrieved `!p snip.rv = datetime.today().strftime("%F")`)
endsnippet
snippet ie "Parenthetical material Latin 'id est' (ie)" iw
(i.e., $1) $0
endsnippet
snippet eg "Parenthetical material Latin 'exempli gratia' (eg)" iw
(e.g., $1) $0
endsnippet
# Em dashes (I've these dedicated snippets for some reason).
snippet em "Quick em dash"
endsnippet
snippet em-mat "Em dash material" iw
— $1 — $0
endsnippet
snippet em-ie "'id est' surrounded with em dash" iw
— i.e., $1 — $0
endsnippet
snippet em-eg "'exempli gratia' surrounded with em dash" iw
— e.g., $1 — $0
endsnippet
# Quick word snippets
# Each of these quick word snippets has a prefix of `qw-`
snippet qw-lx "LaTeX" iw
LaTeX
endsnippet
snippet qw-as "Asciidoctor" iw
Asciidoctor
endsnippet
# Miscellaneous snippets
snippet #! "Quick snippet for a shebang." bi
#!${1:/usr/bin/env} ${2:sh}
endsnippet
# This is only useful for decorative comment boxes and all of the jazz.
snippet "boxen '(.*)'" "Create a box of stuff" ir
`!p snip.rv = (match.group(1) * (len(t[1]) + 4)).strip()[0:(len(t[1]) + 4)]`
`!p snip.rv = match.group(1)[0]` $1 `!p snip.rv = match.group(1)[0]`
`!p snip.rv = (match.group(1) * (len(t[1]) + 4)).strip()[0:(len(t[1]) + 4)]`
$0
endsnippet
# Also stolen from Gilles Castel's post at https://castel.dev/post/lecture-notes-1/.
snippet box "More box (that looks more like a box)."
`!p snip.rv = '┌' + '─' * (len(t[1]) + 2) + '┐'`
│ $1 │
`!p snip.rv = '└' + '─' * (len(t[1]) + 2) + '┘'`
$0
endsnippet