Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
yanhao-pro committed Oct 20, 2022
2 parents 48aea49 + 208644a commit 95559cd
Show file tree
Hide file tree
Showing 86 changed files with 3,089 additions and 690 deletions.
15 changes: 9 additions & 6 deletions UltiSnips/all.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

##########################
Expand Down Expand Up @@ -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:
41 changes: 39 additions & 2 deletions UltiSnips/c.snippets
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
###########################################################################
# TextMate Snippets #
###########################################################################
# --------------
# Functions
# --------------
global !p
def printf_expand_args(snip):
"""
This will look how many placeholders printf has and adds the separated commas
at the end.
"""
# now add so many "," as much as the amount of placeholders
amount_placeholders = snip.tabstops[1].current_text.count("%")
output = ""
# Add the amount of tabstops
for placeholder_index in range(3, amount_placeholders + 3):
output += f", ${placeholder_index}"
# convert them into tabstops
snip.expand_anon(output)
endglobal

# ==============
# Snippets
# ==============
priority -50

snippet def "#define ..."
Expand Down Expand Up @@ -49,6 +75,16 @@ for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
}
endsnippet

snippet fora "for-loop" b
for (${1:var}; ${2:condition}; `!p
if len(t[1]) > 0:
snip.rv = t[1].split('=')[0].split()[-1]
`++) {

$0
} /* for ($1; $2; `!p if len(t[1]) > 0: snip.rv = t[1].split('=')[0].split()[-1]`++) */
endsnippet

snippet once "Include header once only guard"
#ifndef ${1:`!p
if not snip.c:
Expand All @@ -75,8 +111,9 @@ else if (${1:/* condition */}) {
}
endsnippet

snippet printf "printf .. (printf)"
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
post_jump "printf_expand_args(snip)"
snippet "printf" "printf with auto-expand args" wr
printf("$1\n"$2);
endsnippet

snippet st "struct"
Expand Down
76 changes: 76 additions & 0 deletions UltiSnips/cpp.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ endglobal
###########################################################################
# TextMate Snippets #
###########################################################################
snippet main
int main()
{
${0}
}
endsnippet

snippet forc "general for loop (for)"
for (${6:auto} ${1:i} = ${2:v.begin()}; `!p import re; snip.rv = re.split("[^\w]",t[1])[-1]` ${4:!=} ${3:`!p m = re.search(r'^(?:(.*)(\.|->)begin\(\)|((?:std|boost)::)?begin\((.*)\))$', t[2]); snip.rv = (((m.group(3) if m.group(3) else "") + "end(" + m.group(4) + ")") if m.group(4) else (m.group(1) + m.group(2) + "end()")) if m else ""`}; ${5:++`!p snip.rv = t[1].split(" ")[-1]`}) {
${VISUAL}$0
}
endsnippet

