summaryrefslogtreecommitdiffstats
path: root/build
blob: 1ce37ba0444b3c7c5f6c33625b5be4e65ebc2bcd (plain) (blame)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash

set -E

DIRS="syntax indent compiler autoload ftplugin ftdetect after/syntax after/indent after/ftplugin after/ftdetect"

download() {
  for pack in $1; do
    path="$(printf "$pack" | cut -d ':' -f 2)"
    dir="tmp/$(printf "$path" | cut -d '/' -f 2)"
    rm -rf "$dir"
    (git clone -q --recursive "https://github.com/$path.git" "$dir" && printf '.') &
  done

  wait
}

extract() {
  printf "\n"
  for pack in $1; do
    name="$(printf "$pack" | cut -d ':' -f 1)"
    path="$(printf "$pack" | cut -d ':' -f 2)"
    dir="tmp/$(printf "$path" | cut -d '/' -f 2)"
    printf -- "- [$name](https://github.com/$path) ("

    subdirs=""
    for subdir in $DIRS; do
      if [ -d "$dir/$subdir" ]; then
        base="$(basename "$subdir")"
        if [[ "$subdirs" != *"$base"* ]]; then
          subdirs="$subdirs, $base"
        fi

        copy_dir "$dir" "$subdir"
      fi
    done


    printf "${subdirs##, })\n"
  done

  for pack in $1; do
    name="$(printf "$pack" | cut -d ':' -f 1)"
    path="$(printf "$pack" | cut -d ':' -f 2)"
    dir="tmp/$(printf "$path" | cut -d '/' -f 2)"

    if [ -d "$dir/plugin" ]; then
      printf "Possible error (plugin directory exists): $path\n"
    fi
  done
}

copy_dir() {
  for file in $(find "$1/$2" -name '*.vim'); do
    file_path="$(dirname "${file##$1/}")"
    mkdir -p "$file_path"
    touch "$file_path/$(basename "$file")"
    cat $file >> $file_path/$(basename "$file")
  done
}

concat_ftdetect() {
  cat ftdetect/* | grep -E '^[^"]' > tmp/polyglot.vim
  rm -f ftdetect/*
  mv tmp/polyglot.vim ftdetect/
}

PACKS="
  arduino:sudar/vim-arduino-syntax
  c++11:octol/vim-cpp-enhanced-highlight
  c/c++:vim-jp/cpp-vim
  c-extensions:kergoth/aftersyntaxc.vim
  clojure:guns/vim-clojure-static
  coffee-script:kchmck/vim-coffee-script
  csv:chrisbra/csv.vim
  cucumber:tpope/vim-cucumber
  dockerfile:honza/dockerfile.vim
  elixir:elixir-lang/vim-elixir
  emberscript:heartsentwined/vim-ember-script
  erlang:oscarh/vimerl
  git:tpope/vim-git
  go:jnwhiteh/vim-golang
  haml:tpope/vim-haml
  handlebars:mustache/vim-mustache-handlebars
  haskell:travitch/hasksyn
  haxe:yaymukund/vim-haxe
  html5:othree/html5.vim
  jade:digitaltoad/vim-jade
  jasmine:glanotte/vim-jasmine
  javascript:pangloss/vim-javascript
  json:leshill/vim-json
  jst:briancollins/vim-jst
  latex:LaTeX-Box-Team/LaTeX-Box
  less:groenewege/vim-less
  markdown:tpope/vim-markdown
  nginx:mutewinter/nginx.vim
  ocaml:jrk/vim-ocaml
  octave:vim-scripts/octave.vim--
  opencl:petRUShka/vim-opencl
  perl:vim-perl/vim-perl
  php:StanAngeloff/php.vim
  puppet:rodjek/vim-puppet
  protobuf:uarun/vim-protobuf
  python:mitsuhiko/vim-python-combined
  r-lang:vim-scripts/R.vim
  rspec:sheerun/rspec.vim
  ruby:vim-ruby/vim-ruby
  rust:wting/rust.vim
  sbt:derekwyatt/vim-sbt
  scala:derekwyatt/vim-scala
  slim:slim-template/vim-slim
  stylus:wavded/vim-stylus
  systemd:kurayama/systemd-vim-syntax
  textile:timcharper/textile.vim
  tmux:acustodioo/vim-tmux
  tomdoc:duwanis/tomdoc.vim
  typescript:leafgarland/typescript-vim
  vbnet:vim-scripts/vbnet.vim
  toml:cespare/vim-toml
  twig:beyondwords/vim-twig
  xls:vim-scripts/XSLT-syntax
  yard:sheerun/vim-yardoc
  css-color:ap/vim-css-color
"

rm -rf tmp
rm -rf $DIRS
mkdir tmp

printf "Downloading packs..."
download "$PACKS"
extract "$PACKS"
concat_ftdetect

rm -rf tmp