run 2.7 KB

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