prolog.vim 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. " Vim syntax file
  2. " Language: PROLOG
  3. " Maintainer: Anton Kochkov <anton.kochkov@gmail.com>
  4. " Last Change: 2021 Jan 05
  5. " There are two sets of highlighting in here:
  6. " If the "prolog_highlighting_clean" variable exists, it is rather sparse.
  7. " Otherwise you get more highlighting.
  8. "
  9. " You can also set the "prolog_highlighting_no_keyword" variable. If set,
  10. " keywords will not be highlighted.
  11. " quit when a syntax file was already loaded
  12. if exists("b:current_syntax")
  13. finish
  14. endif
  15. " Prolog is case sensitive.
  16. syn case match
  17. " Very simple highlighting for comments, clause heads and
  18. " character codes. It respects prolog strings and atoms.
  19. syn region prologCComment start=+/\*+ end=+\*/+ contains=@Spell
  20. syn match prologComment +%.*+ contains=@Spell
  21. if !exists("prolog_highlighting_no_keyword")
  22. syn keyword prologKeyword module meta_predicate multifile dynamic
  23. endif
  24. syn match prologCharCode +0'\\\=.+
  25. syn region prologString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell
  26. syn region prologAtom start=+'+ skip=+\\\\\|\\'+ end=+'+
  27. syn region prologClause matchgroup=prologClauseHead start=+^\s*[a-z]\w*+ matchgroup=Normal end=+\.\s\|\.$+ contains=ALLBUT,prologClause contains=@NoSpell
  28. if !exists("prolog_highlighting_clean")
  29. " some keywords
  30. " some common predicates are also highlighted as keywords
  31. " is there a better solution?
  32. if !exists("prolog_highlighting_no_keyword")
  33. syn keyword prologKeyword abolish current_output peek_code
  34. syn keyword prologKeyword append current_predicate put_byte
  35. syn keyword prologKeyword arg current_prolog_flag put_char
  36. syn keyword prologKeyword asserta fail put_code
  37. syn keyword prologKeyword assertz findall read
  38. syn keyword prologKeyword at_end_of_stream float read_term
  39. syn keyword prologKeyword atom flush_output repeat
  40. syn keyword prologKeyword atom_chars functor retract
  41. syn keyword prologKeyword atom_codes get_byte set_input
  42. syn keyword prologKeyword atom_concat get_char set_output
  43. syn keyword prologKeyword atom_length get_code set_prolog_flag
  44. syn keyword prologKeyword atomic halt set_stream_position
  45. syn keyword prologKeyword bagof integer setof
  46. syn keyword prologKeyword call is stream_property
  47. syn keyword prologKeyword catch nl sub_atom
  48. syn keyword prologKeyword char_code nonvar throw
  49. syn keyword prologKeyword char_conversion number true
  50. syn keyword prologKeyword clause number_chars unify_with_occurs_check
  51. syn keyword prologKeyword close number_codes var
  52. syn keyword prologKeyword compound once write
  53. syn keyword prologKeyword copy_term op write_canonical
  54. syn keyword prologKeyword current_char_conversion open write_term
  55. syn keyword prologKeyword current_input peek_byte writeq
  56. syn keyword prologKeyword current_op peek_char
  57. endif
  58. syn match prologOperator "=\\=\|=:=\|\\==\|=<\|==\|>=\|\\=\|\\+\|=\.\.\|<\|>\|="
  59. syn match prologAsIs "===\|\\===\|<=\|=>"
  60. syn match prologNumber "\<\d*\>'\@!"
  61. syn match prologNumber "\<0[xX]\x*\>'\@!"
  62. syn match prologCommentError "\*/"
  63. syn match prologSpecialCharacter ";"
  64. syn match prologSpecialCharacter "!"
  65. syn match prologSpecialCharacter ":-"
  66. syn match prologSpecialCharacter "-->"
  67. syn match prologQuestion "?-.*\." contains=prologNumber
  68. endif
  69. syn sync maxlines=50
  70. " Define the default highlighting.
  71. " Only when an item doesn't have highlighting yet
  72. " The default highlighting.
  73. hi def link prologComment Comment
  74. hi def link prologCComment Comment
  75. hi def link prologCharCode Special
  76. if exists ("prolog_highlighting_clean")
  77. hi def link prologKeyword Statement
  78. hi def link prologClauseHead Statement
  79. hi def link prologClause Normal
  80. else
  81. hi def link prologKeyword Keyword
  82. hi def link prologClauseHead Constant
  83. hi def link prologClause Normal
  84. hi def link prologQuestion PreProc
  85. hi def link prologSpecialCharacter Special
  86. hi def link prologNumber Number
  87. hi def link prologAsIs Normal
  88. hi def link prologCommentError Error
  89. hi def link prologAtom String
  90. hi def link prologString String
  91. hi def link prologOperator Operator
  92. endif
  93. let b:current_syntax = "prolog"
  94. " vim: ts=8