awk.vim 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. " Vim filetype plugin
  2. " Language: awk, nawk, gawk, mawk
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Previous Maintainer: Antonio Colombo <azc100@gmail.com>
  5. " Last Change: 2024 Jan 14
  6. " This plugin was prepared by Mark Sikora
  7. " This plugin was updated as proposed by Doug Kearns
  8. " Only do this when not done yet for this buffer
  9. if exists("b:did_ftplugin")
  10. finish
  11. endif
  12. " Don't load another plugin for this buffer
  13. let b:did_ftplugin = 1
  14. let s:cpo_save = &cpo
  15. set cpo&vim
  16. setlocal comments=:#
  17. setlocal commentstring=#\ %s
  18. setlocal formatoptions-=t formatoptions+=croql
  19. setlocal define=function
  20. setlocal suffixesadd+=.awk
  21. let b:undo_ftplugin = "setl fo< com< cms< def< sua<"
  22. " TODO: set this in scripts.vim?
  23. if exists("g:awk_is_gawk")
  24. setlocal include=@include
  25. setlocal suffixesadd+=.gawk
  26. if has("unix") || has("win32unix")
  27. setlocal formatprg=gawk\ -f-\ -o/dev/stdout
  28. let b:undo_ftplugin .= " | setl fp<"
  29. endif
  30. " Disabled by default for security reasons.
  31. if dist#vim#IsSafeExecutable('awk', 'gawk')
  32. let path = system("gawk 'BEGIN { printf ENVIRON[\"AWKPATH\"] }'")
  33. let path = substitute(path, '^\.\=:\|:\.\=$\|:\.\=:', ',,', 'g') " POSIX cwd
  34. let path = substitute(path, ':', ',', 'g')
  35. let &l:path = path
  36. endif
  37. let b:undo_ftplugin .= " | setl inc< path<"
  38. endif
  39. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  40. let b:browsefilter = "Awk Source Files (*.awk, *.gawk)\t*.awk;*.gawk\n"
  41. if has("win32")
  42. let b:browsefilter .= "All Files (*.*)\t*\n"
  43. else
  44. let b:browsefilter .= "All Files (*)\t*\n"
  45. endif
  46. let b:undo_ftplugin .= " | unlet! b:browsefilter"
  47. endif
  48. let &cpo = s:cpo_save
  49. unlet s:cpo_save
  50. " vim: nowrap sw=2 sts=2 ts=8