csh.vim 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. " Vim filetype plugin file
  2. " Language: csh
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Previous Maintainer: Dan Sharp
  5. " Contributor: Johannes Zellner <johannes@zellner.org>
  6. " Last Change: 2024 Jan 14
  7. " 2024 May 23 by Riley Bruins ('commentstring')
  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=:#
  15. setlocal commentstring=#\ %s
  16. setlocal formatoptions-=t
  17. setlocal formatoptions+=crql
  18. let b:undo_ftplugin = "setlocal com< cms< fo<"
  19. " Csh: thanks to Johannes Zellner
  20. " - Both foreach and end must appear alone on separate lines.
  21. " - The words else and endif must appear at the beginning of input lines;
  22. " the if must appear alone on its input line or after an else.
  23. " - Each case label and the default label must appear at the start of a
  24. " line.
  25. " - while and end must appear alone on their input lines.
  26. if exists("loaded_matchit") && !exists("b:match_words")
  27. let s:line_start = '\%(^\s*\)\@<='
  28. let b:match_words =
  29. \ s:line_start .. 'if\s*(.*)\s*then\>:' ..
  30. \ s:line_start .. 'else\s\+if\s*(.*)\s*then\>:' .. s:line_start .. 'else\>:' ..
  31. \ s:line_start .. 'endif\>,' ..
  32. \ s:line_start .. '\%(\<foreach\s\+\h\w*\|while\)\s*(:' ..
  33. \ '\<break\>:\<continue\>:' ..
  34. \ s:line_start .. 'end\>,' ..
  35. \ s:line_start .. 'switch\s*(:' ..
  36. \ s:line_start .. 'case\s\+:' .. s:line_start .. 'default\>:\<breaksw\>:' ..
  37. \ s:line_start .. 'endsw\>'
  38. unlet s:line_start
  39. let b:undo_ftplugin ..= " | unlet! b:match_words"
  40. endif
  41. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  42. let b:browsefilter = "csh Scripts (*.csh)\t*.csh\n"
  43. if has("win32")
  44. let b:browsefilter ..= "All Files (*.*)\t*\n"
  45. else
  46. let b:browsefilter ..= "All Files (*)\t*\n"
  47. endif
  48. let b:csh_set_browsefilter = 1
  49. let b:undo_ftplugin ..= " | unlet! b:browsefilter b:csh_set_browsefilter"
  50. endif
  51. let &cpo = s:save_cpo
  52. unlet s:save_cpo