sh.vim 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. " Vim filetype plugin file
  2. " Language: sh
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Previous Maintainer: Dan Sharp
  5. " Contributor: Enno Nagel <ennonagel+vim@gmail.com>
  6. " Eisuke Kawashima
  7. " Last Change: 2024 Sep 19 by Vim Project (compiler shellcheck)
  8. if exists("b:did_ftplugin")
  9. finish
  10. endif
  11. let b:did_ftplugin = 1
  12. let s:save_cpo = &cpo
  13. set cpo-=C
  14. setlocal comments=b:#
  15. setlocal commentstring=#\ %s
  16. setlocal formatoptions-=t formatoptions+=croql
  17. let b:undo_ftplugin = "setl com< cms< fo<"
  18. " Shell: thanks to Johannes Zellner
  19. if exists("loaded_matchit") && !exists("b:match_words")
  20. let b:match_ignorecase = 0
  21. let s:sol = '\%(;\s*\|^\s*\)\@<=' " start of line
  22. let b:match_words =
  23. \ s:sol .. 'if\>:' .. s:sol.'elif\>:' .. s:sol.'else\>:' .. s:sol .. 'fi\>,' ..
  24. \ s:sol .. '\%(for\|while\)\>:' .. s:sol .. 'done\>,' ..
  25. \ s:sol .. 'case\>:' .. s:sol .. 'esac\>'
  26. unlet s:sol
  27. let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words"
  28. endif
  29. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  30. let b:browsefilter = "Bourne Shell Scripts (*.sh)\t*.sh\n" ..
  31. \ "Korn Shell Scripts (*.ksh)\t*.ksh\n" ..
  32. \ "Bash Shell Scripts (*.bash)\t*.bash\n"
  33. if has("win32")
  34. let b:browsefilter ..= "All Files (*.*)\t*\n"
  35. else
  36. let b:browsefilter ..= "All Files (*)\t*\n"
  37. endif
  38. let b:undo_ftplugin ..= " | unlet! b:browsefilter"
  39. endif
  40. if get(b:, "is_bash", 0)
  41. if exists(':terminal') == 2
  42. command! -buffer -nargs=1 ShKeywordPrg silent exe ':term bash -c "help "<args>" 2>/dev/null || man "<args>""'
  43. else
  44. command! -buffer -nargs=1 ShKeywordPrg echo system('bash -c "help <args>" 2>/dev/null || MANPAGER= man "<args>"')
  45. endif
  46. setlocal keywordprg=:ShKeywordPrg
  47. let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer ShKeywordPrg"
  48. if !exists('current_compiler')
  49. compiler shellcheck
  50. endif
  51. let b:undo_ftplugin .= ' | compiler make'
  52. endif
  53. let &cpo = s:save_cpo
  54. unlet s:save_cpo
  55. " vim: nowrap sw=2 sts=2 ts=8 noet: