3 " Maintainer: Jean Privat <jean@pryen.org>
5 " This file is part of NIT ( http://www.nitlanguage.org ).
7 " Copyright 2009 Jean Privat <jean@pryen.org>
9 " Licensed under the Apache License, Version 2.0 (the "License");
10 " you may not use this file except in compliance with the License.
11 " You may obtain a copy of the License at
13 " http://www.apache.org/licenses/LICENSE-2.0
15 " Unless required by applicable law or agreed to in writing, software
16 " distributed under the License is distributed on an "AS IS" BASIS,
17 " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 " See the License for the specific language governing permissions and
19 " limitations under the License.
21 if !exists("main_syntax")
24 elseif exists("b:current_syntax")
27 " we define it here so that included files can test for it
31 " Expression Substitution and Backslash Notation
32 syn match NITExprSubstError "{\|}" contained
33 syn match NITExprSubst "\\." contained
34 syn match NITExprSubst "{[^}]*}" contained
36 " Numbers and ASCII Codes
37 syn match NITNumber "\<\(\d\+\.\d\+\|\d\+\)\>"
40 syn match NITClass "\<\u\w*"
41 syn match NITAttribute "\<_\h\w*"
44 syn region NITString matchgroup=NITStringDelimit start="\"" end="\"" skip="\\\\\|\\\"" contains=NITExprSubst,NITExprSubstError
45 syn region NITString matchgroup=NITStringDelimit start="'" end="'" skip="\\\\\|\\'"
48 syn match NITLabel "\<label \h\w*"
51 syn match NITClosure "!\h\w*"
53 " Fallback highlight keywords
54 syn match NITNull "\<\(null\)\>"
55 syn match NITControl "\<\(init\|end\|not null\|not\|var\|do\|then\|else\|loop\)\>"
56 syn match NITKeyword "\<\(super\)\>"
58 syn match Error "\<end\>"
60 " Declarations, definitions and blocks
61 syn region NITModuleDecl matchgroup=NITDefine start="\<\(import\|module\|package\)\>\s*" matchgroup=NONE end="\ze\(\s\|:\|(\|$\)" oneline
62 syn region NITClassBlock matchgroup=NITDefine start="\<\(class\|enum\|universal\|interface\|extern\)\>" matchgroup=NITDefine end="\<end\>" contains=ALL fold
63 syn region NITFunctionDecl matchgroup=NITDefine start="\<fun\>\s*" matchgroup=NONE end="\ze\(\<do\>\|\s\|:\|(\|$\)" oneline
64 syn region NITTypeDecl matchgroup=NITDefine start="\<type\>\s*" matchgroup=NONE end="\ze\(\<do\>\|\s\|:\|(\|$\)" oneline contained containedin=NITClassBlock
65 syn region NITAttrDecl matchgroup=NITDefine start="\<var\>\s*\ze_" matchgroup=NONE end="\ze\(\<do\>\|\s\|:\|(\|$\)" oneline contained containedin=NITClassBlock
66 syn region NITInitDecl matchgroup=NITDefine start="\<init\>\s*" matchgroup=NONE end="\ze\(\<do\>\|\s\|:\|(\|$\)" oneline contained containedin=NITClassBlock
67 syn match NITDefine "\<\(super\)\ze\s\+[A-Z]" contained containedin=NITClassBlock
69 syn region NITStmtBlock matchgroup=NITControl start="\<\(do\|then\|else\|loop\)\>\ze\s*\(#\|$\)" matchgroup=NITControl end="^\s*\<\(end\|\zeelse\|\ze!\)\>" contains=ALLBUT,NITTypeDecl,NITAttrDecl,NITInitDecl
70 syn region NITStmtBlock matchgroup=NITControl start="\<\(do\|then\|else\|loop\)\>" matchgroup=NITControl end="\<end\>" oneline
72 if !exists("NIT_minlines")
75 exec "syn sync minlines=" . NIT_minlines
77 " Comments and Documentation
78 syn match NITSharpBang "\%^#!.*"
79 syn match NITComment "#.*" contains=NITTodo
82 syn keyword NITKeyword is abstract intern new
83 syn keyword NITDefine private public protected intrude readable writable redef
84 syn keyword NITControl if while for assert and or in as isa once break continue return abort
85 syn keyword NITClass nullable
86 syn keyword NITInclude special
87 syn keyword NITTodo FIXME NOTE TODO XXX contained
88 syn keyword NITBoolean true false
89 syn keyword NITSelf self
91 " Define the default highlighting.
92 hi def link NITDefine Define
93 hi def link NITModuleDecl Identifier
94 hi def link NITFunctionDecl Function
95 hi def link NITTypeDecl Function
96 hi def link NITAttrDecl Function
97 hi def link NITInitDecl Function
98 hi def link NITControl Statement
99 hi def link NITLabel PreProc
100 hi def link NITInclude Include
101 hi def link NITNumber Number
102 hi def link NITBoolean Boolean
103 hi def link NITNull Constant
104 hi def link NITSelf Constant
105 hi def link NITClass Type
106 hi def link NITAttribute Identifier
107 hi def link NITClosure Function
108 hi def link NITSharpBang PreProc
109 hi def link NITKeyword Keyword
111 hi def link NITString String
112 hi def link NITStringDelimit Delimiter
113 hi def link NITExprSubst Special
114 hi def link NITExprSubstError Error
116 hi def link NITComment Comment
117 hi def link NITTodo Todo
120 syn match NITFFIDelimiters "\<\(`{\|`}\)\>"
121 hi def link NITFFIDelimiters Keyword
123 syntax include @FFIPython syntax/python.vim
124 unlet b:current_syntax
125 syn match NITFFILanguage '"Python"' nextgroup=NITFFIBlockPython skipwhite
126 syn region NITFFIBlockPython matchgroup=NITFFI start='`{' matchgroup=NITFFI end='`}' keepend fold contains=@FFIPython
128 " FFI C (the last one is the default)
129 syntax include @FFIC syntax/c.vim
130 unlet b:current_syntax
131 syn match NITFFILanguage '"C\(\| header\| body\)"' nextgroup=NITFFIBlockC skipwhite
132 syn region NITFFIBlockC matchgroup=NITFFI start='`{' matchgroup=NITFFI end='`}' keepend fold contains=@FFIC
134 hi def link NITFFILanguage Define
136 let b:current_syntax = "Nit"