Add '.vim/UltiSnips/' from commit '84cd9817817a28d58e92eb715273479509e51187'
git-subtree-dir: .vim/UltiSnips git-subtree-mainline: f258dd00078a9aebb235c358b6048aac250d445a git-subtree-split: 84cd9817817a28d58e92eb715273479509e51187
This commit is contained in:
193
UltiSnips/c.snippets
Normal file
193
UltiSnips/c.snippets
Normal file
@@ -0,0 +1,193 @@
|
||||
priority 0
|
||||
|
||||
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]
|
||||
elif len(opts) == 0:
|
||||
return "-error"
|
||||
return '(' + '|'.join(opts) + ')'
|
||||
endglobal
|
||||
|
||||
snippet i8 "int8_t" i
|
||||
int8_t
|
||||
endsnippet
|
||||
|
||||
snippet u8 "uint8_t" i
|
||||
uint8_t
|
||||
endsnippet
|
||||
|
||||
snippet i16 "int16_t" i
|
||||
int16_t
|
||||
endsnippet
|
||||
|
||||
snippet u16 "uint16_t" i
|
||||
uint16_t
|
||||
endsnippet
|
||||
|
||||
snippet i32 "int32_t" i
|
||||
int32_t
|
||||
endsnippet
|
||||
|
||||
snippet u32 "uint32_t" i
|
||||
uint32_t
|
||||
endsnippet
|
||||
|
||||
snippet i64 "int64_t" i
|
||||
int64_t
|
||||
endsnippet
|
||||
|
||||
snippet u64 "uint64_t" i
|
||||
uint64_t
|
||||
endsnippet
|
||||
|
||||
snippet #include "Include directive"
|
||||
#include <${1:header}>
|
||||
endsnippet
|
||||
|
||||
snippet #define "Macro definition"
|
||||
#define ${1:SYMBOL} $0
|
||||
endsnippet
|
||||
|
||||
snippet #ifndef "Guarded macro definition"
|
||||
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
|
||||
#define ${1:SYMBOL} ${0:VALUE}
|
||||
#endif // ${1/([A-Za-z0-9_]+).*/$1/}
|
||||
endsnippet
|
||||
|
||||
snippet #if "#if block"
|
||||
#if ${1:SYMBOL}
|
||||
$0
|
||||
#endif // ${1/([A-Za-z0-9_]+).*/$1/}
|
||||
endsnippet
|
||||
|
||||
snippet #ifdef "#if defined(...) block"
|
||||
#if defined(${1:SYMBOL})
|
||||
$0
|
||||
#endif // $1
|
||||
endsnippet
|
||||
|
||||
snippet once "Include guard"
|
||||
#ifndef ${2/([A-Za-z_]){1}([A-Za-z0-9_]+).*/$1$2/}$1
|
||||
#define $2${1:`!p import string
|
||||
snip.rv = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper()`_INCLUDED}
|
||||
|
||||
$0
|
||||
|
||||
#endif // ${2/([A-Za-z_]){1}([A-Za-z0-9_]+).*/$1$2/}$1
|
||||
endsnippet
|
||||
|
||||
snippet typedef "Typedef"
|
||||
typedef ${1:type} ${2:custom_type};$0
|
||||
endsnippet
|
||||
|
||||
snippet enum "Typedef enumeration"
|
||||
typedef enum ${1:name} {
|
||||
$0
|
||||
} $1;
|
||||
endsnippet
|
||||
|
||||
snippet struct "Typedef struct"
|
||||
typedef struct ${1:name} {
|
||||
$0
|
||||
} $1;
|
||||
endsnippet
|
||||
|
||||
snippet if "If statement"
|
||||
if (${1:condition}) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet else "Else continuation"
|
||||
else {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet elif "Else if continuation"
|
||||
else if (${1:condition}) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet for "For loop, index or range"
|
||||
for (${1:auto} ${2:index} ${3/(.*;.*)|(\w*)/(?1:=:\:)/} ${3:0; $2 < ${5:count}; $2${6:++}}) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet while "While loop"
|
||||
while (${1:condition}) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet do "Do while loop"
|
||||
do {
|
||||
$0
|
||||
} while (${1:condition})
|
||||
endsnippet
|
||||
|
||||
snippet switch "Switch statement"
|
||||
switch (${1:expression}) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet case "Switch case"
|
||||
case ${1:constant}: {
|
||||
$0
|
||||
} break;
|
||||
endsnippet
|
||||
|
||||
snippet default "Switch default case"
|
||||
default: {
|
||||
$0
|
||||
} break;
|
||||
endsnippet
|
||||
|
||||
snippet main "Main function stub"
|
||||
int main(int argc, char **argv) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
# TODO: Should this be in all.snippets?
|
||||
# 1. Take the form '<comment> TODO: issue ${1:id} $0'
|
||||
snippet todo "Todo comment"
|
||||
// TODO: redmine(${1:issue}) $0
|
||||
endsnippet
|
||||
|
||||
# TODO: Should this be in all.snippets?
|
||||
# 1. Take the form '<comment> NOTE: issue ${1:id} $0'
|
||||
snippet note "Note comment"
|
||||
// NOTE: $0
|
||||
endsnippet
|
||||
|
||||
snippet in "Doxygen [in]" i
|
||||
[in]
|
||||
endsnippet
|
||||
|
||||
snippet out "Doxygen [out]" i
|
||||
[out]
|
||||
endsnippet
|
||||
|
||||
snippet @param "Doxygen param tag"
|
||||
@param[$1`!p snip.rv = complete(t[1], ['in', 'out'])`]
|
||||
endsnippet
|
||||
|
||||
snippet doxygen "Doxygen file block" b
|
||||
/// @file
|
||||
///
|
||||
/// @brief $0
|
||||
///
|
||||
/// @coderight
|
||||
/// Copyright (C) 2002-2016 Codeplay Software Limited. All Rights Reserved.
|
||||
endsnippet
|
||||
|
||||
snippet copydoc "Doxygen copydoc block"
|
||||
/// @copydoc $0
|
||||
endsnippet
|
||||
Reference in New Issue
Block a user