feat(nvim): add Common Lisp snippets

This commit is contained in:
George Rawlinson 2022-06-16 20:44:00 +12:00
parent 7bb8288d93
commit e281057f7a
Signed by: grawlinson
GPG key ID: E0959FEA8B550539

View file

@ -1,5 +1,9 @@
priority -50 priority -50
#
# General snippets
#
snippet maint "Maintainer tag" i snippet maint "Maintainer tag" i
`#!/usr/bin/env bash `#!/usr/bin/env bash
echo "# Maintainer:" $(cat /etc/makepkg.conf $XDG_CONFIG_HOME/pacman/makepkg.conf 2>/dev/null | grep -oP '^PACKAGER="\K[^"]+') echo "# Maintainer:" $(cat /etc/makepkg.conf $XDG_CONFIG_HOME/pacman/makepkg.conf 2>/dev/null | grep -oP '^PACKAGER="\K[^"]+')
@ -13,11 +17,11 @@ pkgrel=${3:1}
pkgdesc='$4' pkgdesc='$4'
arch=(${5:'any'}) arch=(${5:'any'})
url='$6' url='$6'
license=($7) license=('$7')
depends=($8) depends=('$8')
makedepends=($9) makedepends=('$9')
checkdepends=($10) checkdepends=('$10')
optdepends=($11) optdepends=('$11')
options=('!lto') options=('!lto')
source=("$pkgname::git+$12") source=("$pkgname::git+$12")
b2sums=('SKIP') b2sums=('SKIP')
@ -31,12 +35,25 @@ prepare() {
} }
endsnippet endsnippet
snippet patch "patch files" i
`#!/usr/bin/env bash
source PKGBUILD
for s in "${source[@]}"; do
if [[ "$s" == *".patch"* ]]; then
printf "patch --strip=1 --input=\"\$srcdir/%s\"\n" "${s%::*}"
fi
done
`
endsnippet
snippet ver "pkgver" i snippet ver "pkgver" i
pkgver() { pkgver() {
cd "$pkgname"$1 cd "$pkgname"$1
git describe --tags | sed 's/^v//' git describe --tags | sed 's/^v//'
git describe --tags | sed -e 's/^v//' -e 's/-/.r/' -e 's/-/./g'
printf 'r%s.g%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" printf 'r%s.g%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
} }
endsnippet endsnippet
@ -65,7 +82,6 @@ package() {
} }
endsnippet endsnippet
## General package() snippets
snippet pkgbin "Package binary" i snippet pkgbin "Package binary" i
# binary # binary
install -vDm755 -t "$pkgdir/usr/bin" $1 install -vDm755 -t "$pkgdir/usr/bin" $1
@ -81,8 +97,10 @@ snippet pkglic "Package license" i
install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" $1 install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" $1
endsnippet endsnippet
## Go specific #
snippet goprep "Prepare (Go)" i # Go specific
#
snippet prepgo "Prepare (Go)" i
# create directory for build output # create directory for build output
mkdir build mkdir build
@ -90,7 +108,7 @@ snippet goprep "Prepare (Go)" i
go mod download go mod download
endsnippet endsnippet
snippet gobuild "Build (Go)" i snippet buildgo "Build (Go)" i
# set Go flags # set Go flags
export CGO_CPPFLAGS="${CPPFLAGS}" export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}" export CGO_CFLAGS="${CFLAGS}"
@ -106,27 +124,60 @@ snippet gobuild "Build (Go)" i
. .
endsnippet endsnippet
snippet gochk "Check (Go)" i snippet chkgo "Check (Go)" i
go test -v ./... go test -v ./...
endsnippet endsnippet
## Rust specific #
snippet rustprep "Prepare (Rust)" i # Rust specific
#
snippet preprs "Prepare (Rust)" i
# download dependencies # download dependencies
cargo fetch --locked --target "$CARCH-unknown-linux-gnu" cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
endsnippet endsnippet
snippet rustbuild "Build (Rust)" i snippet buildrs "Build (Rust)" i
cargo build --frozen --release --all-features cargo build --frozen --release --all-features
endsnippet endsnippet
snippet rustchk "Check (Rust)" i snippet chkrs "Check (Rust)" i
cargo test --frozen --all-features cargo test --frozen --all-features
endsnippet endsnippet
snippet rustpkg "Package (Rust)" i snippet pkgrs "Package (Rust)" i
# binary # binary
install -vDm755 -t "$pkgdir/usr/bin" "target/release/$pkgname" install -vDm755 -t "$pkgdir/usr/bin" "target/release/$pkgname"
endsnippet endsnippet
#
# Common Lisp specific
#
snippet clname "Package Name (Common Lisp)" i
_pkgname="${pkgname#cl-}"
endsnippet
snippet vercl "Version (Common Lisp)" i
# first known commit to receive latest version
local _pkgver='$1'
local _pkgcommit='$2'
git tag "$_pkgver" "$_pkgcommit"
git describe --tags | sed -e 's/^v//' -e 's/-/.r/' -e 's/-/./g'
endsnippet
snippet chkcl "Check (Common Lisp)" i
sbcl --script ../run-tests.lisp
endsnippet
snippet pkgcl "Package (Common Lisp)" i
# library
install -vDm644 -t "$pkgdir/usr/share/common-lisp/source/$_pkgname" ./*.{lisp,asd}
find . -mindepth 1 -maxdepth 1 -type d -not -name '.git' -exec cp -vr -t "$pkgdir/usr/share/common-lisp/source/$_pkgname" {} \+
cp -vr \
directories \
files ./*.asd \
"$pkgdir/usr/share/common-lisp/source/$_pkgname"
endsnippet
# vim: tabstop=2 shiftwidth=2 expandtab # vim: tabstop=2 shiftwidth=2 expandtab