misc: extends Vim syntax highlighting for the FFI
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 29 Jan 2013 20:56:45 +0000 (15:56 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 1 Feb 2013 19:34:17 +0000 (14:34 -0500)
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 <alexis.laf@xymus.net>

misc/vim/syntax/nit.vim

index 2f03435..288d64c 100644 (file)
 " 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"