dep3patch.vim 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. " Vim syntax file
  2. " Language: Debian DEP3 Patch headers
  3. " Maintainer: Gabriel Filion <gabster@lelutin.ca>
  4. " Last Change: 2022 Apr 06
  5. " URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/syntax/dep3patch.vim
  6. "
  7. " Specification of the DEP3 patch header format is available at:
  8. " https://dep-team.pages.debian.net/deps/dep3/
  9. " Standard syntax initialization
  10. if exists('b:current_syntax')
  11. finish
  12. endif
  13. runtime! syntax/diff.vim
  14. unlet! b:current_syntax
  15. let s:cpo_save = &cpo
  16. set cpo&vim
  17. syn region dep3patchHeaders start="\%^" end="^\%(---\)\@=" contains=dep3patchKey,dep3patchMultiField
  18. syn case ignore
  19. syn region dep3patchMultiField matchgroup=dep3patchKey start="^\%(Description\|Subject\)\ze: *" skip="^[ \t]" end="^$"me=s-1 end="^[^ \t#]"me=s-1 contained contains=@Spell
  20. syn region dep3patchMultiField matchgroup=dep3patchKey start="^Origin\ze: *" end="$" contained contains=dep3patchHTTPUrl,dep3patchCommitID,dep3patchOriginCategory oneline keepend
  21. syn region dep3patchMultiField matchgroup=dep3patchKey start="^Bug\%(-[[:graph:]]\+\)\?\ze: *" end="$" contained contains=dep3patchHTTPUrl oneline keepend
  22. syn region dep3patchMultiField matchgroup=dep3patchKey start="^Forwarded\ze: *" end="$" contained contains=dep3patchHTTPUrl,dep3patchForwardedShort oneline keepend
  23. syn region dep3patchMultiField matchgroup=dep3patchKey start="^\%(Author\|From\)\ze: *" end="$" contained contains=dep3patchEmail oneline keepend
  24. syn region dep3patchMultiField matchgroup=dep3patchKey start="^\%(Reviewed-by\|Acked-by\)\ze: *" end="$" contained contains=dep3patchEmail oneline keepend
  25. syn region dep3patchMultiField matchgroup=dep3patchKey start="^Last-Update\ze: *" end="$" contained contains=dep3patchISODate oneline keepend
  26. syn region dep3patchMultiField matchgroup=dep3patchKey start="^Applied-Upstream\ze: *" end="$" contained contains=dep3patchHTTPUrl,dep3patchCommitID oneline keepend
  27. syn match dep3patchHTTPUrl contained "\vhttps?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$"
  28. syn match dep3patchCommitID contained "commit:[[:alnum:]]\+"
  29. syn match dep3patchOriginCategory contained "\%(upstream\|backport\|vendor\|other\), "
  30. syn match dep3patchForwardedShort contained "\%(yes\|no\|not-needed\), "
  31. syn match dep3patchEmail "[_=[:alnum:]\.+-]\+@[[:alnum:]\./\-]\+"
  32. syn match dep3patchEmail "<.\{-}>"
  33. syn match dep3patchISODate "[[:digit:]]\{4}-[[:digit:]]\{2}-[[:digit:]]\{2}"
  34. " Associate our matches and regions with pretty colours
  35. hi def link dep3patchKey Keyword
  36. hi def link dep3patchOriginCategory Keyword
  37. hi def link dep3patchForwardedShort Keyword
  38. hi def link dep3patchMultiField Normal
  39. hi def link dep3patchHTTPUrl Identifier
  40. hi def link dep3patchCommitID Identifier
  41. hi def link dep3patchEmail Identifier
  42. hi def link dep3patchISODate Identifier
  43. let b:current_syntax = 'dep3patch'
  44. let &cpo = s:cpo_save
  45. unlet s:cpo_save
  46. " vim: ts=8 sw=2