spacevim/bundle/vim-snippets/UltiSnips/markdown.snippets
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

149 lines
3.5 KiB
Plaintext

priority -50
global !p
# A overkill(dirty) table with automatic alignment feature
def create_table(snip):
# retrieving single line from current string and treat it like tabstops count
placeholders_string = snip.buffer[snip.line].strip()
rows_amount = int(placeholders_string[0])
columns_amount = int(placeholders_string[1])
prefix_str = "from vimsnippets import display_width;"
# erase current line
snip.buffer[snip.line] = ""
# create anonymous snippet with expected content and number of tabstops
anon_snippet_title = "| "
anon_snippet_delimiter = "|"
for col in range(1, columns_amount+1):
sync_rows = [x*columns_amount+col for x in range(rows_amount+1)]
sync_str = ",".join(["t[{0}]".format(x) for x in sync_rows])
max_width_str = "max(list(map(display_width, [" + sync_str + "])))"
cur_width_str = "display_width(t[" + str(col) + "])"
rv_val = "(" + max_width_str + "-" + cur_width_str + ")*' '"
anon_snippet_title += "${" + str(col) + ":head" + str(col)\
+ "}`!p " + prefix_str + "snip.rv=" + rv_val + "` | "
anon_snippet_delimiter += ":`!p " + prefix_str + "snip.rv = "\
+ max_width_str + "*'-'" + "`-|"
anon_snippet_title += "\n"
anon_snippet_delimiter += "\n"
anon_snippet_body = ""
for row in range(1, rows_amount+1):
body_row = "| "
for col in range(1, columns_amount+1):
sync_rows = [x*columns_amount+col for x in range(rows_amount+1)]
sync_str = ",".join(["t[{0}]".format(x) for x in sync_rows])
max_width_str = "max(list(map(display_width, [" + sync_str + "])))"
cur_width_str = "display_width(t[" + str(row*columns_amount+col) + "])"
rv_val = "(" + max_width_str + "-" + cur_width_str + ")*' '"
placeholder = "R{0}C{1}".format(row, col)
body_row += "${" + str(row*columns_amount+col) + ":" + placeholder\
+ "}`!p " + prefix_str + "snip.rv=" + rv_val + "` | "
body_row += "\n"
anon_snippet_body += body_row
anon_snippet_table = anon_snippet_title + anon_snippet_delimiter + anon_snippet_body
# expand anonymous snippet
snip.expand_anon(anon_snippet_table)
endglobal
###########################
# Sections and Paragraphs #
###########################
snippet sec "Section" b
# ${1:Section Name} #
$0
endsnippet
snippet ssec "Sub Section" b
## ${1:Section Name} ##
$0
endsnippet
snippet sssec "SubSub Section" b
### ${1:Section Name} ###
$0
endsnippet
snippet par "Paragraph" b
#### ${1:Paragraph Name} ####
$0
endsnippet
snippet spar "Paragraph" b
##### ${1:Paragraph Name} #####
$0
endsnippet
###################
# Text formatting #
###################
snippet * "italics"
*${1:${VISUAL}}*$0
endsnippet
snippet ** "bold"
**${1:${VISUAL}}**$0
endsnippet
snippet *** "bold italics"
***${1:${VISUAL}}***$0
endsnippet
snippet /* "Comment"
<!-- ${1:${VISUAL}} -->$0
endsnippet
################
# Common stuff #
################
snippet link "Link to something"
[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0
endsnippet
snippet img "Image"
![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0
endsnippet
snippet ilc "Inline Code" i
\`$1\`$0
endsnippet
snippet cbl "Codeblock" b
\`\`\`
$1
\`\`\`
$0
endsnippet
snippet refl "Reference Link"
[${1:${VISUAL:Text}}][${2:id}]$0
[$2]:${4:http://${3:www.url.com}} "${5:$4}"
endsnippet
snippet fnt "Footnote"
[^${1:${VISUAL:Footnote}}]$0
[^$1]:${2:Text}
endsnippet
snippet detail "Disclosure"
<details${3: open=""}>
${1:<summary>${2}</summary>}$0
</details>
endsnippet
post_jump "create_table(snip)"
snippet "tb([1-9][1-9])" "Fancy table" br
`!p snip.rv = match.group(1)`
endsnippet
# vim:ft=snippets: