Delete useless snippets, combining c and cpp snippets
Test Neovim config on push / build (ubuntu-20.04) (push) Failing after 25s
Details
Test Neovim config on push / build (ubuntu-20.04) (push) Failing after 25s
Details
This commit is contained in:
parent
8026306999
commit
f0b346271c
|
@ -2,6 +2,15 @@ extends cpp
|
|||
|
||||
priority 200
|
||||
|
||||
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]
|
||||
return '(' + '|'.join(opts) + ')'
|
||||
endglobal
|
||||
|
||||
snippet helloworld "Hello World"
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -15,6 +24,13 @@ for (${1:int ${2:i}} = ${3:0}; ${4:$2 < $5}; ${6:$2++}) {
|
|||
$0
|
||||
endsnippet
|
||||
|
||||
snippet while "while loop head"
|
||||
for (;$1;) {
|
||||
$2
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet fun "New Function"
|
||||
${1:int} ${2:MyFunc} (${3:void}) {
|
||||
`!p
|
||||
|
@ -32,27 +48,6 @@ else:
|
|||
$0
|
||||
endsnippet
|
||||
|
||||
snippet "(\w+)->fun" "Struct function" r
|
||||
${1:int} ${2:Name} (`!p snip.rv = match.group(1)`* self, ${4:void}) {
|
||||
`!p
|
||||
if t[1].replace('static ', '') != "void":
|
||||
snip.rv = f"{t[1].replace('static ', '')} rv = 0;"
|
||||
else:
|
||||
snip.rv = ""`
|
||||
$5
|
||||
`!p
|
||||
if t[1].replace('static ', '') != "void":
|
||||
snip.rv = f"return rv;"
|
||||
else:
|
||||
snip.rv = ""`
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet "self.(\w+)" "Struct call" r
|
||||
`!p snip.rv = match.group(1)`(self$1)$0
|
||||
endsnippet
|
||||
|
||||
snippet pfun "prototype for function" bA
|
||||
/**
|
||||
* @name $2
|
||||
|
@ -99,13 +94,6 @@ else:
|
|||
$0
|
||||
endsnippet
|
||||
|
||||
snippet while "while loop head"
|
||||
for (;$1;) {
|
||||
$2
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet "(\w+) = malloc" "Automativ malloc error implementation" rA
|
||||
/* Allocate memory for `!p snip.rv = match.group(1)` */
|
||||
`!p snip.rv = match.group(1)` = ($1*)malloc(sizeof(${1:int}) * $2);
|
||||
|
@ -117,17 +105,6 @@ if (!`!p snip.rv = match.group(1)`) {
|
|||
$0
|
||||
endsnippet
|
||||
|
||||
snippet "(\w+) = open" "Automatic open error implementation" r
|
||||
/* create descriptor `!p snip.rv = match.group(1)` for file $1 */
|
||||
`!p snip.rv = match.group(1)` = open(${1:"Filename"}, ${2:"MODE"});
|
||||
if (-1 == `!p snip.rv = match.group(1)`) {
|
||||
/* Error */
|
||||
perror(${4:"open error"});
|
||||
${5:exit(EXIT_FAILURE);}
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet swap "Swap two integer or numerical variables"
|
||||
/* Swap Variables $1 and $2 */
|
||||
${1:Var1} = $1 + ${2:Var2};
|
||||
|
@ -136,27 +113,6 @@ $1 = $1 - $2;
|
|||
$0
|
||||
endsnippet
|
||||
|
||||
snippet cast "adds cast" i
|
||||
(${1:void})$0
|
||||
endsnippet
|
||||
|
||||
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]
|
||||
return '(' + '|'.join(opts) + ')'
|
||||
endglobal
|
||||
|
||||
snippet printf "Cast printf result to 'void' if heturn value is unneeded" bA
|
||||
(void)printf("$1"`!p
|
||||
if "%" in t[1]:
|
||||
snip.rv = ", "
|
||||
else:
|
||||
snip.rv = ""`$2);$0
|
||||
endsnippet
|
||||
|
||||
snippet defstruct "define a new type with a struct" A
|
||||
/* define struct $1 ${2:Explaination} */
|
||||
typedef struct $1 $1;
|
||||
|
@ -165,10 +121,11 @@ struct $1 {
|
|||
};
|
||||
endsnippet
|
||||
|
||||
snippet docomment "Meta Comment for Documenation" A
|
||||
snippet docstring "Meta Comment for Documenation" A
|
||||
/*
|
||||
* Filename: `!p snip.rv = fn`
|
||||
* Author: ${1:Yannick Reiss}
|
||||
* Date: `date`
|
||||
* Project: ${2:Project Name}
|
||||
* Copyright: ${3:None}
|
||||
* Description: ${4:Funny module}
|
||||
|
@ -205,158 +162,10 @@ $8
|
|||
$0
|
||||
endsnippet
|
||||
|
||||
snippet let+ "Declare and initialize Variable" A
|
||||
${1:int} ${2:Variable} = ${3:0}; /* ${4:Description} */
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet let- "Declare Variable" A
|
||||
${1:int} ${2:Variable}; /* ${3:Description} */
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet "close\((\w+)\)" "Automatic close error implementation" brA
|
||||
/* Closing file `!p snip.rv = match.group(1)` */
|
||||
if (close(`!p snip.rv = match.group(1)`)) {
|
||||
/* Error */
|
||||
perror("${1:Could not close file!}");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet write( "Automatic write error check" A
|
||||
/* Write $3 bytes from $2 to file $1 */
|
||||
if (-1 == write(${1:file}, ${2:buffer}, ${3:bytes})) {
|
||||
/* Error */
|
||||
perror("${4:Could not write to file!}");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet /* "comment" A
|
||||
/* $1 */$0
|
||||
endsnippet
|
||||
|
||||
snippet "read\((.+), (.+), (.+)\);" "auto read" brA
|
||||
/* read `!p snip.rv = match.group(3)` from file `!p snip.rv = match.group(1)` intobuffer `!p snip.rv = match.goup(2)` */
|
||||
if (-1 == read(`!p snip.rv = match.group(1)`, `!p snip.rv = match.group(2)`, `!p snip.rv = match.group(3)`)) {
|
||||
/* Error */
|
||||
perror("${1:Could not read to file!})";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet "fstat\((.+), (.+)\);" "auto stat" brA
|
||||
/* load information about file `!p snip.rv = match.group(1)` into struct `!p snip.rv = match.group(2)` */
|
||||
if (fstat(`!p snip.rv = match.group(1)`, `!p snip.rv = match.group(2)`)) {
|
||||
/* Error */
|
||||
perror("${1:Could not fill struct with information!}");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet "ftruncate\((.+), (.+)\);" "ftruncate auto" brA
|
||||
/* Resize file `!p snip.rv = match.group(1)` to size `!p snip.rv = match.group(2)` */
|
||||
if (ftruncate(`!p snip.rv = match.group(1)`, `!p snip.rv = match.group(2)`)) {
|
||||
/* Error */
|
||||
perror("${1:Could not resize file!}j;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet 'system\("(.+)"\);' "Automatic system error implementation" rA
|
||||
/* run system command `!p snip.rv = match.group(1)` and check for success */
|
||||
if (system("`!p snip.rv = match.group(1)`")) {
|
||||
/* Error */
|
||||
perror(${1:"Could not execute shell command!"});
|
||||
${5:exit(EXIT_FAILURE);}
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet "if \(argc" "automatically add clarg check" A
|
||||
/* check for right number of arguments */
|
||||
if (argc ${1:!=} $2) {
|
||||
/* Error */
|
||||
perror("Wrong number of arguments");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet "(\w+) = fork" "Auto fork error implementation" rA
|
||||
/* create new subproccess `!p snip.rv = match.group(1)` */
|
||||
`!p snip.rv = match.group(1)` = fork();
|
||||
if (`!p snip.rv = match.group(1)` < 0) {
|
||||
/* Error */
|
||||
perror("fork error on creating new subprocess '`!p snip.rv = match.group(1)`'.");
|
||||
exit(EXIT_FAILURE);
|
||||
} else if (!`!p snip.rv = match.group(1)`) {
|
||||
/* fork runs from here */
|
||||
${1:execve(proc, args, NULL)};
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet pthread_create "pthreadcreate auto implement" A
|
||||
/* Creating thread $1 running function $3 */
|
||||
if (pthread_create(${1:thread}, ${2:NULL}, ${3:function}, ${4:args})) {
|
||||
perror("Could not create thread $1.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet pthread_mutex_unlock "mutex" iA
|
||||
/* Unlock mutex $1 */
|
||||
if ( pthread_mutex_unlock(&${1:mutex}) ) {
|
||||
perror("Could not unlock mutex $1.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet pthread_cond_wait "condition wait" iA
|
||||
/* wait for condition $1 on mutex $2 */
|
||||
if ( pthread_cond_wait(&${1:Condition}, &${2:mutex}) ) {
|
||||
perror("Could not wait for signal $1 on mutex $2.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet pthread_cond_signal "condition signal" iA
|
||||
/* Send signal $1 */
|
||||
if ( pthread_cond_signal(&${1:signal}) ) {
|
||||
perror("Could not send signal $1.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet pthread_mutex_lock "mutex" iA
|
||||
/* lock the mutex $1 */
|
||||
if ( pthread_mutex_lock(&${1:mutex}) ) {
|
||||
perror("Could not lock mutex $1.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet pthread_join "join thread" iA
|
||||
/* join the thread $1 */
|
||||
if ( pthread_join(${1:thread}, ${2:NULL}) ) {
|
||||
perror("Could not join thread $1.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet sigaction "signal action" i
|
||||
/* call function $2 on signal $1 */
|
||||
if ( sigaction(${1:SIGINT}, ${2:&act}, ${3:&old}) ) {
|
||||
perror("Could not change function of signal $1 to $2.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet fflush "flush stdout" iA
|
||||
/* flush stdout */
|
||||
if ( fflush(stdout) ) {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
extends c
|
||||
priority 100
|
||||
|
||||
snippet header "Header wrapper" b
|
||||
#ifndef $1
|
||||
#define $1
|
||||
|
@ -7,72 +10,6 @@ $0
|
|||
#endif//$1
|
||||
endsnippet
|
||||
|
||||
snippet for "For-loop head"
|
||||
for (${1:int i} = ${2:0}; ${3:i}; ${4:--i}) {
|
||||
$5
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet exfun "New Function with Documentation"
|
||||
/**
|
||||
* @name $2
|
||||
* @return `!p t[1].replace("static ", "")`
|
||||
* @brief ${4: Description}
|
||||
*
|
||||
`!p
|
||||
params = t[3].split(", ")
|
||||
rval = ""
|
||||
for param in params:
|
||||
if len(param.split(' ')) == 2:
|
||||
rval += f" * @param {param}:\t{t[2]}_{param.split(' ')[1]}\n"
|
||||
snip.rv = rval`
|
||||
*/
|
||||
${1:int} ${2:MyFunc} (${3:void}) {
|
||||
`!p
|
||||
if t[1] != "void":
|
||||
snip.rv = f"{t[1].replace('static ', '')} rv = 0;"
|
||||
else:
|
||||
snip.rv = ""`
|
||||
$5
|
||||
`!p
|
||||
if t[1].replace("static ", "") != "void":
|
||||
snip.rv = f"return rv;"
|
||||
else:
|
||||
snip.rv = ""`
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet fun "Function template"
|
||||
${1:int} ${2:Name} (${3:void}) {
|
||||
$5
|
||||
|
||||
return ${6:`!p
|
||||
if t[1].replace("static ", "") != "void":
|
||||
snip.rv = f"0"
|
||||
else:
|
||||
snip.rv = ""`};
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet while "while loop head"
|
||||
while (${1:true}) {
|
||||
$2
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet ifelse "If-Clause"
|
||||
if ($1) {
|
||||
$2
|
||||
} else {
|
||||
$3
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet class "Add new class" bA
|
||||
class $1 ${2::} `!p
|
||||
if t[2] == ":":
|
||||
|
@ -150,47 +87,3 @@ for var in variables:
|
|||
snip.rv = rv`
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet defstruct "define a new type with a struct" A
|
||||
typedef struct $1 $1;
|
||||
struct $1{
|
||||
$2
|
||||
};
|
||||
endsnippet
|
||||
|
||||
snippet docomment "Meta Comment" A
|
||||
/*
|
||||
* Filename: `!p snip.rv = fn`
|
||||
* Author: ${1:Yannick Reiss}
|
||||
* Project: ${2:Project Name}
|
||||
* Copyright: ${3:None}
|
||||
* Description: ${4:Helpful description}
|
||||
*/
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet let+ "Declare and initialize Variable" A
|
||||
${1:int} ${2:Variable} = ${3:0}; /* ${4:Description} */
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet let- "Declare Variable" A
|
||||
${1:int} ${2:Variable}; /* ${3:Description} */
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet pfun "prototype for function" bA
|
||||
/**
|
||||
* @name $2
|
||||
* @return $1
|
||||
* @brief ${4: Description}
|
||||
* `!p
|
||||
params = t[3].split(", ")
|
||||
rval = ""
|
||||
for param in params:
|
||||
if len(param.split(' ')) >= 2:
|
||||
rval += f"\n *\t@param {param}:\t{t[2]}_{param.split(' ')[1]}"
|
||||
snip.rv = rval`
|
||||
*/
|
||||
${1:int} ${2:MyFunc} (${3:void});
|
||||
endsnippet
|
||||
|
|
Loading…
Reference in New Issue