summaryrefslogtreecommitdiffstats
path: root/lua/snippet/c.lua
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2024-08-09 02:45:31 -0400
committerSquibid <me@zacharyscheiman.com>2024-08-09 02:45:31 -0400
commitc489d393695e90d424f9ae51e35c4d42358e6a71 (patch)
tree12ea97ec4684fd82cd6b73dd127d0137b115837b /lua/snippet/c.lua
parentad76983d969c318e6e234bc82384b4b025d70447 (diff)
downloadnvim-c489d393695e90d424f9ae51e35c4d42358e6a71.tar.gz
nvim-c489d393695e90d424f9ae51e35c4d42358e6a71.tar.bz2
nvim-c489d393695e90d424f9ae51e35c4d42358e6a71.zip
yes there's a bit of java in my nvim config why do you ask?
Diffstat (limited to 'lua/snippet/c.lua')
-rw-r--r--lua/snippet/c.lua79
1 files changed, 0 insertions, 79 deletions
diff --git a/lua/snippet/c.lua b/lua/snippet/c.lua
deleted file mode 100644
index 7ef2e51..0000000
--- a/lua/snippet/c.lua
+++ /dev/null
@@ -1,79 +0,0 @@
-ls.add_snippets('c', {
- s('trip', {
- -- cond ? then : else statment
- i(1, 'cond'), t(' ? '), i(2, 'then'), t(' : '), i(3, 'else')
- }),
-
- s('stdlibs', {
- -- the normal stuff
- t('#include <stdio.h>'),
- t({'', '#include <stdlib.h>'})
- }),
-
- s('die', {
- -- message provieder when program is exiting
- t({
- 'void die(const char *fmt, ...) {', '',
- 'va_list ap;',
- '',
- 'va_start(ap, fmt);',
- 'vfprintf(stderr, fmt, ap);',
- 'va_end(ap);',
- '',
- [[if (fmt[0] && fmt[strlen(fmt)-1] == ':') {]],
- [[ fputc(' ', stderr);]],
- ' perror(NULL);',
- '} else',
- [[ fputc('\n', stderr);]],
- ' exit(1);',
- '}',
- })
- }),
-
- s({
- name = 'get them opts!',
- trig = 'getopt',
- dscr = 'standard argument parser',
- },
- fmta(
- [[
- int c;
-
- while ((c = getopt(argc, argv, "<OPTS>")) != -1) {
- switch (c) {
- case '<OPT1>': <OPT1RUN> break;
- default: <DEFRUN> break;
- }
- }
- ]],
- {
- OPTS = i(1, 'h'),
- OPT1 = i(2, 'h'),
- OPT1RUN = i(3, 'printf("help text\\n");'),
- DEFRUN = i(4, 'printf("run %s -h for help\\n", argv[0]); return 1;'),
- }
- )
- ),
- s({
- name = 'Variadic function parser',
- trig = 'infinite vars',
- dscr = 'Parse an infinite number of arguments passed to a function',
- },
- {
- t({
- "/*",
- " * NOTE: the function must have a int before the ... argument",
- " * and you need to include <stdarg.h> for this to work",
- " */",
- "va_list ptr;",
- "va_start(ptr, ", i(1, "n"),
- ");",
- "for (int i = 0; i < ", ri(1),
- "; i++) {",
- i(2),
- "}",
- "va_end(ptr);",
- }),
- }
- )
-})