m4.vim 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. " Vim syntax file
  2. " Language: M4
  3. " Maintainer: Claudio Fleiner (claudio@fleiner.com)
  4. " URL: http://www.fleiner.com/vim/syntax/m4.vim
  5. " Last Change: 2005 Jan 15
  6. " This file will highlight user function calls if they use only
  7. " capital letters and have at least one argument (i.e. the '('
  8. " must be there). Let me know if this is a problem.
  9. " quit when a syntax file was already loaded
  10. if !exists("main_syntax")
  11. if exists("b:current_syntax")
  12. finish
  13. endif
  14. " we define it here so that included files can test for it
  15. let main_syntax='m4'
  16. endif
  17. " define the m4 syntax
  18. syn match m4Variable contained "\$\d\+"
  19. syn match m4Special contained "$[@*#]"
  20. syn match m4Comment "\<\(m4_\)\=dnl\>.*" contains=SpellErrors
  21. syn match m4Constants "\<\(m4_\)\=__file__"
  22. syn match m4Constants "\<\(m4_\)\=__line__"
  23. syn keyword m4Constants divnum sysval m4_divnum m4_sysval
  24. syn region m4Paren matchgroup=m4Delimiter start="(" end=")" contained contains=@m4Top
  25. syn region m4Command matchgroup=m4Function start="\<\(m4_\)\=\(define\|defn\|pushdef\)(" end=")" contains=@m4Top
  26. syn region m4Command matchgroup=m4Preproc start="\<\(m4_\)\=\(include\|sinclude\)("he=e-1 end=")" contains=@m4Top
  27. syn region m4Command matchgroup=m4Statement start="\<\(m4_\)\=\(syscmd\|esyscmd\|ifdef\|ifelse\|indir\|builtin\|shift\|errprint\|m4exit\|changecom\|changequote\|changeword\|m4wrap\|debugfile\|divert\|undivert\)("he=e-1 end=")" contains=@m4Top
  28. syn region m4Command matchgroup=m4builtin start="\<\(m4_\)\=\(len\|index\|regexp\|substr\|translit\|patsubst\|format\|incr\|decr\|eval\|maketemp\)("he=e-1 end=")" contains=@m4Top
  29. syn keyword m4Statement divert undivert
  30. syn region m4Command matchgroup=m4Type start="\<\(m4_\)\=\(undefine\|popdef\)("he=e-1 end=")" contains=@m4Top
  31. syn region m4Function matchgroup=m4Type start="\<[_A-Z][_A-Z0-9]*("he=e-1 end=")" contains=@m4Top
  32. syn region m4String start="`" end="'" contained contains=@m4Top,@m4StringContents,SpellErrors
  33. syn cluster m4Top contains=m4Comment,m4Constants,m4Special,m4Variable,m4String,m4Paren,m4Command,m4Statement,m4Function
  34. " Define the default highlighting.
  35. " Only when an item doesn't have highlighting yet
  36. hi def link m4Delimiter Delimiter
  37. hi def link m4Comment Comment
  38. hi def link m4Function Function
  39. hi def link m4Keyword Keyword
  40. hi def link m4Special Special
  41. hi def link m4String String
  42. hi def link m4Statement Statement
  43. hi def link m4Preproc PreProc
  44. hi def link m4Type Type
  45. hi def link m4Special Special
  46. hi def link m4Variable Special
  47. hi def link m4Constants Constant
  48. hi def link m4Builtin Statement
  49. let b:current_syntax = "m4"
  50. if main_syntax == 'm4'
  51. unlet main_syntax
  52. endif
  53. " vim: ts=4