mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -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 ..."
|
||||
@ -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:
|
||||
@ -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"
|
||||
|
@ -30,6 +30,12 @@ endglobal
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
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
|
||||
@ -106,5 +112,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:
|
||||
|
@ -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 ('')
|
||||
|
||||
|
@ -1,5 +1,13 @@
|
||||
priority -50
|
||||
|
||||
snippet impq "Qualified import"
|
||||
import qualified ${1:Data.Text} as ${0:`!p snip.rv = t[1].split(".")[-1]`}
|
||||
snippet imp "Simple import"
|
||||
import ${1:${2:Data}.${0:Text}}
|
||||
endsnippet
|
||||
|
||||
snippet imp2 "Selective import" b
|
||||
import ${1:${2:Data}.${3:Text}} (${4})${0}
|
||||
endsnippet
|
||||
|
||||
snippet impq "Qualified import"
|
||||
import qualified ${1:${2:Data}.${3:Text}} as ${0:`!p snip.rv = t[1].split(".")[-1]`}
|
||||
endsnippet
|
||||
|
@ -276,7 +276,7 @@ snippet htmll "HTML basic structure with the lang attribute" b
|
||||
<html lang="${1:es}">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>${2:`!p snip.rv = snip.basename.replace('-', ' ').capitalize()`}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -30,7 +30,7 @@ endsnippet
|
||||
snippet useCB "useCallback(fn, inputs)" b
|
||||
const ${1:callback} = useCallback((${2})) => ${3:{
|
||||
${4}
|
||||
}}, [${5}]
|
||||
}}, [${5}])
|
||||
endsnippet
|
||||
snippet useM "useMemo(fn, inputs)" b
|
||||
const ${1:memorized} = useMemo(() => ${2:{
|
||||
|
@ -104,7 +104,7 @@ endsnippet
|
||||
# Common stuff #
|
||||
################
|
||||
snippet link "Link to something"
|
||||
[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0
|
||||
[${1:${VISUAL:Text}}](${3:https://${2:www.url.com}})$0
|
||||
endsnippet
|
||||
|
||||
snippet img "Image"
|
||||
@ -125,7 +125,7 @@ endsnippet
|
||||
snippet refl "Reference Link"
|
||||
[${1:${VISUAL:Text}}][${2:id}]$0
|
||||
|
||||
[$2]:${4:http://${3:www.url.com}} "${5:$4}"
|
||||
[$2]:${4:https://${3:www.url.com}} "${5:$4}"
|
||||
endsnippet
|
||||
|
||||
snippet fnt "Footnote"
|
||||
|
@ -45,8 +45,8 @@ snippet .it ".iter()" i
|
||||
endsnippet
|
||||
|
||||
snippet impl "Struct/Trait implementation" b
|
||||
impl ${1:Type/Trait}${2: for ${3:Type}} {
|
||||
$0
|
||||
impl$4 ${1:Type/Trait}${2: for ${3:Type}}${4:<${5:T}>} {
|
||||
${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -9,15 +9,15 @@ def create_table(snip):
|
||||
cols = snip.buffer[snip.line].split('x')[1]
|
||||
|
||||
int_val = lambda string: int(''.join(s for s in string if s.isdigit()))
|
||||
|
||||
|
||||
rows = int_val(rows)
|
||||
cols = int_val(cols)
|
||||
|
||||
offset = cols + 1
|
||||
old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1]
|
||||
|
||||
|
||||
snip.buffer[snip.line] = ''
|
||||
|
||||
|
||||
final_str = old_spacing + "\\begin{tabular}{|" + "|".join(['$' + str(i + 1) for i in range(cols)]) + "|}\n"
|
||||
|
||||
for i in range(rows):
|
||||
@ -35,7 +35,7 @@ def add_row(snip):
|
||||
old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1]
|
||||
|
||||
snip.buffer[snip.line] = ''
|
||||
|
||||
|
||||
final_str = old_spacing
|
||||
final_str += " & ".join(['$' + str(j + 1) for j in range(row_len)])
|
||||
final_str += " \\\\\\"
|
||||
@ -63,7 +63,7 @@ $0${2/(?<=.)(c|l|r)|./(?1: & )/g}
|
||||
endsnippet
|
||||
|
||||
pre_expand "create_table(snip)"
|
||||
snippet "gentbl(\d+)x(\d+)" "Generate table of *width* by *height*" r
|
||||
snippet "gentbl(\d+)x(\d+)" "Generate table of *width* by *height*" r
|
||||
endsnippet
|
||||
|
||||
pre_expand "add_row(snip)"
|
||||
@ -193,8 +193,6 @@ snippet acl "Acroynm expanded" b
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
|
||||
|
||||
snippet ni "Non-indented paragraph" b
|
||||
\noindent
|
||||
$0
|
||||
@ -241,4 +239,20 @@ snippet glnl "New long glossary item" b
|
||||
${0:description}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
# Bold text
|
||||
snippet bf "Bold"
|
||||
\textbf{$1} $0
|
||||
endsnippet
|
||||
|
||||
# Italic text
|
||||
snippet ita "Italics"
|
||||
\textit{$1} $0
|
||||
endsnippet
|
||||
|
||||
# Underlined text
|
||||
snippet und "Underline"
|
||||
\underline{$1} $0
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
|
Reference in New Issue
Block a user