diff options
Diffstat (limited to 'lua/snippet')
-rw-r--r-- | lua/snippet/c.lua | 79 | ||||
-rw-r--r-- | lua/snippet/lua.lua | 14 | ||||
-rw-r--r-- | lua/snippet/makefile.lua | 41 | ||||
-rw-r--r-- | lua/snippet/shorthands.lua | 31 |
4 files changed, 0 insertions, 165 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);", - }), - } - ) -}) diff --git a/lua/snippet/lua.lua b/lua/snippet/lua.lua deleted file mode 100644 index c5466ff..0000000 --- a/lua/snippet/lua.lua +++ /dev/null @@ -1,14 +0,0 @@ -ls.add_snippets('lua', { - s({ - name = "local require", - trig = "req", - dscr = "simple lua require" - }, - fmt("local {} = require('{}')", - { - i(1, "default"), - ri(1), - } - ) - ) -}) diff --git a/lua/snippet/makefile.lua b/lua/snippet/makefile.lua deleted file mode 100644 index d15ef8d..0000000 --- a/lua/snippet/makefile.lua +++ /dev/null @@ -1,41 +0,0 @@ -ls.add_snippets('make', { - s({ - name = "Start Makefile", - trig = "make", - dscr = "simple starter make file" - }, - fmta( - [[ - # flags and incs - CFLAGS = <FLAGS> - INCS = <MAIN>.c - - PREFIX = <PREFIX> - - # compiler and linker - CC = cc - - all: <MAINA> - <MAINA>: <MAINA>.o - $(CC) <MAINA>.o $(CFLAGS) -o $@ - <MAINA>.o: $(INCS) - - clean: - rm -f <MAINA> *.o - - install: <MAINA> - mkdir -p $(PREFIX)/bin - cp -f <MAINA> $(PREFIX)/bin - chmod 755 $(PREFIX)/bin/<MAINA> - uninstall: <MAINA> - rm -f $(PREFIX)/bin/<MAINA> - ]], - { - FLAGS = i(1, "-Wall"), - MAIN = i(2, "main"), - PREFIX = i(3, "/usr/local"), - MAINA = ri(2), - } - ) - ), -}) diff --git a/lua/snippet/shorthands.lua b/lua/snippet/shorthands.lua deleted file mode 100644 index 05453bd..0000000 --- a/lua/snippet/shorthands.lua +++ /dev/null @@ -1,31 +0,0 @@ -ls = require("luasnip") -s = ls.snippet -sn = ls.snippet_node -isn = ls.indent_snippet_node -t = ls.text_node -i = ls.insert_node -f = ls.function_node -c = ls.choice_node -d = ls.dynamic_node -r = ls.restore_node -events = require("luasnip.util.events") -ai = require("luasnip.nodes.absolute_indexer") -extras = require("luasnip.extras") -l = extras.lambda -rep = extras.rep -p = extras.partial -m = extras.match -n = extras.nonempty -dl = extras.dynamic_lambda -fmt = require("luasnip.extras.fmt").fmt -fmta = require("luasnip.extras.fmt").fmta -conds = require("luasnip.extras.expand_conditions") -postfix = require("luasnip.extras.postfix").postfix -types = require("luasnip.util.types") -parse = require("luasnip.util.parser").parse_snippet - --- Repeat Insernode text --- @param insert_node_id The id of the insert node to repeat (the first line from) -ri = function (insert_node_id) - return f(function (args) return args[1][1] end, insert_node_id) -end |