vim-polyglot/build

293 lines
8.3 KiB
Plaintext
Raw Normal View History

2013-09-14 14:48:46 -04:00
#!/usr/bin/env bash
2013-09-12 09:50:45 -04:00
2013-09-12 10:12:52 -04:00
set -E
2013-09-12 09:50:45 -04:00
DIRS="syntax indent compiler autoload ftplugin after/syntax after/indent after/ftplugin"
# shellcheck disable=SC2034
DIRS_BASIC="syntax compiler indent after/syntax after/indent"
# shellcheck disable=SC2034
DIRS_ALL="syntax indent compiler autoload ftplugin after"
# shellcheck disable=SC2034
DIRS_SYNTAX="syntax indent after/syntax after/indent"
DIRS_JAVASCRIPT="${DIRS} extras"
read -r -a DIRS_RM <<<"$DIRS_JAVASCRIPT"
2013-09-12 09:50:45 -04:00
2015-07-18 16:34:26 -04:00
OUTPUT=""
output() {
OUTPUT="$OUTPUT$1"
echo -n "$1"
2015-07-18 16:34:26 -04:00
}
download() {
for pack in $1; do
path="$(cut -d ':' -f 2 <<<"$pack")"
dir="tmp/$(cut -d '/' -f 2 <<<"$path")"
rm -rf "$dir"
(mkdir -p "$dir" && curl --silent -L "https://codeload.github.com/$path/tar.gz/master" | tar -zx -C "$dir" --strip 1 && printf '.') &
done
wait
}
extract() {
echo
cat config.vim >> tmp/polyglot.vim
for pack in $1; do
name="$(cut -d ':' -f 1 <<<"$pack")"
path="$(cut -d ':' -f 2 <<<"$pack")"
dir="tmp/$(cut -d '/' -f 2 <<<"$path")"
directories="DIRS$(cut -d ':' -f 3 <<<"$pack")"
subtree="$(cut -d ':' -f 4 <<<"$pack")"
2015-07-18 16:34:26 -04:00
output "- [$name](https://github.com/$path) ("
subdirs=""
for subdir in ${!directories}; do
if [ -d "${dir}${subtree:-/}${subdir}" ]; then
base="$(basename "$subdir")"
if [[ "$subdirs" != *"$base"* ]]; then
subdirs="$subdirs, $base"
fi
copy_dir "${dir}${subtree}" "$subdir" "$name"
fi
done
# syntax for go.vim depends on autoload for go.vim, but we exclude the
# autoload always and the ftplugin because it's too complex. FML.
if [ "${pack%%:*}" = "go" ]; then
copy_file "${dir}${subtree}" "${dir}${subtree}/autoload/go/config.vim" "${name}"
fi
output "${subdirs##, })"$'\n'
2019-03-04 03:52:59 -05:00
if (echo "julia coffee-script elixir fish git plantuml scala swift jinja" | grep -qF "$name"); then
echo "Skipping ftdetect installation of $name" >&2
2018-04-30 17:57:13 -04:00
continue
fi
2019-03-04 04:29:18 -05:00
[ -d "${dir}${subtree:-/}ftdetect" ] && for f in "${dir}${subtree:-/}ftdetect/"*; do
cat <<EOF >> tmp/polyglot.vim
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, '${pack%%:*}') == -1
augroup filetypedetect
" ${pack%%:*}, from ${f##*/ftdetect/} in ${pack#*:}
$(cat "${f}")
augroup end
endif
EOF
done
2013-09-16 19:53:14 -04:00
done
2013-09-16 19:53:14 -04:00
mv tmp/polyglot.vim ftdetect/
2013-09-16 19:53:14 -04:00
for pack in $1; do
name="$(cut -d ':' -f 1 <<<"$pack")"
path="$(cut -d ':' -f 2 <<<"$pack")"
dir="tmp/$(cut -d '/' -f 2 <<<"$path")"
subtree="$(cut -d ':' -f 4 <<<"$pack")"
2013-09-16 19:53:14 -04:00
if [ -d "$dir${subtree:-/}plugin" ]; then
echo "Possible error (plugin directory exists): $path" >&2
2013-09-16 19:53:14 -04:00
fi
done
}
copy_dir() {
find "$1/$2" \( -name '*.vim' -o -name '*.vital' \) -print0 | while read -r -d $'\0' file; do
copy_file "$1" "$file" "$3"
2013-09-12 09:50:45 -04:00
done
}
copy_file() {
## $1 is the build dir (e.g. tmp/vim-go)
## $2 is the full file path, as returned by `find` (e.g. tmp/vim-go/indent/go.vim)
## $3 is the name of the package (so that we can detect if it's disabled at runtime)
local tmp_dir="$1"
local file_in_tmp="$2"
local file_basename="${2##*/}"
local file_path="${file_in_tmp##$tmp_dir/}" # Just this file's (full) path
file_path="${file_path%/*}" # Minus the actual name of the file
local file_in_dst="${file_path}/${file_basename}" # Could also be ${file_in_tmp##$tmp_dir/}
local package_name="$3"
if [ "${file_in_tmp##$tmp_dir/}" != "${file_in_dst}" ]; then
echo "Failure in logic in build script; '${file_in_tmp##$tmp_dir/}' != '${file_in_dst}'. Bailing." >&2
exit 1
fi
mkdir -p "${file_path}"
touch "$file_in_dst"
# Use comma instead of / to handle cases like c/c++
sed -e "s,%%PACK%%,${package_name}," -e "/%%CONTENT%%/{r ${file_in_tmp}" -e "d;}" plugin_guard.vim.template >> "$file_in_dst"
}
2015-07-18 16:34:26 -04:00
update_readme() {
local tf of
tf="$(mktemp)"
of="$(mktemp)"
LC_ALL=C sort <<<"$OUTPUT" | grep -vxE '[[:space:]]*' > "$of"
awk 'suppress == 0 {
gsub(/<!--Package Count-->[^<]*<!--\/Package Count-->/,
"<!--Package Count-->'"$(awk 'END {print NR}' "$of")"'<!--/Package Count-->");
print;
}
/<!--Language Packs-->/ {
suppress = 1;
while ( ( getline line < "'"$of"'" ) > 0 ) {
print line;
}
}
/<!--\/Language Packs-->/ {
suppress = 0;
print;
}' "README.md" >"$tf"
mv "$tf" "README.md"
2015-07-18 16:34:26 -04:00
}
PACKS="
2019-03-04 03:32:57 -05:00
ansible:pearofducks/ansible-vim
2017-03-23 08:21:01 -04:00
apiblueprint:sheerun/apiblueprint.vim
applescript:mityu/vim-applescript:_SYNTAX
arduino:sudar/vim-arduino-syntax
2019-03-04 03:32:57 -05:00
asciidoc:asciidoc/vim-asciidoc
2017-09-27 14:14:30 -04:00
autohotkey:hnamikaw/vim-autohotkey
2015-12-06 05:31:01 -05:00
blade:jwalton512/vim-blade
c++11:octol/vim-cpp-enhanced-highlight
2015-12-06 05:31:01 -05:00
c/c++:vim-jp/vim-cpp
caddyfile:isobit/vim-caddyfile
2017-12-30 05:29:09 -05:00
carp:hellerve/carp-vim
2015-10-24 06:06:19 -04:00
cjsx:mtscout6/vim-cjsx
clojure:guns/vim-clojure-static
2017-11-19 15:46:44 -05:00
cmake:pboettch/vim-cmake-syntax
coffee-script:kchmck/vim-coffee-script
2019-03-04 03:32:57 -05:00
cql:elubow/cql-vim
2016-05-02 04:44:59 -04:00
cryptol:victoredwardocallaghan/cryptol.vim
2016-05-02 04:49:45 -04:00
crystal:rhysd/vim-crystal
cucumber:tpope/vim-cucumber
2019-03-04 03:37:07 -05:00
cue:mgrabovsky/vim-cuesheet
2015-12-06 05:38:02 -05:00
dart:dart-lang/dart-vim-plugin
2018-12-26 14:22:36 -05:00
dockerfile:ekalinin/Dockerfile.vim
elixir:elixir-lang/vim-elixir
2017-09-27 14:52:13 -04:00
elm:ElmCast/elm-vim
emberscript:yalesov/vim-ember-script
2016-07-05 03:55:06 -04:00
emblem:yalesov/vim-emblem
erlang:vim-erlang/vim-erlang-runtime
2018-06-04 16:07:36 -04:00
ferm:vim-scripts/ferm.vim
2016-05-02 04:46:45 -04:00
fish:dag/vim-fish
2019-03-04 04:35:44 -05:00
flatbuffers:dcharbon/vim-flatbuffers
2017-09-27 14:19:38 -04:00
fsharp:fsharp/vim-fsharp:_BASIC
git:tpope/vim-git
glsl:tikhomirov/vim-glsl
2019-03-04 03:32:57 -05:00
gmpl:maelvalais/gmpl.vim
2017-03-23 06:49:10 -04:00
gnuplot:vim-scripts/gnuplot-syntax-highlighting
go:fatih/vim-go:_BASIC
gradle:tfnico/vim-gradle
graphql:jparise/vim-graphql
2015-10-10 11:17:57 -04:00
groovy:vim-scripts/groovy.vim
2019-03-04 03:38:12 -05:00
groovy-indent:vim-scripts/groovyindent-unix
haml:sheerun/vim-haml
handlebars:mustache/vim-mustache-handlebars
haproxy:CH-DanReif/haproxy.vim
haskell:neovimhaskell/haskell-vim
2014-06-08 07:22:29 -04:00
haxe:yaymukund/vim-haxe
html5:othree/html5.vim
2018-12-26 05:19:25 -05:00
i3:mboughaba/i3config.vim
2019-03-04 04:14:37 -05:00
idris:idris-hackers/idris-vim
2014-04-14 19:12:18 -04:00
jasmine:glanotte/vim-jasmine
javascript:pangloss/vim-javascript:_JAVASCRIPT
jenkins:martinda/Jenkinsfile-vim-syntax
2019-03-04 03:52:59 -05:00
jinja:lepture/vim-jinja
2017-12-30 05:34:40 -05:00
json5:GutenYe/json5.vim
2019-03-04 03:32:57 -05:00
json:elzr/vim-json
jst:briancollins/vim-jst
jsx:amadeus/vim-jsx
julia:JuliaEditorSupport/julia-vim
kotlin:udalov/kotlin-vim
latex:LaTeX-Box-Team/LaTeX-Box
less:groenewege/vim-less
2014-06-08 13:38:42 -04:00
liquid:tpope/vim-liquid
2016-07-26 08:06:32 -04:00
livescript:gkz/vim-ls
2016-07-26 07:58:55 -04:00
lua:tbastos/vim-lua
2016-05-13 09:56:51 -04:00
mako:sophacles/vim-bundle-mako
2016-06-26 12:13:30 -04:00
markdown:plasticboy/vim-markdown:_SYNTAX
2017-03-23 07:11:44 -04:00
mathematica:rsmenon/vim-mathematica
2019-03-04 04:29:18 -05:00
meson:mesonbuild/meson:_ALL:/data/syntax-highlighting/vim/
2018-12-26 14:15:18 -05:00
moonscript:leafo/moonscript-vim
nginx:chr4/nginx.vim
2016-01-22 03:12:18 -05:00
nim:zah/nim.vim:_BASIC
2017-11-19 15:34:38 -05:00
nix:LnL7/vim-nix
objc:b4winckler/vim-objc
ocaml:jrk/vim-ocaml
octave:vim-scripts/octave.vim--
2014-03-16 09:52:12 -04:00
opencl:petRUShka/vim-opencl
2013-09-17 11:37:59 -04:00
perl:vim-perl/vim-perl
2016-05-02 04:52:01 -04:00
pgsql:exu/pgsql.vim
php:StanAngeloff/php.vim
2016-05-02 04:50:59 -04:00
plantuml:aklt/plantuml-syntax
2018-12-26 14:33:28 -05:00
pony:jakwings/vim-pony
powershell:PProvost/vim-ps1
2013-09-14 05:36:13 -04:00
protobuf:uarun/vim-protobuf
2016-05-02 05:52:54 -04:00
pug:digitaltoad/vim-pug
puppet:voxpupuli/vim-puppet
purescript:purescript-contrib/purescript-vim
2016-09-11 07:25:03 -04:00
python-compiler:aliev/vim-compiler-python
python-ident:Vimjas/vim-python-pep8-indent
2019-03-04 03:32:57 -05:00
python:vim-python/python-syntax
2019-03-04 04:32:24 -05:00
qmake:artoj/qmake-syntax-vim
2015-10-10 11:25:38 -04:00
qml:peterhoeg/vim-qml
2015-10-24 06:06:19 -04:00
r-lang:vim-scripts/R.vim
2017-05-17 05:46:19 -04:00
racket:wlangstroth/vim-racket
2015-12-31 12:27:37 -05:00
ragel:jneen/ragel.vim
2019-03-04 03:32:57 -05:00
raml:IN3D/vim-raml
2019-03-04 04:09:33 -05:00
reason:reasonml-editor/vim-reason-plus
rspec:sheerun/rspec.vim
2019-03-04 03:32:57 -05:00
rst:marshallward/vim-restructuredtext
ruby:vim-ruby/vim-ruby
2015-11-20 09:47:50 -05:00
rust:rust-lang/rust.vim
sbt:derekwyatt/vim-sbt
scala:derekwyatt/vim-scala
scss:cakebaker/scss-syntax.vim
slim:slim-template/vim-slim
2017-12-06 07:17:06 -05:00
slime:slime-lang/vim-slime-syntax
2017-09-27 14:08:01 -04:00
solidity:tomlion/vim-solidity
stylus:wavded/vim-stylus
2015-12-05 20:05:04 -05:00
swift:keith/swift.vim
2017-03-23 07:48:17 -04:00
sxhkd:baskerville/vim-sxhkdrc
systemd:wgwoods/vim-systemd-syntax
2017-02-02 15:44:42 -05:00
terraform:hashivim/vim-terraform
textile:timcharper/textile.vim
2015-10-24 06:06:19 -04:00
thrift:solarnz/thrift.vim
2016-06-26 12:03:28 -04:00
tmux:keith/tmux.vim
2015-12-06 05:31:01 -05:00
tomdoc:wellbredgrapefruit/tomdoc.vim
2014-04-14 19:16:56 -04:00
toml:cespare/vim-toml
2016-09-11 07:50:56 -04:00
twig:lumiliet/vim-twig
2015-10-24 06:06:19 -04:00
typescript:leafgarland/typescript-vim
vala:arrufat/vala.vim
2015-10-24 06:06:19 -04:00
vbnet:vim-scripts/vbnet.vim
2015-12-06 05:34:19 -05:00
vcl:smerrill/vcl-vim-plugin
2017-09-27 14:23:42 -04:00
vifm:vifm/vifm.vim
2014-12-22 16:01:38 -05:00
vm:lepture/vim-velocity
2019-03-04 03:32:57 -05:00
vue:posva/vim-vue
xml:amadeus/vim-xml
2015-10-24 06:06:19 -04:00
xls:vim-scripts/XSLT-syntax
2019-03-04 03:32:57 -05:00
yaml:stephpy/vim-yaml
2015-10-24 06:06:19 -04:00
yard:sheerun/vim-yardoc
"
2013-09-14 14:10:55 -04:00
rm -rf tmp
rm -rf "${DIRS_RM[@]}"
2013-09-16 11:46:24 -04:00
mkdir tmp
2013-09-14 14:10:55 -04:00
printf "Downloading packs..."
download "$(sed '/^#/d' <<<"$PACKS")"
extract "$(sed '/^#/d' <<<"$PACKS")"
2015-07-18 16:34:26 -04:00
update_readme
rm -rf tmp