csh.vim 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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: 2021 Oct 15
  7. if exists("b:did_ftplugin") | finish | endif
  8. let b:did_ftplugin = 1
  9. let s:save_cpo = &cpo
  10. set cpo-=C
  11. setlocal comments=:#
  12. setlocal commentstring=#%s
  13. setlocal formatoptions-=t
  14. setlocal formatoptions+=crql
  15. let b:undo_ftplugin = "setlocal com< cms< fo<"
  16. " Csh: thanks to Johannes Zellner
  17. " - Both foreach and end must appear alone on separate lines.
  18. " - The words else and endif must appear at the beginning of input lines;
  19. " the if must appear alone on its input line or after an else.
  20. " - Each case label and the default label must appear at the start of a
  21. " line.
  22. " - while and end must appear alone on their input lines.
  23. if exists("loaded_matchit") && !exists("b:match_words")
  24. let s:line_start = '\%(^\s*\)\@<='
  25. let b:match_words =
  26. \ s:line_start .. 'if\s*(.*)\s*then\>:' ..
  27. \ s:line_start .. 'else\s\+if\s*(.*)\s*then\>:' .. s:line_start .. 'else\>:' ..
  28. \ s:line_start .. 'endif\>,' ..
  29. \ s:line_start .. '\%(\<foreach\s\+\h\w*\|while\)\s*(:' ..
  30. \ '\<break\>:\<continue\>:' ..
  31. \ s:line_start .. 'end\>,' ..
  32. \ s:line_start .. 'switch\s*(:' ..
  33. \ s:line_start .. 'case\s\+:' .. s:line_start .. 'default\>:\<breaksw\>:' ..
  34. \ s:line_start .. 'endsw\>'
  35. unlet s:line_start
  36. let b:undo_ftplugin ..= " | unlet b:match_words"
  37. endif
  38. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  39. let b:browsefilter="csh Scripts (*.csh)\t*.csh\n" ..
  40. \ "All Files (*.*)\t*.*\n"
  41. let b:undo_ftplugin ..= " | unlet b:browsefilter"
  42. endif
  43. let &cpo = s:save_cpo
  44. unlet s:save_cpo