1" Vim syntax file 2" Language: Clean 3" Author: Pieter van Engelen <[email protected]> 4" Co-Author: Arthur van Leeuwen <[email protected]> 5" Last Change: 2013 Oct 15 by Jurriën Stutterheim 6 7" quit when a syntax file was already loaded 8if exists("b:current_syntax") 9 finish 10endif 11 12let s:cpo_save = &cpo 13set cpo&vim 14 15" Some Clean-keywords 16syn keyword cleanConditional if case 17syn keyword cleanLabel let! with where in of 18syn keyword cleanSpecial Start 19syn keyword cleanKeyword infixl infixr infix 20syn keyword cleanBasicType Int Real Char Bool String 21syn keyword cleanSpecialType World ProcId Void Files File 22syn keyword cleanModuleSystem module implementation definition system 23syn keyword cleanTypeClass class instance export 24 25" Import highlighting 26syn region cleanIncludeRegion start="^\s*\(from\|import\|\s\+\(as\|qualified\)\)" end="\n" contains=cleanIncludeKeyword keepend 27syn keyword cleanIncludeKeyword contained from import as qualified 28 29" To do some Denotation Highlighting 30syn keyword cleanBoolDenot True False 31syn region cleanStringDenot start=+"+ skip=+\(\(\\\\\)\+\|\\"\)+ end=+"+ display 32syn match cleanCharDenot "'\(\\\\\|\\'\|[^'\\]\)\+'" display 33syn match cleanIntegerDenot "[\~+-]\?\<\(\d\+\|0[0-7]\+\|0x[0-9A-Fa-f]\+\)\>" display 34syn match cleanRealDenot "[\~+-]\?\d\+\.\d\+\(E[\~+-]\?\d\+\)\?" display 35 36" To highlight the use of lists, tuples and arrays 37syn region cleanList start="\[" end="\]" contains=ALL 38syn region cleanRecord start="{" end="}" contains=ALL 39syn region cleanArray start="{:" end=":}" contains=ALL 40syn match cleanTuple "([^=]*,[^=]*)" contains=ALL 41 42" To do some Comment Highlighting 43syn region cleanComment start="/\*" end="\*/" contains=cleanComment,cleanTodo fold 44syn region cleanComment start="//.*" end="$" display contains=cleanTodo 45syn keyword cleanTodo TODO FIXME XXX contained 46 47" Now for some useful type definition recognition 48syn match cleanFuncTypeDef "\([a-zA-Z].*\|(\=[-~@#$%^?!+*<>\/|&=:]\+)\=\)\s*\(infix[lr]\=\)\=\s*\d\=\s*::.*->.*" contains=cleanSpecial,cleanBasicType,cleanSpecialType,cleanKeyword 49 50 51" Define the default highlighting. 52" Only when an item doesn't have highlighting yet 53 54 " Comments 55 hi def link cleanComment Comment 56 " Constants and denotations 57 hi def link cleanStringDenot String 58 hi def link cleanCharDenot Character 59 hi def link cleanIntegerDenot Number 60 hi def link cleanBoolDenot Boolean 61 hi def link cleanRealDenot Float 62 " Identifiers 63 " Statements 64 hi def link cleanTypeClass Keyword 65 hi def link cleanConditional Conditional 66 hi def link cleanLabel Label 67 hi def link cleanKeyword Keyword 68 " Generic Preprocessing 69 hi def link cleanIncludeKeyword Include 70 hi def link cleanModuleSystem PreProc 71 " Type 72 hi def link cleanBasicType Type 73 hi def link cleanSpecialType Type 74 hi def link cleanFuncTypeDef Typedef 75 " Special 76 hi def link cleanSpecial Special 77 hi def link cleanList Special 78 hi def link cleanArray Special 79 hi def link cleanRecord Special 80 hi def link cleanTuple Special 81 " Error 82 " Todo 83 hi def link cleanTodo Todo 84 85 86let b:current_syntax = "clean" 87 88let &cpo = s:cpo_save 89unlet s:cpo_save 90" vim: ts=4 91