-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimdoc-install
executable file
·55 lines (51 loc) · 1.69 KB
/
vimdoc-install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh -e
# vimdoc setup under XDG Base Directory Specification
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
# @ NAMES vim opt packagenames (list)
# @ -d DOCDIR vim doc install directory
#set -x
cd > /dev/null || true
HOME=$(pwd)
help() {
echo "syntax: ${0##*/}"
echo
echo "Set up a vimdoc for all packages in ..pack//packer/opt"
}
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
help
exit 0
fi
# source .local/share/nvim/site/pack/packer/opt/<packagename>/doc/*.txt
# destination .config/astrovim/doc/*.txt
BASE="${XDG_DATA_HOME:-$HOME/.local}/share/nvim/site/pack/packer/opt"
#echo "BASE='$BASE'"
PKGNAMES=$(find "$BASE" -maxdepth 1 -type d | sed -e 's,^.*/,,')
# echo "PKGNAMES='$PKGNAMES'"
DESTPATH="${XDG_CONFIG_HOME:-$HOME/.config}/astronvim/doc"
#echo "DESTPATH='$DESTPATH'"
for PKGNAME in $PKGNAMES; do
case $PKGNAME in
aerial.nvim | nvim-treesitter | nvim-colorizer.lua | indent-blankline.nvim | \
mason-lspconfig.nvim | nvim-lspconfig | mason.nvim | which-key.nvim | \
packer.nvim)
# nvim-treesitter.txt already read
# already read
echo "Skip: $PKGNAME (no need)" # do nothing
;;
*)
#echo "Creating symlink for $PKGNAME"
BASEPATH="$BASE/$PKGNAME/doc"
if [ -d "$BASEPATH" ]; then
TXTFILES=$(find "$BASEPATH" -type f -name '*.txt' | sed 's,^.*/,,')
#echo " ... TXTFILES='$TXTFILES'"
for FNAME in $TXTFILES; do
#echo " ... $FNAME"
echo "Link: $BASE/$PKGNAME/doc/$FNAME -> $DESTPATH/$FNAME"
ln -sf "$BASE/$PKGNAME/doc/$FNAME" "$DESTPATH/$FNAME"
done
else
echo "Skip: $PKGNAME (no doc)"
fi
;;
esac
done