1
0
Fork 0
mirror of synced 2024-11-17 14:35:34 -05:00
ultimate-vim/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets

111 lines
2.3 KiB
Text
Raw Normal View History

priority -50
extends c
# We want to overwrite everything in parent ft.
priority -49
2017-03-07 12:04:28 -05:00
###########################################################################
# Global functions #
###########################################################################
global !p
def write_docstring_args(arglist, snip):
args = str(arglist).split(',')
if len(args) > 1:
c = 0
for arg in args:
if c == 0:
snip.rv += arg
c = 1
else:
snip += '* : %s' % arg.strip()
else:
snip.rv = args[0]
endglobal
2012-08-16 23:41:25 -04:00
###########################################################################
# TextMate Snippets #
###########################################################################
snippet beginend "$1.begin(), $1.end() (beginend)"
${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), $1${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end()
endsnippet
snippet cl "class .. (class)"
class ${1:`!p snip.rv = snip.basename or "name"`}
{
public:
${1/(\w+).*/$1/} (${2:arguments});
virtual ~${1/(\w+).*/$1/} ();
private:
${0:/* data */}
};
endsnippet
snippet ns "namespace .. (namespace)"
namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`}
{
2017-02-11 08:01:38 -05:00
${VISUAL}$0
2012-08-16 23:41:25 -04:00
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
endsnippet
snippet readfile "read file (readF)"
std::vector<char> v;
if (FILE *fp = fopen(${1:"filename"}, "r"))
{
char buf[1024];
while(size_t len = fread(buf, 1, sizeof(buf), fp))
v.insert(v.end(), buf, buf + len);
fclose(fp);
}
endsnippet
snippet map "std::map (map)"
std::map<${1:key}, ${2:value}> map$0;
endsnippet
snippet vector "std::vector (v)"
std::vector<${1:char}> v$0;
endsnippet
snippet tp "template <typename ..> (template)"
template <typename ${1:_InputIter}>
endsnippet
2016-04-12 04:31:09 -04:00
snippet cla "An entire .h generator" b
#ifndef ${2:`!v substitute(vim_snippets#Filename('$1_H','ClassName'),'.*','\U&\E','')`}
#define $2
class ${1:`!v substitute(substitute(vim_snippets#Filename('$1','ClassName'),'^.','\u&',''), '_\(\w\)', '\u\1', 'g')`}
{
private:
2017-02-11 08:01:38 -05:00
$3
2016-04-12 04:31:09 -04:00
public:
$1();
virtual ~$1();
};
#endif /* $2 */
endsnippet
2017-03-07 12:04:28 -05:00
snippet fnc "Basic c++ doxygen function template" b
/**
* @brief: ${4:brief}
*
* @param: `!p write_docstring_args(t[3],snip)`
*
* @return: `!p snip.rv = t[1]`
*/
${1:ReturnType} ${2:FunctionName}(${3:param})
{
2018-03-31 10:56:26 -04:00
${0:FunctionBody}
2017-03-07 12:04:28 -05:00
}
endsnippet
2012-08-16 23:41:25 -04:00
# vim:ft=snippets: