run 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. cd "$BASE"
  29. }
  30. make_dirs() {
  31. rm -rf "$PLUG_FIXTURES/$1"
  32. mkdir -p "$PLUG_FIXTURES/$1"
  33. cd "$PLUG_FIXTURES/$1"
  34. mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
  35. for d in *; do
  36. [ -d $d ] || continue
  37. cat > $d/xxx.vim << EOF
  38. " echom expand('<sfile>')
  39. let g:total_order = get(g:, 'total_order', [])
  40. let g:$2 = get(g:, '$2', [])
  41. let s:name = join(filter(['$2', '${1:4}', '$d'], '!empty(v:val)'), '/')
  42. call add(g:$2, s:name)
  43. call add(g:total_order, s:name)
  44. EOF
  45. done
  46. cd "$BASE"
  47. }
  48. prepare() {
  49. make_dirs xxx/ xxx
  50. make_dirs xxx/after xxx
  51. mkdir -p "$PLUG_FIXTURES/xxx/doc"
  52. cat > "$PLUG_FIXTURES/xxx/doc/xxx.txt" << DOC
  53. hello *xxx*
  54. DOC
  55. make_dirs yyy/ yyy
  56. make_dirs yyy/after yyy
  57. make_dirs z1/ z1
  58. make_dirs z2/ z2
  59. rm -rf "$PLUG_FIXTURES/ftplugin-msg"
  60. mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
  61. echo "echomsg 'ftplugin'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
  62. rm -rf /tmp/new-branch
  63. cd /tmp
  64. git init new-branch
  65. cd new-branch
  66. mkdir plugin
  67. echo 'let g:foo = 1' > plugin/foo.vim
  68. git add plugin/foo.vim
  69. git commit -m initial
  70. cd "$BASE"
  71. }
  72. select_vim() {
  73. local vim=/usr/bin/vim
  74. if [ -n "$DEPS" ] && [ -e "${DEPS}/bin/vim" ]; then
  75. vim="${DEPS}/bin/vim"
  76. elif [ -e "/usr/local/bin/vim" ]; then
  77. vim=/usr/local/bin/vim
  78. fi
  79. echo $vim
  80. }
  81. clone_repos
  82. prepare
  83. VIM=$(select_vim)
  84. echo "Selected Vim: $VIM"
  85. if [ "$1" = '!' ]; then
  86. $VIM -Nu /tmp/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
  87. prepare &&
  88. $VIM -Nu /tmp/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null
  89. else
  90. $VIM -Nu /tmp/mini-vimrc -c 'Vader test.vader'
  91. fi