Skip to content

Commit

Permalink
update version to v0.0.4
Browse files Browse the repository at this point in the history
1. update some code block snippet for C.
2. add some code snippets for CPP.
  • Loading branch information
D0n9X1n committed May 4, 2017
1 parent 4a5ec8d commit 5fce307
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
m-vim.vimrc
---

[![GitHub version](https://badge.fury.io/gh/MikeCoder%2Fm-vim.vimrc.svg)](https://badge.fury.io/gh/MikeCoder%2Fm-vim.vimrc)
[![GitHub version](https://badge.fury.io/gh/MikeCoder%2Fm-vim.vimrc.svg)](https://badge.fury.io/gh/MikeCoder/m-vim.vimrc)

Yet, just another vim config project.

Expand Down
22 changes: 22 additions & 0 deletions UltiSnips/c.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,25 @@ if (${1}) {
${2}
}
endsnippet


snippet chead "#ifndef ... #define ... #endif"
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
#define ${1:SYMBOL} ${2:VALUE}
#endif /* ifndef $1 */
endsnippet

snippet fun "function"
${1:void}
${2:function_name}($3)
{
${VISUAL}$0
}
endsnippet

snippet fund "function declaration"
${1:void}
${2:function_name}($3);
endsnippet

# vim:ft=snippets:
122 changes: 122 additions & 0 deletions UltiSnips/cpp.snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
priority -50

extends c

# We want to overwrite everything in parent ft.
priority -48
###########################################################################
# 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

###########################################################################
# 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"`}
{
${VISUAL}$0
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
endsnippet

snippet readfile "read file (readF)"
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 "map (map)"
map<${1:key}, ${2:value}> map$0;
endsnippet

snippet vector "vector (v)"
vector<${1:char}> v$0;
endsnippet

snippet vector "vector (v)"
vector<${1:char}> v$0;
endsnippet

snippet list "list (v)"
list<${1:char}> v$0;
endsnippet

snippet set "set (v)"
set<${1:char}> v$0;
endsnippet

snippet tp "template <typename ..> (template)"
template <typename ${1:_InputIter}>
endsnippet

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:
$3

public:
$1();
virtual ~$1();
};

#endif /* $2 */
endsnippet


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})
{
${0:FunctionBody}
}
endsnippet
# vim:ft=snippets:

0 comments on commit 5fce307

Please sign in to comment.