Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Modula 2 |
| 3 | " Maintainer: pf@artcom0.north.de (Peter Funk) |
| 4 | " based on original work of Bram Moolenaar <Bram@vim.org> |
| 5 | " Last Change: 2001 May 09 |
| 6 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 7 | " quit when a syntax file was already loaded |
| 8 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9 | finish |
| 10 | endif |
| 11 | |
| 12 | " Don't ignore case (Modula-2 is case significant). This is the default in vim |
| 13 | |
| 14 | " Especially emphasize headers of procedures and modules: |
| 15 | syn region modula2Header matchgroup=modula2Header start="PROCEDURE " end="(" contains=modula2Ident oneline |
| 16 | syn region modula2Header matchgroup=modula2Header start="MODULE " end=";" contains=modula2Ident oneline |
| 17 | syn region modula2Header matchgroup=modula2Header start="BEGIN (\*" end="\*)" contains=modula2Ident oneline |
| 18 | syn region modula2Header matchgroup=modula2Header start="END " end=";" contains=modula2Ident oneline |
| 19 | syn region modula2Keyword start="END" end=";" contains=ALLBUT,modula2Ident oneline |
| 20 | |
| 21 | " Some very important keywords which should be emphasized more than others: |
| 22 | syn keyword modula2AttKeyword CONST EXIT HALT RETURN TYPE VAR |
| 23 | " All other keywords in alphabetical order: |
| 24 | syn keyword modula2Keyword AND ARRAY BY CASE DEFINITION DIV DO ELSE |
| 25 | syn keyword modula2Keyword ELSIF EXPORT FOR FROM IF IMPLEMENTATION IMPORT |
| 26 | syn keyword modula2Keyword IN LOOP MOD NOT OF OR POINTER QUALIFIED RECORD |
| 27 | syn keyword modula2Keyword SET THEN TO UNTIL WHILE WITH |
| 28 | |
| 29 | syn keyword modula2Type ADDRESS BITSET BOOLEAN CARDINAL CHAR INTEGER REAL WORD |
| 30 | syn keyword modula2StdFunc ABS CAP CHR DEC EXCL INC INCL ORD SIZE TSIZE VAL |
| 31 | syn keyword modula2StdConst FALSE NIL TRUE |
| 32 | " The following may be discussed, since NEW and DISPOSE are some kind of |
| 33 | " special builtin macro functions: |
| 34 | syn keyword modula2StdFunc NEW DISPOSE |
| 35 | " The following types are added later on and may be missing from older |
| 36 | " Modula-2 Compilers (they are at least missing from the original report |
| 37 | " by N.Wirth from March 1980 ;-) Highlighting should apply nevertheless: |
| 38 | syn keyword modula2Type BYTE LONGCARD LONGINT LONGREAL PROC SHORTCARD SHORTINT |
| 39 | " same note applies to min and max, which were also added later to m2: |
| 40 | syn keyword modula2StdFunc MAX MIN |
| 41 | " The underscore was originally disallowed in m2 ids, it was also added later: |
| 42 | syn match modula2Ident " [A-Z,a-z][A-Z,a-z,0-9,_]*" contained |
| 43 | |
| 44 | " Comments may be nested in Modula-2: |
| 45 | syn region modula2Comment start="(\*" end="\*)" contains=modula2Comment,modula2Todo |
| 46 | syn keyword modula2Todo contained TODO FIXME XXX |
| 47 | |
| 48 | " Strings |
| 49 | syn region modula2String start=+"+ end=+"+ |
| 50 | syn region modula2String start="'" end="'" |
| 51 | syn region modula2Set start="{" end="}" |
| 52 | |
| 53 | " Define the default highlighting. |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 54 | " Only when an item doesn't have highlighting yet |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 55 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 56 | hi def link modula2Ident Identifier |
| 57 | hi def link modula2StdConst Boolean |
| 58 | hi def link modula2Type Identifier |
| 59 | hi def link modula2StdFunc Identifier |
| 60 | hi def link modula2Header Type |
| 61 | hi def link modula2Keyword Statement |
| 62 | hi def link modula2AttKeyword PreProc |
| 63 | hi def link modula2Comment Comment |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 64 | " The following is just a matter of taste (you want to try this instead): |
| 65 | " hi modula2Comment term=bold ctermfg=DarkBlue guifg=Blue gui=bold |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 66 | hi def link modula2Todo Todo |
| 67 | hi def link modula2String String |
| 68 | hi def link modula2Set String |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 69 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 70 | |
| 71 | let b:current_syntax = "modula2" |
| 72 | |
| 73 | " vim: ts=8 |