2019-08-22 12:25:27 +00:00
|
|
|
global !p
|
2020-03-25 16:41:57 +00:00
|
|
|
# Smartly automate inserting of certain characters.
|
|
|
|
# Mainly used for smart space insertion.
|
2019-08-22 12:25:27 +00:00
|
|
|
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
|
|
|
|
|
2019-08-21 12:33:45 +00:00
|
|
|
# Text formatting
|
2020-04-02 15:42:52 +00:00
|
|
|
snippet "h(([1-6]))" "Quick header snippet" bir
|
2019-08-21 12:33:45 +00:00
|
|
|
`!p
|
|
|
|
header_level = int(match.group(1))
|
|
|
|
legit_header_level = True if header_level >= 1 and header_level <= 6 else False
|
|
|
|
|
2020-03-26 18:52:38 +00:00
|
|
|
if header_level == 2:
|
|
|
|
snip.rv = "\n" * 4
|
|
|
|
else:
|
|
|
|
snip.rv = "\n" * 2
|
|
|
|
|
|
|
|
snip.rv += "=" * header_level if legit_header_level else ""
|
|
|
|
` ${1:Chapter name}
|
|
|
|
|
2019-08-21 12:33:45 +00:00
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2019-10-26 12:50:41 +00:00
|
|
|
snippet bf "Boldface" iw
|
|
|
|
**$1** $0
|
2019-08-22 12:25:27 +00:00
|
|
|
endsnippet
|
|
|
|
|
2019-10-26 12:50:41 +00:00
|
|
|
snippet it "Italic" iw
|
|
|
|
__$1__ $0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet tt "Monospace" iw
|
|
|
|
\`$1\` $0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet hl "Highlighted text" iw
|
2019-08-22 12:25:27 +00:00
|
|
|
#$1# $0
|
|
|
|
endsnippet
|
|
|
|
|
2019-09-30 01:26:57 +00:00
|
|
|
snippet a "Hyperlink" iw
|
|
|
|
${1:<url>}[${2:<text>}] $0
|
|
|
|
endsnippet
|
|
|
|
|
2020-04-29 15:58:14 +00:00
|
|
|
snippet link "Link for files" iw
|
|
|
|
link:${1:<url>}[`$1`]
|
|
|
|
endsnippet
|
|
|
|
|
2019-10-26 12:50:41 +00:00
|
|
|
snippet sp "Superscript" iw
|
2019-08-22 12:25:27 +00:00
|
|
|
^$1^ $0
|
|
|
|
endsnippet
|
|
|
|
|
2019-10-26 12:50:41 +00:00
|
|
|
snippet sb "Subscript" iw
|
2019-08-22 12:25:27 +00:00
|
|
|
~$1~ $0
|
|
|
|
endsnippet
|
|
|
|
|
2019-08-21 12:33:45 +00:00
|
|
|
snippet dt "Definition term" bi
|
|
|
|
${1:<term>}::
|
|
|
|
${2:<definition>}
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet ul "Unordered list item" bi
|
|
|
|
* ${1:<list item>}
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet ol "Ordered list item" bi
|
|
|
|
. ${1:<list item>}
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet -ol "Reversed ordered list (use it only once in a list)" bi
|
|
|
|
[%reversed]
|
|
|
|
. ${1:<list item>}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet bquote "Blockquote" bi
|
|
|
|
----
|
|
|
|
$1
|
|
|
|
----
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet src "Source code listings" bi
|
2020-03-25 16:41:57 +00:00
|
|
|
[source`!p snip.rv=smart_space(t[1], ", ", loose=True)`${1:<language>}]
|
2019-08-21 12:33:45 +00:00
|
|
|
----
|
|
|
|
${2:<source code>}
|
|
|
|
----
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet "-table (\d+)-" "Make a quick table" bir
|
|
|
|
[cols="`!p snip.rv = match.group(1)`*"]
|
|
|
|
|===
|
|
|
|
|
|
|
|
$1
|
|
|
|
|
|
|
|
|===
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2019-10-26 12:50:41 +00:00
|
|
|
snippet "-table h (\d+)-" "Make a quick table with the headers already set up" bir
|
2020-04-18 16:43:32 +00:00
|
|
|
[cols="`!p snip.rv = match.group(1)`", options="headers"`!p snip.rv=smart_space(t[1], ", ", loose=True)`$1]
|
2019-10-26 12:50:41 +00:00
|
|
|
|===
|
|
|
|
`!p
|
|
|
|
number_of_headers = int(match.group(1))
|
|
|
|
|
|
|
|
for i in range(0, number_of_headers):
|
2020-04-18 16:43:32 +00:00
|
|
|
snip += f"| Header {i + 1}"
|
2019-10-26 12:50:41 +00:00
|
|
|
`
|
|
|
|
$2
|
|
|
|
|
|
|
|
|===
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2019-08-22 12:25:27 +00:00
|
|
|
# Multimedia blocks
|
2019-08-21 12:33:45 +00:00
|
|
|
snippet figure "Image block with caption" bi
|
|
|
|
.${2:<caption>}
|
2019-09-30 01:26:57 +00:00
|
|
|
image::${1:<image path>}[$2, ${3:width=100%,height=100%}]
|
2019-08-21 12:33:45 +00:00
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet -figure "Inline image" i
|
|
|
|
image:${1:<image path>}[${2}] $0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet video "Video block" bi
|
|
|
|
video::${1:<image path>}[$2]
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet youtube "YouTube video block" bi
|
|
|
|
video::${1:<YouTube video ID>}[youtube]
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet vimeo "Vimeo video block" bi
|
|
|
|
video::${1:<Vimeo video ID>}[vimeo]
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2019-08-22 12:25:27 +00:00
|
|
|
snippet audio "Audio block" bi
|
|
|
|
audio::${1:<image path>}[`!p snip.rv=smart_space(t[2], "options=", loose=True)`$2]
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2019-08-21 12:33:45 +00:00
|
|
|
# Other features
|
|
|
|
snippet incl "Include document" bi
|
|
|
|
include::${1:<file path>}[${2:<options>}]
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet oblock "Open block" bi
|
|
|
|
--
|
|
|
|
$1
|
|
|
|
--
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2020-04-18 16:43:32 +00:00
|
|
|
snippet verbatim "Literal text block" bi
|
|
|
|
....
|
|
|
|
$1
|
|
|
|
....
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
|
2019-08-21 12:33:45 +00:00
|
|
|
snippet sidebar "Sidebar as an open block" bi
|
|
|
|
[sidebar]
|
|
|
|
.${1:<title>}
|
|
|
|
--
|
|
|
|
$2
|
|
|
|
--
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet abstract "Abstract block" bi
|
|
|
|
[abstract]
|
|
|
|
== ${1:Summary}
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2019-12-20 02:44:54 +00:00
|
|
|
snippet append "Appendix block" bi
|
2020-06-01 15:31:18 +00:00
|
|
|
`!p snip.rv = "\n" * 4`
|
2019-12-20 02:44:54 +00:00
|
|
|
[appendix]
|
2020-04-18 16:43:32 +00:00
|
|
|
== ${1:Additional readings}
|
2019-12-20 02:44:54 +00:00
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2020-04-18 16:43:32 +00:00
|
|
|
snippet bibres "Bibliographical resource in a definition block" bi
|
2020-04-29 15:58:14 +00:00
|
|
|
${1:<link>}[${2:<title>}] (retrieved ${3:date})::
|
2020-04-18 16:43:32 +00:00
|
|
|
${4:<description>}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
|
2019-12-20 02:44:54 +00:00
|
|
|
snippet stem "Stem block" bi
|
|
|
|
[stem]
|
|
|
|
++++
|
|
|
|
$1
|
|
|
|
++++
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2020-01-15 19:45:48 +00:00
|
|
|
snippet stem "Stem macro" iw
|
2019-12-20 02:44:54 +00:00
|
|
|
stem:[$1] $0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet foot "Footnote macro" iw
|
|
|
|
footnote:[$1] $0
|
|
|
|
endsnippet
|
|
|
|
|