awk.vim 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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: 2020 Sep 28
  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. \ " | unlet! b:browsefilter"
  23. " TODO: set this in scripts.vim?
  24. if exists("g:awk_is_gawk")
  25. setlocal include=@include
  26. setlocal suffixesadd+=.gawk
  27. if has("unix") || has("win32unix")
  28. setlocal formatprg=gawk\ -f-\ -o/dev/stdout
  29. let b:undo_ftplugin .= " | setl fp<"
  30. endif
  31. let path = system("gawk 'BEGIN { printf ENVIRON[\"AWKPATH\"] }'")
  32. let path = substitute(path, '^\.\=:\|:\.\=$\|:\.\=:', ',,', 'g') " POSIX cwd
  33. let path = substitute(path, ':', ',', 'g')
  34. let &l:path = path
  35. let b:undo_ftplugin .= " | setl inc< path<"
  36. endif
  37. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  38. let b:browsefilter = "Awk Source Files (*.awk,*.gawk)\t*.awk;*.gawk\n" .
  39. \ "All Files (*.*)\t*.*\n"
  40. endif
  41. let &cpo = s:cpo_save
  42. unlet s:cpo_save
  43. " vim: nowrap sw=2 sts=2 ts=8