zsh.vim 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. " Vim filetype plugin file
  2. " Language: Zsh shell script
  3. " Maintainer: Christian Brabandt <cb@256bit.org>
  4. " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
  5. " Latest Revision: 2024 Sep 19
  6. " License: Vim (see :h license)
  7. " Repository: https://github.com/chrisbra/vim-zsh
  8. if exists("b:did_ftplugin")
  9. finish
  10. endif
  11. let b:did_ftplugin = 1
  12. let s:cpo_save = &cpo
  13. set cpo&vim
  14. setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
  15. let b:undo_ftplugin = "setl com< cms< fo< "
  16. if executable('zsh') && &shell !~# '/\%(nologin\|false\)$'
  17. if exists(':terminal') == 2
  18. command! -buffer -nargs=1 ZshKeywordPrg silent exe ':term zsh -c "autoload -Uz run-help; run-help <args>"'
  19. else
  20. command! -buffer -nargs=1 ZshKeywordPrg echo system('MANPAGER= zsh -c "autoload -Uz run-help; run-help <args> 2>/dev/null"')
  21. endif
  22. setlocal keywordprg=:ZshKeywordPrg
  23. let b:undo_ftplugin .= '| setl keywordprg< | sil! delc -buffer ZshKeywordPrg'
  24. if !exists('current_compiler')
  25. compiler zsh
  26. endif
  27. let b:undo_ftplugin .= ' | compiler make'
  28. endif
  29. let b:match_words = '\<if\>:\<elif\>:\<else\>:\<fi\>'
  30. \ . ',\<case\>:^\s*([^)]*):\<esac\>'
  31. \ . ',\<\%(select\|while\|until\|repeat\|for\%(each\)\=\)\>:\<done\>'
  32. let b:match_skip = 's:comment\|string\|heredoc\|subst'
  33. let &cpo = s:cpo_save
  34. unlet s:cpo_save