snippet beginend "$1.begin(), $1.end() (beginend)"
${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), $1${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end()
endsnippet
Expand Down Expand Up @@ -106,5 +119,68 @@ ${1:ReturnType} ${2:FunctionName}(${3:param})
{
${0:FunctionBody}
}
endsnippet

snippet boost_test "Boost test module" b
#define BOOST_TEST_MODULE ${1:TestModuleName}
#include <boost/test/included/unit_test.hpp>

BOOST_AUTO_TEST_CASE(${2:TestCaseName})
{
${0:TestDefinition}
}

endsnippet

snippet boost_suite "Boost test suite module" b
#define BOOST_TEST_MODULE ${1:TestModuleName}
#include <boost/test/included/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(${2:SuiteName})

BOOST_AUTO_TEST_CASE(${3:TestCaseName})
{
${0:TestDefinition}
}

BOOST_AUTO_TEST_SUITE_END()

endsnippet
snippet boost_test_fixture "Boost test module with fixture" b
#define BOOST_TEST_MODULE ${1:TestModuleName}
#include <boost/test/included/unit_test.hpp>

struct ${2:FixtureName} {
$2() {}
virtual ~$2() {}
/* define members here */
};

BOOST_FIXTURE_TEST_CASE(${3:SuiteName}, $2)
{
${0:TestDefinition}
}

endsnippet

snippet boost_suite_fixture "Boost test suite with fixture" b
#define BOOST_TEST_MODULE ${1:TestModuleName}
#include <boost/test/included/unit_test.hpp>

struct ${2:FixtureName} {
$2() {}
virtual ~$2() {}
/* define members here */
};

BOOST_FIXTURE_TEST_SUITE(${3:SuiteName}, $2)

BOOST_AUTO_TEST_CASE(${4:TestCaseName})
{
${0:TestDefinition}
}

BOOST_AUTO_TEST_SUITE_END()

endsnippet
# vim:ft=snippets:
25 changes: 19 additions & 6 deletions UltiSnips/cs.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,29 @@ endsnippet
# methods #
#############
snippet equals "Equals method" b
public override bool Equals(object obj)
snippet equals "Equality for a type" b
public override bool Equals(object obj) => Equals(obj as ${1:TYPE});
public bool Equals($1 other) // IEquatable<$1>
{
if (obj == null || GetType() != obj.GetType())
{
if (object.ReferenceEquals(other, null))
return false;
if (object.ReferenceEquals(this, other))
return true;
if (this.GetType() != other.GetType())
return false;
}
$0
return base.Equals(obj);
return base.Equals(other);
}
public override int GetHashCode() => base.GetHashCode();
public static bool operator ==($1 x, $1 y) =>
(object.ReferenceEquals(x, null) && object.ReferenceEquals(y, null))
|| (!object.ReferenceEquals(x, null) && x.Equals(y));
public static bool operator !=($1 x, $1 y) => !(x == y);
endsnippet
snippet mth "Method" b
Expand Down
4 changes: 2 additions & 2 deletions UltiSnips/css.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ snippet ! "!important CSS (!)"
endsnippet

snippet tsh "text-shadow: color-hex x y blur (text)"
text-shadow: ${1:${2:color} ${3:offset-x} ${4:offset-y} ${5:blur}};$0
text-shadow: ${1:${2:offset-x} ${3:offset-y} ${4:blur} ${5:color}};$0
endsnippet

snippet bxsh "box-shadow: color-hex x y blur (text)"
box-shadow: ${1:${2:offset-x} ${3:offset-y} ${4:blur} ${5:spread} ${6:color}};$0
box-shadow: ${1:${2:offset-x} ${3:offset-y} ${4:blur} ${5:spread} ${6:color} ${7:inset}};$0
endsnippet

#
Expand Down
1 change: 0 additions & 1 deletion UltiSnips/django.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ class ${1:MODELNAME}(models.Model):
def save(self):
return super($1, self).save()

@models.permalink
def get_absolute_url(self):
return ('')

Expand Down
10 changes: 10 additions & 0 deletions UltiSnips/ejs.snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
snippet for "ejs for loop" b
<% for (let ${1:i = 0}; ${2:i<arr.length}; ${3:i++}) { %>
${0:body}
<% } %>
endsnippet
snippet forE "ejs for Each loop" b
<% ${1:array}.forEach((${2:single var}) => { %>
${0:body}
<% }) %>
endsnippet
130 changes: 130 additions & 0 deletions UltiSnips/gitcommit.snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
global !p
def complete(t, opts):
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
return '(' + '|'.join(opts) + ')'
endglobal

snippet status "Status" bA
status $1`!p snip.rv = complete(t[1], ['build', 'ci', 'test', 'refactor', 'perf', 'improvement', 'docs', 'chore', 'feat', 'fix'])`
endsnippet

snippet fix "fix conventional commit"
fix(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet feat "feat conventional commit"
feat(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet chore "chore conventional commit"
chore(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet docs "docs conventional commit"
docs(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet improvement "improvement conventional commit"
improvement(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet perf "perf conventional commit"
perf(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet refactor "refactor conventional commit"
refactor(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet test "test conventional commit"
test(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet ci "ci conventional commit"
ci(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet build "build conventional commit"
build(${1:scope}): ${2:title}

${0:${VISUAL}}
endsnippet

snippet sign "Signature"
-------------------------------------------------------------------------------
${1:Company Name}

${2:Author Name}

${3:Streetname 21}
${4:City and Area}

${5:Tel: +44 (0)987 / 888 8888}
${6:Fax: +44 (0)987 / 888 8882}
${7:Mail: Email}
${8:Web: https://}
-------------------------------------------------------------------------------
$0
endsnippet

snippet t "Todo"
TODO: ${1:What is it} (`date "+%b %d %Y %a (%H:%M:%S)"`, `echo $USER`)
$0
endsnippet

snippet cmt "Commit Structure" bA
${1:Summarize changes in around 50 characters or less}

${2:More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.}

${3:Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.}

${4:Further paragraphs come after blank lines.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, preceded
by a single space, with blank lines in between, but conventions
vary here}

${5:Status}

${6:If you use an issue tracker, put references to them at the bottom,
like this.}

${7:Any todos}

${8:Resolves: #123
See also: #456, #789}

${9:Signature}
endsnippet
Loading

0 comments on commit 95559cd

Please sign in to comment.