mirror of
https://github.com/amix/vimrc
synced 2025-06-17 02:15:01 +08:00
Updated plugins
This commit is contained in:
@ -11,6 +11,12 @@ priority -60
|
||||
##############
|
||||
global !p
|
||||
from vimsnippets import foldmarker, make_box, get_comment_format
|
||||
LOREM = """
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod \
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At \
|
||||
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, \
|
||||
no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
"""
|
||||
endglobal
|
||||
|
||||
snippet box "A nice box with the current comment symbol" b
|
||||
@ -56,11 +62,8 @@ endsnippet
|
||||
##########################
|
||||
# LOREM IPSUM GENERATORS #
|
||||
##########################
|
||||
snippet lorem "Lorem Ipsum - 50 Words" b
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
|
||||
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
|
||||
no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
snippet "lorem(([1-4])?[0-9])?" "Lorem Ipsum" r
|
||||
`!p snip.rv = " ".join(LOREM.split()[:int(match.group(1))]) if match.group(1) else LOREM`
|
||||
endsnippet
|
||||
|
||||
##########################
|
||||
@ -104,7 +107,7 @@ endsnippet
|
||||
# Misc #
|
||||
##########
|
||||
snippet uuid "Random UUID" w
|
||||
`!p if not snip.c: import uuid; snip.rv = uuid.uuid4()`
|
||||
`!p if not snip.c: import uuid; snip.rv = str(uuid.uuid4())`
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
|
@ -1,25 +1,55 @@
|
||||
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()[2:].split("x",1)
|
||||
rows_amount = int(placeholders_string[0])
|
||||
columns_amount = int(placeholders_string[1])
|
||||
# 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])
|
||||
|
||||
# erase current line
|
||||
snip.buffer[snip.line] = ''
|
||||
prefix_str = "from vimsnippets import display_width;"
|
||||
|
||||
# create anonymous snippet with expected content and number of tabstops
|
||||
anon_snippet_title = ' | '.join(['$' + str(col) for col in range(1,columns_amount+1)]) + "\n"
|
||||
anon_snippet_delimiter = ':-|' * (columns_amount-1) + ":-\n"
|
||||
anon_snippet_body = ""
|
||||
for row in range(1,rows_amount+1):
|
||||
anon_snippet_body += ' | '.join(['$' + str(row*columns_amount+col) for col in range(1,columns_amount+1)]) + "\n"
|
||||
anon_snippet_table = anon_snippet_title + anon_snippet_delimiter + anon_snippet_body
|
||||
# erase current line
|
||||
snip.buffer[snip.line] = ""
|
||||
|
||||
# expand anonymous snippet
|
||||
snip.expand_anon(anon_snippet_table)
|
||||
# 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
|
||||
|
||||
###########################
|
||||
@ -101,8 +131,9 @@ snippet fnt "Footnote"
|
||||
[^$1]:${2:Text}
|
||||
endsnippet
|
||||
|
||||
pre_expand "create_table(snip)"
|
||||
snippet "tb(\d+x\d+)" "Customizable table" br
|
||||
post_jump "create_table(snip)"
|
||||
snippet "tb([1-9][1-9])" "Fancy table" br
|
||||
`!p snip.rv = match.group(1)`
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
|
@ -497,8 +497,8 @@ def __coerce__(self, other):
|
||||
${25:pass}
|
||||
endsnippet
|
||||
|
||||
snippet deff
|
||||
def ${1:fname}(`!p snip.rv = vim.eval('indent(".") ? "self" : ""')`$2):
|
||||
snippet deff "function or class method"
|
||||
def ${1:fname}(`!p snip.rv = "self, " if snip.indent else ""`$2):
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
|
@ -6,53 +6,43 @@ priority -50
|
||||
# General Stuff #
|
||||
###########################################################################
|
||||
global !p
|
||||
import vim
|
||||
from os import path as ospath
|
||||
from string import Template
|
||||
import re
|
||||
from collections import Counter
|
||||
from vimsnippets import complete, has_cjk, display_width
|
||||
|
||||
from vimsnippets import complete
|
||||
|
||||
#http://docutils.sourceforge.net/docs/ref/rst/roles.html
|
||||
TEXT_ROLES = ['emphasis','literal','code','math',
|
||||
'pep-reference','rfc-reference',
|
||||
'strong','subscript','superscript',
|
||||
'title-reference','raw']
|
||||
# http://docutils.sourceforge.net/docs/ref/rst/roles.html
|
||||
TEXT_ROLES = ['emphasis', 'literal', 'code', 'math',
|
||||
'pep-reference', 'rfc-reference',
|
||||
'strong', 'subscript', 'superscript',
|
||||
'title-reference', 'raw']
|
||||
TEXT_ROLES_REGEX = r'\.\.\srole::?\s(w+)'
|
||||
|
||||
#http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
|
||||
# http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
|
||||
SPECIFIC_ADMONITIONS = ["attention", "caution", "danger",
|
||||
"error", "hint", "important", "note",
|
||||
"tip", "warning"]
|
||||
#http://docutils.sourceforge.net/docs/ref/rst/directives.html
|
||||
DIRECTIVES = ['topic','sidebar','math','epigraph',
|
||||
'parsed-literal','code','highlights',
|
||||
'pull-quote','compound','container','table','csv-table',
|
||||
'list-table','class','sectnum',
|
||||
'role','default-role','unicode',
|
||||
'raw']
|
||||
# http://docutils.sourceforge.net/docs/ref/rst/directives.html
|
||||
DIRECTIVES = ['code', 'contents', 'admonition', 'table', 'csv-table', 'list-table',
|
||||
'class', 'container', 'sidebar', 'topic', 'title',
|
||||
'role', 'default-role', 'raw']
|
||||
|
||||
NONE_CONTENT_DIRECTIVES = ['rubric', 'contents', 'header',
|
||||
'footer', 'date', 'include', 'title']
|
||||
# DIRECTIVES_WITHOUT_TITLE means directive arguments equal None
|
||||
DIRECTIVES_WITHOUT_TITLE = ['math', 'meta', 'parsed-literal', 'line-block',
|
||||
'header', 'compound', 'highlights', 'pull-quote',
|
||||
'footer', 'epigraph', 'rubric', 'sectnum']
|
||||
|
||||
INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include']
|
||||
# CJK chars
|
||||
# http://stackoverflow.com/questions/2718196/find-all-chinese-text-in-a-string-using-python-and-regex
|
||||
CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
|
||||
|
||||
#http://www.pygal.org/en/stable/documentation/types/index.html
|
||||
# Directives for Subsubsection Definition
|
||||
DIRECTIVES_FOR_SUBSTITUTION = ['replace', 'unicode', 'date']
|
||||
|
||||
# http://www.pygal.org/en/stable/documentation/types/index.html
|
||||
CHART_TYPES = ["Line", "StackedLine", "HorizontalLine", "Bar", "StackedBar", "HorizontalBar", "Histogram", "XY", "DateLine", "TimeLine", "TimeDeltaLine", "DateTimeLine", "Pie", "Radar", "Box", "Dot", "Funnel", "Gauge", "SolidGauge", "Pyramid", "Treemap"]
|
||||
|
||||
def has_cjk(s):
|
||||
"""Detect if s contains CJK characters."""
|
||||
return CJK_RE.search(s) is not None
|
||||
|
||||
def real_filename(filename):
|
||||
"""pealeextension name off if possible
|
||||
# i.e. "foo.bar.png will return "foo.bar"
|
||||
"""
|
||||
return ospath.splitext(filename)[0]
|
||||
return os.path.splitext(filename)[0]
|
||||
|
||||
def check_file_exist(rst_path, relative_path):
|
||||
"""
|
||||
@ -62,23 +52,10 @@ def check_file_exist(rst_path, relative_path):
|
||||
:param relative_path: path related to rst file
|
||||
:return: relative file's absolute path if file exist
|
||||
"""
|
||||
abs_path = ospath.join(ospath.dirname(rst_path), relative_path)
|
||||
if ospath.isfile(abs_path):
|
||||
abs_path = os.path.join(os.path.dirname(rst_path), relative_path)
|
||||
if os.path.isfile(abs_path):
|
||||
return abs_path
|
||||
|
||||
|
||||
try:
|
||||
rst_char_len = vim.strwidth # Requires Vim 7.3+
|
||||
except AttributeError:
|
||||
from unicodedata import east_asian_width
|
||||
def rst_char_len(s):
|
||||
"""Return the required over-/underline length for s."""
|
||||
result = 0
|
||||
for c in s:
|
||||
result += 2 if east_asian_width(c) in ('W', 'F') else 1
|
||||
return result
|
||||
|
||||
|
||||
def make_items(times, leading='+'):
|
||||
"""
|
||||
make lines with leading char multitimes
|
||||
@ -130,45 +107,45 @@ def get_popular_code_type():
|
||||
endglobal
|
||||
|
||||
snippet part "Part" b
|
||||
`!p snip.rv = rst_char_len(t[1])*'#'`
|
||||
`!p snip.rv = display_width(t[1])*'#'`
|
||||
${1:${VISUAL:Part name}}
|
||||
`!p snip.rv = rst_char_len(t[1])*'#'`
|
||||
`!p snip.rv = display_width(t[1])*'#'`
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet chap "Chapter" b
|
||||
`!p snip.rv = rst_char_len(t[1])*'*'`
|
||||
`!p snip.rv = display_width(t[1])*'*'`
|
||||
${1:${VISUAL:Chapter name}}
|
||||
`!p snip.rv = rst_char_len(t[1])*'*'`
|
||||
`!p snip.rv = display_width(t[1])*'*'`
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet sec "Section" b
|
||||
${1:${VISUAL:Section name}}
|
||||
`!p snip.rv = rst_char_len(t[1])*'='`
|
||||
`!p snip.rv = display_width(t[1])*'='`
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet ssec "Subsection" b
|
||||
${1:${VISUAL:Subsection name}}
|
||||
`!p snip.rv = rst_char_len(t[1])*'-'`
|
||||
`!p snip.rv = display_width(t[1])*'-'`
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet sssec "Subsubsection" b
|
||||
${1:${VISUAL:Subsubsection name}}
|
||||
`!p snip.rv = rst_char_len(t[1])*'^'`
|
||||
`!p snip.rv = display_width(t[1])*'^'`
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet para "Paragraph" b
|
||||
${1:${VISUAL:Paragraph name}}
|
||||
`!p snip.rv = rst_char_len(t[1])*'"'`
|
||||
`!p snip.rv = display_width(t[1])*'"'`
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
@ -228,7 +205,7 @@ endsnippet
|
||||
# img, inc, fig
|
||||
snippet id "Includable Directives" b
|
||||
`!p
|
||||
real_name=real_filename(ospath.basename(t[2]))
|
||||
real_name=real_filename(os.path.basename(t[2]))
|
||||
di=t[1][:2]
|
||||
|
||||
link=""
|
||||
@ -264,23 +241,30 @@ snippet di "Directives" b
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet nd "None Content Directives" b
|
||||
.. $1`!p snip.rv=complete(t[1], NONE_CONTENT_DIRECTIVES)`:: $2
|
||||
snippet dt "Directives without title" b
|
||||
.. $1`!p snip.rv=complete(t[1], DIRECTIVES_WITHOUT_TITLE)`::
|
||||
|
||||
${2:${VISUAL:Content}}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet ds "Directives for subscription" b
|
||||
.. |$1| $2`!p snip.rv=complete(t[2], DIRECTIVES_FOR_SUBSTITUTION)`:: ${3:Content}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet sa "Specific Admonitions" b
|
||||
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`::
|
||||
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`:: $2
|
||||
|
||||
${2:${VISUAL:Content}}
|
||||
${3:${VISUAL:Content}}
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
#it will be trigger at start of line or after a word
|
||||
# it will be trigger at start of line or after a word
|
||||
snippet ro "Text Roles" w
|
||||
\ :$1`!p snip.rv=complete(t[1],
|
||||
TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX,
|
||||
TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX,
|
||||
path))`:\`$2\`\
|
||||
endsnippet
|
||||
|
||||
@ -306,7 +290,7 @@ snippet chart "Pygal chart for Nikola" b
|
||||
.. chart:: $1`!p snip.rv=complete(t[1], CHART_TYPES)`
|
||||
:title: '${2:Browser usage evolution (in %)}'
|
||||
:x_labels: [${3:"2002", "2003", "2004", "2005", "2006", "2007"}]
|
||||
|
||||
|
||||
'Firefox', [None, None, 0, 16.6, 25, 31]
|
||||
'Chrome', [None, None, None, None, None, None]
|
||||
'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
|
||||
@ -323,4 +307,5 @@ snippet sid "SideBar" b
|
||||
|
||||
${2:${VISUAL:SideBar Content}}
|
||||
endsnippet
|
||||
# vim:ft=snippets:
|
||||
|
||||
# vim:set list noet sts=0 sw=4 ts=4:
|
||||
|
@ -1,25 +1,28 @@
|
||||
"""Helper methods used in UltiSnips snippets."""
|
||||
|
||||
import string, vim
|
||||
import string, vim, re
|
||||
|
||||
def complete(tab, opts):
|
||||
"""
|
||||
get options that start with tab
|
||||
get options that match with tab
|
||||
|
||||
:param tab: query string
|
||||
:param opts: list that needs to be completed
|
||||
|
||||
:return: a string that start with tab
|
||||
:return: a string that match with tab
|
||||
"""
|
||||
msg = "({0})"
|
||||
if tab:
|
||||
opts = [m[len(tab):] for m in opts if m.startswith(tab)]
|
||||
if len(opts) == 1:
|
||||
return opts[0]
|
||||
|
||||
if not len(opts):
|
||||
msg = "{0}"
|
||||
return msg.format("|".join(opts))
|
||||
el = [x for x in tab]
|
||||
pat = "".join(list(map(lambda x: x + "\w*" if re.match("\w", x) else x,
|
||||
el)))
|
||||
try:
|
||||
opts = [x for x in opts if re.search(pat, x, re.IGNORECASE)]
|
||||
except:
|
||||
opts = [x for x in opts if x.startswith(tab)]
|
||||
if not len(opts) or str.lower(tab) in list(map(str.lower, opts)):
|
||||
return ""
|
||||
cads = "|".join(opts[:5])
|
||||
if len(opts) > 5: cads += "|..."
|
||||
return "({0})".format(cads)
|
||||
|
||||
def _parse_comments(s):
|
||||
""" Parses vim's comments option to extract comment format """
|
||||
@ -69,7 +72,7 @@ def get_comment_format():
|
||||
commentstring = vim.eval("&commentstring")
|
||||
if commentstring.endswith("%s"):
|
||||
c = commentstring[:-2]
|
||||
return (c, c, c, "")
|
||||
return (c.rstrip(), c.rstrip(), c.rstrip(), "")
|
||||
comments = _parse_comments(vim.eval("&comments"))
|
||||
for c in comments:
|
||||
if c[0] == "SINGLE_CHAR":
|
||||
@ -90,3 +93,26 @@ def make_box(twidth, bwidth=None):
|
||||
def foldmarker():
|
||||
"Return a tuple of (open fold marker, close fold marker)"
|
||||
return vim.eval("&foldmarker").split(",")
|
||||
|
||||
|
||||
def display_width(str):
|
||||
"""Return the required over-/underline length for str."""
|
||||
try:
|
||||
# Respect &ambiwidth and &tabstop, but old vim may not support this
|
||||
return vim.strdisplaywidth(str)
|
||||
except AttributeError:
|
||||
# Fallback
|
||||
from unicodedata import east_asian_width
|
||||
result = 0
|
||||
for c in str:
|
||||
result += 2 if east_asian_width(c) in ('W', 'F') else 1
|
||||
return result
|
||||
|
||||
# http://stackoverflow.com/questions/2718196/find-all-chinese-text-in-a-string-using-python-and-regex
|
||||
def has_cjk(s):
|
||||
"""Detect if s contains CJK characters."""
|
||||
cjk_re = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
|
||||
|
||||
return cjk_re.search(s) is not None
|
||||
|
||||
# vim:set et sts=0 sw=4 ts=4:
|
||||
|
@ -724,7 +724,7 @@ snippet jc:sa
|
||||
snippet jc:se
|
||||
justify-content: space-evenly;
|
||||
snippet jc:st
|
||||
justify-content: space-evenly;
|
||||
justify-content: stretch;
|
||||
snippet jc:l
|
||||
justify-content: left;
|
||||
snippet jc:r
|
||||
|
@ -1,27 +1,74 @@
|
||||
extends html
|
||||
|
||||
snippet assign
|
||||
<#assign ${1} = ${0:${VISUAL}} />
|
||||
|
||||
snippet if
|
||||
<#if ${1}>
|
||||
# Freemarker version
|
||||
snippet ver "${.version}"
|
||||
\${.version}
|
||||
# Interpolation
|
||||
snippet int "${interpolation}"
|
||||
\${${0:interpolation${VISUAL}}\}
|
||||
# Interpolation with default string
|
||||
snippet intd "${interpolation!"default_string"}"
|
||||
\${${0:interpolation${VISUAL}}!"${1:default_string}"\}
|
||||
# Comment
|
||||
snippet com "<#-- comment -->"
|
||||
<#-- ${0:comment${VISUAL}} -->
|
||||
# Variable assignment on a single line
|
||||
snippet ass "<#assign variable_name = value />"
|
||||
<#assign ${1:variable_name} = ${0:value${VISUAL}} />
|
||||
# Variable assignments on multiple lines
|
||||
snippet assm "<#assign <#-- multiple lines --> />"
|
||||
<#assign
|
||||
${1:variable_name} = ${0:value${VISUAL}}
|
||||
/>
|
||||
# Local variable assignment on a single
|
||||
snippet loc "<#local variable_name = value />"
|
||||
<#local ${1:variable_name} = ${0:value${VISUAL}} />
|
||||
# Local variable assignments on multiple lines
|
||||
snippet locm "<#local <#-- multiple lines --> />"
|
||||
<#local
|
||||
${1:variable_name} = ${0:value${VISUAL}}
|
||||
/>
|
||||
# Include Freemarker file
|
||||
snippet inc "<#include \"file.ftl\" />"
|
||||
<#include "${0:file.ftl${VISUAL}}" />
|
||||
# If statement
|
||||
snippet if "<#if condition>...</#if>"
|
||||
<#if ${1:true}>
|
||||
${0:${VISUAL}}
|
||||
</#if>
|
||||
|
||||
snippet ife
|
||||
<#if ${1}>
|
||||
${2:${VISUAL}}
|
||||
# If/else statement
|
||||
snippet ife "<#if condition>...<#else>...</#if>"
|
||||
<#if ${1:true}>
|
||||
${0:${VISUAL}}
|
||||
<#else>
|
||||
${0}
|
||||
${2}
|
||||
</#if>
|
||||
|
||||
snippet list
|
||||
<#list ${1} as ${2}>
|
||||
# Iteration over a sequence
|
||||
snippet lis "<#list sequence as element>...</#list>"
|
||||
<#list ${1:sequence} as ${2:element}>
|
||||
${0:${VISUAL}}
|
||||
</#list>
|
||||
|
||||
snippet attempt
|
||||
# Iteration over an hashmap
|
||||
snippet lish "<#list hashmap?keys as element>...</#list>"
|
||||
<#list ${1:hashmap}?keys as ${2:key}>
|
||||
\${$2\}: \${$1[$2]\}${0:${VISUAL}}
|
||||
</#list>
|
||||
# Macro statement
|
||||
snippet mac "<#macro macro_name param1>...</#macro>"
|
||||
<#macro ${1:macro_name} ${2:param1}>
|
||||
${0:${VISUAL}}
|
||||
</#macro>
|
||||
# Function statement
|
||||
snippet fun "<#function function_name param1>...</#function>"
|
||||
<#function ${1:function_name} ${2:param1}>
|
||||
${0:${VISUAL}}
|
||||
</#function>
|
||||
# Attempt statement (try-catch to prevent runtime exceptions)
|
||||
snippet att "<#attempt>...<#recover></#attempt>"
|
||||
<#attempt>
|
||||
${0:${VISUAL}}
|
||||
<#recover>
|
||||
</#attempt>
|
||||
# Then built-in for booleans
|
||||
snippet ?th "?then(true, false)"
|
||||
?then(${1:true}, ${0:false${VISUAL}})
|
||||
|
@ -222,6 +222,23 @@ snippet test "test function"
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
|
||||
snippet testt "table test function"
|
||||
func Test${1:name}(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
}{
|
||||
{
|
||||
name: "${2:test name}",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
${0:${VISUAL}}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
snippet bench "benchmark function"
|
||||
func Benchmark${1:name}(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
@ -9,7 +9,8 @@ snippet fun "function"
|
||||
function ${1:function_name}(${2}) {
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
snippet fun "async function"
|
||||
# Asynchronous Function
|
||||
snippet asf "async function"
|
||||
async function ${1:function_name}(${2}) {
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
@ -282,6 +283,8 @@ snippet timeout
|
||||
setTimeout(function () {${0}}${2}, ${1:10});
|
||||
snippet const
|
||||
const ${1} = ${0};
|
||||
snippet constn
|
||||
const ${1} = new ${0};
|
||||
snippet let
|
||||
let ${1} = ${0};
|
||||
snippet im "import xyz from 'xyz'"
|
||||
|
@ -207,7 +207,7 @@ snippet define
|
||||
}
|
||||
|
||||
snippet service
|
||||
service { "${1:service}" :
|
||||
service { "${1:service}":
|
||||
ensure => running,
|
||||
enable => true,
|
||||
require => [ Package["${2:package}"], File["${3:file}"], ],
|
||||
@ -215,7 +215,7 @@ snippet service
|
||||
}
|
||||
|
||||
snippet file
|
||||
file { "${1:filename}" :
|
||||
file { "${1:filename}":
|
||||
ensure => ${2:present},
|
||||
owner => "${3:root}",
|
||||
group => "${4:root}",
|
||||
@ -227,7 +227,7 @@ snippet file
|
||||
}
|
||||
|
||||
snippet archive
|
||||
archive { "${1:filename}" :
|
||||
archive { "${1:filename}":
|
||||
ensure => ${2:present},
|
||||
url => "http://${3:url}",
|
||||
extension => "${4:tgz}",
|
||||
@ -237,7 +237,7 @@ snippet archive
|
||||
}
|
||||
|
||||
snippet firewall
|
||||
firewall { "${1:comment}" :
|
||||
firewall { "${1:comment}":
|
||||
proto => ${2:tcp},
|
||||
action => ${3:accept},
|
||||
port => ${4},
|
||||
|
@ -19,16 +19,17 @@ snippet -
|
||||
${0}
|
||||
#some directive
|
||||
snippet img:
|
||||
.. |${0:alias}| image:: ${1:img}
|
||||
.. |${1:alias}| image:: ${0:img}
|
||||
snippet fig:
|
||||
.. figure:: ${1:img}
|
||||
:alt: ${0:alter text}
|
||||
:alt: ${2:alter text}
|
||||
|
||||
$0
|
||||
snippet con:
|
||||
.. contents:: ${1:Table of Contents}
|
||||
|
||||
$2
|
||||
snippet cont:
|
||||
.. contents::
|
||||
${0:content}
|
||||
snippet code:
|
||||
snippet cod:
|
||||
.. code:: ${1:type}
|
||||
|
||||
${0:write some code}
|
||||
@ -65,34 +66,36 @@ snippet tod:
|
||||
.. todo::
|
||||
${0}
|
||||
snippet lis:
|
||||
.. list-table:: ${0:Title}
|
||||
.. list-table:: ${1:Title}
|
||||
:header-rows: 1
|
||||
:stub-columns: 1
|
||||
:stub-columns: 0
|
||||
|
||||
* - x1,y1
|
||||
- x2,y1
|
||||
- x3,y1
|
||||
* - x1,y2
|
||||
- x2,y2
|
||||
- x3,y2
|
||||
* - x1,y3
|
||||
- x2,y3
|
||||
- x3,y3
|
||||
* - ${0:R1C1}
|
||||
- R1C2
|
||||
* - R2C1
|
||||
- R2C2
|
||||
snippet csv:
|
||||
.. csv-table:: ${1:Title}
|
||||
:header-rows: 1
|
||||
:stub-columns: 0
|
||||
|
||||
${0:R1C1}, R1C2
|
||||
R2C1, R2C2
|
||||
snippet toc:
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
${0}
|
||||
snippet dow:
|
||||
:download:\`${0:text} <${1:path}>\`
|
||||
:download:\`${1:text} <${0:path}>\`
|
||||
snippet ref:
|
||||
:ref:\`${0:text} <${1:path}>\`
|
||||
:ref:\`${1:text} <${0:path}>\`
|
||||
snippet doc:
|
||||
:doc:`${0:text} <${1:path}>`
|
||||
:doc:\`${1:text} <${0:path}>\`
|
||||
# CJK optimize, CJK has no space between charaters
|
||||
snippet *c
|
||||
\ *${1:Emphasis}*\ ${0}
|
||||
snippet **c
|
||||
\ **${1:Strong emphasis}**\ ${0}
|
||||
|
||||
# vim:set list noet sts=0 sw=4 ts=4:
|
||||
|
@ -232,3 +232,7 @@ snippet macro "macro_rules!" b
|
||||
}
|
||||
snippet box "Box::new()"
|
||||
Box::new(${0:${VISUAL}})
|
||||
snippet rc "Rc::new()"
|
||||
Rc::new(${0:${VISUAL}})
|
||||
snippet unim "unimplemented!()"
|
||||
unimplemented!()
|
||||
|
@ -722,7 +722,7 @@ snippet jc:sa
|
||||
snippet jc:se
|
||||
justify-content: space-evenly
|
||||
snippet jc:st
|
||||
justify-content: space-evenly
|
||||
justify-content: stretch
|
||||
snippet jc:l
|
||||
justify-content: left
|
||||
snippet jc:r
|
||||
|
@ -222,6 +222,10 @@ snippet rm roman font text
|
||||
\\textrm{${1:${VISUAL:text}}}${0}
|
||||
snippet tt typewriter (monospace) text
|
||||
\\texttt{${1:${VISUAL:text}}}${0}
|
||||
snippet tsub subscripted text
|
||||
\\textsubscript{${1:${VISUAL:text}}}${0}
|
||||
snippet tsup superscripted text
|
||||
\\textsuperscript{${1:${VISUAL:text}}}${0}
|
||||
#Math font
|
||||
snippet mf mathfrak
|
||||
\\mathfrak{${1:${VISUAL:text}}}${0}
|
||||
|
@ -1 +1,43 @@
|
||||
extends javascript
|
||||
|
||||
snippet tconst "ts const"
|
||||
const ${1}: ${2:any} = ${3};
|
||||
${0}
|
||||
snippet tlet "ts let"
|
||||
let ${1}: ${2:any} = ${3};
|
||||
${0}
|
||||
snippet tvar "ts var"
|
||||
var ${1}: ${2:any} = ${3};
|
||||
${0}
|
||||
snippet + "var: type"
|
||||
${1}: ${0:any}
|
||||
snippet int "interface"
|
||||
interface ${1} {
|
||||
${2}: ${3:any};
|
||||
${0}
|
||||
}
|
||||
snippet intx "interface extends"
|
||||
interface ${1} extends ${2} {
|
||||
${3}: ${4:any};
|
||||
${0}
|
||||
}
|
||||
snippet tfun "ts function"
|
||||
function ${1}(${2}): ${3:any} {
|
||||
${0}
|
||||
}
|
||||
snippet tcla "ts class"
|
||||
class ${1} {
|
||||
${2}
|
||||
constructor(public ${3}: ${4: any}) {
|
||||
${5}
|
||||
}
|
||||
${0}
|
||||
}
|
||||
snippet tclax "ts class extends"
|
||||
class ${1} extends ${2} {
|
||||
${3}
|
||||
constructor(public ${4}: ${5: any}) {
|
||||
${6}
|
||||
}
|
||||
${0}
|
||||
}
|
||||
|
@ -76,3 +76,5 @@ snippet im
|
||||
imap ${1} ${2}
|
||||
snippet exe
|
||||
execute ${1}
|
||||
snippet filename
|
||||
`Filename()`
|
||||
|
@ -176,3 +176,14 @@ snippet vstore
|
||||
${1:key}: ${2:value}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
# vue-i18n snippets https://github.com/kazupon/vue-i18n
|
||||
|
||||
snippet trans
|
||||
$t('$1')
|
||||
|
||||
# Translation with parameter
|
||||
snippet transc
|
||||
$t('$1', { $2: $3 })
|
||||
|
||||
|
Reference in New Issue
Block a user