run 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/bash
  2. cd $(dirname "${BASH_SOURCE[0]}")
  3. export BASE="$PWD"
  4. export PLUG_SRC="$PWD/../plug.vim"
  5. export PLUG_FIXTURES="$PWD/fixtures"
  6. mkdir -p "$PLUG_FIXTURES"
  7. cat > /tmp/mini-vimrc << VIMRC
  8. set rtp+=/tmp/junegunn/vader.vim
  9. set shell=/bin/bash
  10. VIMRC
  11. clone() {
  12. if [ ! -d $2 ]; then
  13. git clone $1 $2
  14. fi
  15. }
  16. clone_repos() (
  17. cd /tmp
  18. mkdir -p junegunn vim-scripts jg
  19. for repo in vader.vim goyo.vim rust.vim seoul256.vim vim-easy-align vim-fnr \
  20. vim-oblique vim-pseudocl vim-redis vim-emoji; do
  21. clone https://github.com/junegunn/${repo}.git junegunn/$repo &
  22. done
  23. clone https://github.com/vim-scripts/beauty256.git vim-scripts/beauty256 &
  24. clone https://github.com/junegunn/fzf.git fzf &
  25. wait
  26. clone junegunn/vim-emoji jg/vim-emoji
  27. cd junegunn/seoul256.vim && git checkout no-t_co && git checkout master
  28. )
  29. make_dirs() (
  30. rm -rf "$PLUG_FIXTURES/$1"
  31. mkdir -p "$PLUG_FIXTURES/$1"
  32. cd "$PLUG_FIXTURES/$1"
  33. mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
  34. for d in *; do
  35. [ -d $d ] || continue
  36. cat > $d/xxx.vim << EOF
  37. " echom expand('<sfile>')
  38. let g:total_order = get(g:, 'total_order', [])
  39. let g:$2 = get(g:, '$2', [])
  40. let s:name = join(filter(['$2', '${1:4}', '$d'], '!empty(v:val)'), '/')
  41. call add(g:$2, s:name)
  42. call add(g:total_order, s:name)
  43. EOF
  44. done
  45. )
  46. gitinit() (
  47. cd "$PLUG_FIXTURES/$1"
  48. git init
  49. git commit -m 'commit' --allow-empty
  50. )
  51. prepare() {
  52. make_dirs xxx/ xxx
  53. make_dirs xxx/after xxx
  54. mkdir -p "$PLUG_FIXTURES/xxx/doc"
  55. cat > "$PLUG_FIXTURES/xxx/doc/xxx.txt" << DOC
  56. hello *xxx*
  57. DOC
  58. gitinit xxx
  59. make_dirs yyy/ yyy
  60. make_dirs yyy/after yyy
  61. gitinit yyy
  62. make_dirs z1/ z1
  63. make_dirs z2/ z2
  64. rm -rf "$PLUG_FIXTURES/ftplugin-msg"
  65. mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
  66. echo "echomsg 'ftplugin'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
  67. rm -rf /tmp/new-branch
  68. cd /tmp
  69. git init new-branch
  70. cd new-branch
  71. mkdir plugin
  72. echo 'let g:foo = 1' > plugin/foo.vim
  73. git add plugin/foo.vim
  74. git commit -m initial
  75. cd "$BASE"
  76. }
  77. select_vim() {
  78. local vim=/usr/bin/vim
  79. if [ -n "$DEPS" ] && [ -e "${DEPS}/bin/vim" ]; then
  80. vim="${DEPS}/bin/vim"
  81. elif [ -e "/usr/local/bin/vim" ]; then
  82. vim=/usr/local/bin/vim
  83. fi
  84. echo $vim
  85. }
  86. clone_repos
  87. prepare
  88. VIM=$(select_vim)
  89. echo "Selected Vim: $VIM"
  90. if [ "$1" = '!' ]; then
  91. $VIM -Nu /tmp/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
  92. prepare &&
  93. $VIM -Nu /tmp/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null
  94. else
  95. $VIM -Nu /tmp/mini-vimrc -c 'Vader test.vader'
  96. fi