summaryrefslogblamecommitdiffstats
path: root/build
blob: 58d15904a07f97451f563c1811cea268ee2a35ec (plain) (tree)
1
2
3
4
5
6
7
8
                   
 
      
 
                                                                                                                
                                                                            
                                                                  
 






                    

                    

                                                 
                 
                                                                                                                                       





           
             
                    


                                                 
                                                         
                                                 
                                                  
 
              
                                     
                                                    




                                              
                                                     
        
        
 
 
                              
      




                                                 
                                                 
 
                                             


                                                                





                                               
                                          


                                                                                                                           


      





                                                     















                               
       
                                  
                         



                                        
                        
                       
                             
                                 
                               
                                             
                                  
                                 
                   
                        
                     
                                             
                             
                         
                        
                           
                              
                                    
                                    
                       
                          
                      
                                
                          
                         



                                 
                             
                        
                          
                          
                                 
                             
                                      
                          
                       
                         
                        
                     


                             
                                
                          
                                     
                              
                                
                    
                           
                                       
                             
                           
                       

                             
                         
                      
                         
 
 
          
                
         
 
                             

                 
               
             

          
#!/usr/bin/env bash

set -E

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

OUTPUT=""

output() {
  OUTPUT="$OUTPUT$1"
  printf -- "$1"
}

download() {
  for pack in $1; do
    path="$(printf "$pack" | cut -d ':' -f 2)"
    dir="tmp/$(printf "$path" | cut -d '/' -f 2)"
    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() {
  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)"
    directories="DIRS$(printf "$pack" | cut -d ':' -f 3)"
    subtree="$(printf "$pack" | cut -d ':' -f 4)"
    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


    output "${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)"
    subtree="$(printf "$pack" | cut -d ':' -f 4)"

    if [ -d "$dir${subtree:-/}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")"

    # Use comma instead of / to handle cases like c/c++
    sed -e "s,%%PACK%%,$3," -e "/%%CONTENT%%/{r $file" -e "d;}" plugin_guard.vim.template >> $file_path/$(basename "$file")
  done
}

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

update_readme() {
  OLD_README="$(cat README.md)"

  ed README.md <<- EOF
/Language packs
+2kb
/##
'b,-2c
$(printf -- "$OUTPUT")
.
w
q
EOF

}

PACKS="
  arduino:sudar/vim-arduino-syntax
  blade:xsbeats/vim-blade
  c++11:octol/vim-cpp-enhanced-highlight
  c/c++:vim-jp/cpp-vim
  clojure:guns/vim-clojure-static
  coffee-script:kchmck/vim-coffee-script
  cjsx:mtscout6/vim-cjsx
  css:JulesWang/css.vim
  cucumber:tpope/vim-cucumber
  dockerfile:honza/dockerfile.vim
  elixir:elixir-lang/vim-elixir
  emberscript:heartsentwined/vim-ember-script
  emblem:heartsentwined/vim-emblem
  erlang:hcs42/vim-erlang-runtime
  git:tpope/vim-git
  go:fatih/vim-go:_BASIC
  haml:tpope/vim-haml
  handlebars:mustache/vim-mustache-handlebars
  haskell:raichoo/haskell-vim
  haxe:yaymukund/vim-haxe
  html5:othree/html5.vim
  jade:digitaltoad/vim-jade
  jasmine:glanotte/vim-jasmine
  javascript:pangloss/vim-javascript
  julia:dcjones/julia-minimalist-vim
  json:sheerun/vim-json
  jst:briancollins/vim-jst
  jsx:mxw/vim-jsx:_ALL
  latex:LaTeX-Box-Team/LaTeX-Box
  less:groenewege/vim-less
  liquid:tpope/vim-liquid
  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
  powershell:Persistent13/vim-ps1
  protobuf:uarun/vim-protobuf
  python:mitsuhiko/vim-python-combined
  r-lang:vim-scripts/R.vim
  ragel:jneen/ragel.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
  solidity:ethereum/vim-solidity
  stylus:wavded/vim-stylus
  systemd:kurayama/systemd-vim-syntax
  swift:toyamarinyon/vim-swift
  textile:timcharper/textile.vim
  tmux:tejr/vim-tmux
  tomdoc:duwanis/tomdoc.vim
  typescript:leafgarland/typescript-vim
  vbnet:vim-scripts/vbnet.vim
  thrift:solarnz/thrift.vim
  toml:cespare/vim-toml
  twig:beyondwords/vim-twig
  xls:vim-scripts/XSLT-syntax
  yard:sheerun/vim-yardoc
  vala:tkztmk/vim-vala
  vm:lepture/vim-velocity
"

rm -rf tmp
rm -rf $DIRS_ALL
mkdir tmp

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

rm -rf tmp