180 lines
2.7 KiB
Plaintext
180 lines
2.7 KiB
Plaintext
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
|
|
|
|
# TODO: include
|
|
# 1. Default should be '#include <filename.h>'.
|
|
# 2. Relative paths should only allow inserting a single '"'.
|
|
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
|
|
endsnippet
|
|
|
|
snippet #if "#if block"
|
|
#if ${1:SYMBOL}
|
|
$0
|
|
#endif
|
|
endsnippet
|
|
|
|
snippet #ifdef "#if defined(...) block"
|
|
#ifdef ${1:SYMBOL}
|
|
$0
|
|
#endif
|
|
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"
|
|
for (${1:int} ${2:index} = ${3:0}; $2 ${4:<} ${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(${1:int argc, char **argv}) {
|
|
$0
|
|
}
|
|
endsnippet
|
|
|
|
snippet "/// p" "Doxygen param tag"
|
|
/// @param${1/.+/[/}$1${1/.+/]/} $0
|
|
endsnippet
|
|
|
|
snippet "/// b" "Doxygen brief tag"
|
|
/// @brief $0
|
|
endsnippet
|
|
|
|
snippet copydoc "Doxygen copydoc block"
|
|
/// @copydoc $0
|
|
endsnippet
|
|
|
|
snippet debug "Debug fprintf"
|
|
fprintf(stderr, "%s: %d: %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
|
|
endsnippet
|
|
|
|
snippet bs "bool string"
|
|
${1:value} ? "true" : "false"
|
|
endsnippet
|