From: Alexis Laferrière Date: Tue, 29 Jan 2013 20:56:45 +0000 (-0500) Subject: misc: extends Vim syntax highlighting for the FFI X-Git-Tag: v0.6~100^2~8 X-Git-Url: http://nitlanguage.org misc: extends Vim syntax highlighting for the FFI First, this recognizes the use of inline foreign code. It also switches language highlighting for the inlined language. This commit supports only inlined C and Python code, but more can easily be added. Signed-off-by: Alexis Laferrière --- diff --git a/misc/vim/syntax/nit.vim b/misc/vim/syntax/nit.vim index 2f03435..288d64c 100644 --- a/misc/vim/syntax/nit.vim +++ b/misc/vim/syntax/nit.vim @@ -18,8 +18,14 @@ " See the License for the specific language governing permissions and " limitations under the License. -if exists("b:current_syntax") - finish +if !exists("main_syntax") + if version < 600 + syntax clear + elseif exists("b:current_syntax") + finish + endif + " we define it here so that included files can test for it + let main_syntax='nit' endif " Expression Substitution and Backslash Notation @@ -110,4 +116,21 @@ hi def link NITExprSubstError Error hi def link NITComment Comment hi def link NITTodo Todo +" FFI Section +syn match NITFFIDelimiters "\<\(`{\|`}\)\>" +hi def link NITFFIDelimiters Keyword +" FFI Python +syntax include @FFIPython syntax/python.vim +unlet b:current_syntax +syn match NITFFILanguage '"Python"' nextgroup=NITFFIBlockPython skipwhite +syn region NITFFIBlockPython matchgroup=NITFFI start='`{' matchgroup=NITFFI end='`}' keepend fold contains=@FFIPython + +" FFI C (the last one is the default) +syntax include @FFIC syntax/c.vim +unlet b:current_syntax +syn match NITFFILanguage '"C\(\| header\| body\)"' nextgroup=NITFFIBlockC skipwhite +syn region NITFFIBlockC matchgroup=NITFFI start='`{' matchgroup=NITFFI end='`}' keepend fold contains=@FFIC + +hi def link NITFFILanguage Define + let b:current_syntax = "Nit"