From 4e5a0bf876a788a912abb2dc2c6740639a126b6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 29 Jan 2013 15:56:45 -0500 Subject: [PATCH] misc: extends Vim syntax highlighting for the FFI MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- misc/vim/syntax/nit.vim | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) 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" -- 1.7.9.5