2019-08-15 03:52:35 +00:00
|
|
|
|
global !p
|
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
2020-04-18 16:43:32 +00:00
|
|
|
|
def relative_date(days = 0):
|
2019-08-15 03:52:35 +00:00
|
|
|
|
time_difference = timedelta(days=int(days))
|
|
|
|
|
calculated_date = datetime.today() + time_difference
|
|
|
|
|
|
2020-11-12 15:44:48 +00:00
|
|
|
|
return calculated_date
|
2019-08-15 03:52:35 +00:00
|
|
|
|
endglobal
|
|
|
|
|
|
2022-04-24 13:19:53 +00:00
|
|
|
|
snippet "reldate (-?\d+)( .+)?" "Prints out the relative date in ISO format." ri
|
2020-11-12 15:44:48 +00:00
|
|
|
|
`!p
|
2019-08-15 03:52:35 +00:00
|
|
|
|
reldate = relative_date(match.group(1))
|
2020-04-02 15:42:52 +00:00
|
|
|
|
date_format = match.group(2).strip(" \"") if match.group(2) is not None else "%F"
|
|
|
|
|
snip.rv = reldate.strftime(date_format)
|
2019-08-15 03:52:35 +00:00
|
|
|
|
`
|
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
|
|
snippet today "Prints out today's date in ISO format" i
|
|
|
|
|
`!p
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
snip.rv = datetime.today().strftime("%F")
|
|
|
|
|
`
|
|
|
|
|
endsnippet
|
|
|
|
|
|
2020-04-18 16:43:32 +00:00
|
|
|
|
|
2020-11-12 15:44:48 +00:00
|
|
|
|
# Quick formatting.
|
2019-08-15 03:52:35 +00:00
|
|
|
|
snippet sign "Quick signature" i
|
|
|
|
|
${1:Sincerely,}
|
|
|
|
|
${2:Gabriel Arazas}
|
|
|
|
|
$0
|
|
|
|
|
endsnippet
|
|
|
|
|
|
2020-04-18 16:43:32 +00:00
|
|
|
|
snippet retrieve "Quick retrieval date in informal format" i
|
|
|
|
|
(retrieved `!p snip.rv = datetime.today().strftime("%F")`)
|
|
|
|
|
endsnippet
|
|
|
|
|
|
2019-12-20 02:44:54 +00:00
|
|
|
|
snippet ie "Parenthetical material Latin 'id est' (ie)" iw
|
2020-11-12 15:44:48 +00:00
|
|
|
|
(i.e., $1) $0
|
2019-12-20 02:44:54 +00:00
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
|
|
snippet eg "Parenthetical material Latin 'exempli gratia' (eg)" iw
|
|
|
|
|
(e.g., $1) $0
|
|
|
|
|
endsnippet
|
|
|
|
|
|
2020-04-18 16:43:32 +00:00
|
|
|
|
|
2020-11-12 15:44:48 +00:00
|
|
|
|
# En dashes
|
|
|
|
|
snippet -- "En dash"
|
|
|
|
|
–
|
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Em dashes (I've these dedicated snippets for some reason).
|
|
|
|
|
snippet --- "Em dash"
|
|
|
|
|
—
|
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
|
|
snippet em "Quick em dash"
|
2019-12-20 02:44:54 +00:00
|
|
|
|
—
|
|
|
|
|
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
|
|
|
|
|
|
2020-04-18 16:43:32 +00:00
|
|
|
|
|
2020-11-12 15:44:48 +00:00
|
|
|
|
# Quick word snippets
|
2019-12-20 02:44:54 +00:00
|
|
|
|
# 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
|
|
|
|
|
|
2020-04-18 16:43:32 +00:00
|
|
|
|
|
2020-11-12 15:44:48 +00:00
|
|
|
|
# Miscellaneous snippets
|
2020-03-26 18:52:38 +00:00
|
|
|
|
snippet #! "Quick snippet for a shebang." bi
|
|
|
|
|
#!${1:/usr/bin/env} ${2:sh}
|
|
|
|
|
endsnippet
|
|
|
|
|
|
2020-11-12 15:44:48 +00:00
|
|
|
|
# This is only useful for decorative comment boxes and all of the jazz.
|
2022-04-24 13:19:53 +00:00
|
|
|
|
snippet "boxen (.*)" "Create a box of stuff" ir
|
2020-04-02 15:42:52 +00:00
|
|
|
|
`!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)]`
|
|
|
|
|
endsnippet
|
|
|
|
|
|
2020-11-12 15:44:48 +00:00
|
|
|
|
# Also stolen from Gilles Castel's post at https://castel.dev/post/lecture-notes-1/.
|
2020-04-02 15:42:52 +00:00
|
|
|
|
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) + '┘'`
|
|
|
|
|
endsnippet
|
|
|
|
|
|