neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

prolog.vim (4494B)


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