run 2.8 KB

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