yaml.vim 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. " To make this file do stuff, add something like the following (without the
  2. " leading ") to your ~/.vimrc:
  3. " au BufNewFile,BufRead *.yaml,*.yml so ~/src/PyYaml/YAML.vim
  4. " Vim syntax/macro file
  5. " Language: YAML
  6. " Author: Igor Vergeichik <iverg@mail.ru>
  7. " Sponsor: Tom Sawyer <transami@transami.net>
  8. " Stayven: Ryan King <jking@panoptic.com>
  9. " Copyright (c) 2002 Tom Saywer
  10. " Add an item to a gangly list:
  11. "map , o<bs><bs><bs><bs>-<esc>o
  12. " Convert to Canonical form:
  13. "map \c :%!python -c 'from yaml.redump import redump; import sys; print redump(sys.stdin.read()).rstrip()'
  14. if version < 600
  15. syntax clear
  16. elseif exists("b:current_syntax")
  17. finish
  18. endif
  19. syntax clear
  20. syn match yamlDelimiter "[:,-]"
  21. syn match yamlBlock "[\[\]\{\}\|\>]"
  22. syn match yamlOperator "[?^+-]\|=>"
  23. syn region yamlComment start="\#" end="$"
  24. syn match yamlIndicator "#YAML:\S\+"
  25. syn region yamlString start="'" end="'" skip="\\'"
  26. syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape
  27. syn match yamlEscape +\\[abfnrtv'"\\]+ contained
  28. syn match yamlEscape "\\\o\o\=\o\=" contained
  29. syn match yamlEscape "\\x\x\+" contained
  30. syn match yamlType "!\S\+"
  31. syn keyword yamlConstant NULL Null null NONE None none NIL Nil nil
  32. syn keyword yamlConstant TRUE True true YES Yes yes ON On on
  33. syn keyword yamlConstant FALSE False false NO No no OFF Off off
  34. syn match yamlKey "\w\+\ze\s*:"
  35. syn match yamlAnchor "&\S\+"
  36. syn match yamlAlias "*\S\+"
  37. " Setupt the hilighting links
  38. hi link yamlConstant Keyword
  39. hi link yamlIndicator PreCondit
  40. hi link yamlAnchor Function
  41. hi link yamlAlias Function
  42. hi link yamlKey Identifier
  43. hi link yamlType Type
  44. hi link yamlComment Comment
  45. hi link yamlBlock Operator
  46. hi link yamlOperator Operator
  47. hi link yamlDelimiter Delimiter
  48. hi link yamlString String
  49. hi link yamlEscape Special