~kaction/config

8f4e28c93e413881d878b92ded624e24f8658f41 — Dmitry Bogatov 2 years ago 1ab4be4 milestone/1
vim: drop custom implementation of snippets

Custom, primitive implementation of snippets proved to be of little
value. Their intended usecase is better covered by sed/awk/shell
scripts.
3 files changed, 0 insertions(+), 56 deletions(-)

M Tupfile
D aux/mk-template.c.m4
D aux/vim-snipcmd
M Tupfile => Tupfile +0 -3
@@ 60,7 60,6 @@ run ./aux/tup-copy
!vimspell    = |> $(RO) printf 'mkspell %o %f\nexit' | vim -e |>
!man         = |> $(RO) gzip %f -c > %o |>
!prog        = |> $(RO) cp -f %f %o |>
!gen-vimsnip = |> $(RO) m4 -P -DTHE_SOURCE=%f aux/mk-template.c.m4 > %o |>
!cc          = |> cc %f -o %o ; chmod 500 %o |>
!ftplugin    = |> $(RO) ./aux/fix-ftplugin %f > %o |>
!m4          = |> $(RO) m4 -P %f > %o |>


@@ 69,8 68,6 @@ run ./aux/tup-copy
: foreach src/man/*.1 |> !man |> out/dest/.local/share/man/man1/%B.1.gz {out}
: foreach src/prog/*  |> !prog |> out/dest/.local/bin/%B {out}
: foreach src/libexec/* |> !prog |> out/dest/prefix/libexec/%B {out}
: foreach src/snippet-txt/*.txt |> !gen-vimsnip |> out/snip/%B.c {vimsnip}
: foreach {vimsnip} |> !cc |> out/dest/prefix/config/vim/bin/%B {out}
: foreach src/ftplugin/*.vim |> !ftplugin |> out/dest/prefix/config/vim/after/ftplugin/%b {out}

POSIX = out/dest/prefix/config//posix

D aux/mk-template.c.m4 => aux/mk-template.c.m4 +0 -35
@@ 1,35 0,0 @@
m4_changequote(<|, |>)
#include <stdio.h>
#include <limits.h>
#include <ctype.h>
static const char bytes[] = {
	m4_esyscmd(xxd -i < THE_SOURCE), 0x0
};

/* If *p is digit, return it; return INT_MAX otherwise */
static int digit(const char *p)
{
	const char c = *p;
	if (isdigit(c)) {
		return c - '0';
	}
	return INT_MAX;
}

int
main(int argc, char **argv)
{
	const char *p = bytes;
	while (*p) {
		int ix;
		if (*p == '#' && ((ix = digit(p+1)) < argc)) {
			fputs(argv[ix], stdout);
			p += 2;
		} else {
			putchar(*p);
			p += 1;
		}
	}
	return 0;
}
// vim: ft=c

D aux/vim-snipcmd => aux/vim-snipcmd +0 -18
@@ 1,18 0,0 @@
#!/bin/sh -eu
cat << 'EOF'
function! s:template(name, ...)
  let command = "read!~/.vim/bin/" . a:name
  for ix in range(0, len(a:000) - 1)
    let command .= " " . shellescape(a:000[ix])
  endfor
  normal mT
  execute command
  normal 'T
endfunction
EOF

for base ; do
  printf                                                             \
    "command! -nargs=* I%s silent call s:template('%s', <f-args>)\n" \
    "${base}" "${base}"
done