Skip to content

Commit 551aed1

Browse files
committed
Added pyrex syntax
1 parent 304931e commit 551aed1

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

syntax/pyrex.vim

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
" Vim syntax file
2+
" Language: Pyrex
3+
" Maintainer: John Tyree
4+
" Last Change: 2012 Nov 06
5+
6+
" For version 5.x: Clear all syntax items
7+
" For version 6.x: Quit when a syntax file was already loaded
8+
if version < 600
9+
syntax clear
10+
elseif exists("b:current_syntax")
11+
finish
12+
endif
13+
14+
" Read the Python syntax to start with
15+
if version < 600
16+
so <sfile>:p:h/python.vim
17+
else
18+
runtime! syntax/python.vim
19+
unlet b:current_syntax
20+
endif
21+
22+
" Pyrex extentions
23+
syn keyword pyrexStatement nogil inline typedef ctypedef sizeof
24+
syn keyword pyrexType Py_ssize_t int long short float double char object void
25+
" Here we want slightly different behavior depending on whether we're declaring
26+
" variables or functions. c[p]def should work on the top level as a keyword, but
27+
" should ALSO work to identify functions and classes.
28+
syn match pyrexStatement "\<cp\?def\>"
29+
syn match pyrexStatement "\<cp\?def\>[^=]*(\@=" contains=pythonStatement,pyrexStatement,pythonFunction,pyrexType skipwhite
30+
syn keyword pyrexType signed unsigned
31+
syn keyword pyrexStructure struct union enum
32+
syn keyword pyrexInclude include cimport
33+
syn keyword pyrexAccess public private property readonly extern
34+
" If someome wants Python's built-ins highlighted probably he
35+
" also wants Pyrex's built-ins highlighted
36+
if exists("python_highlight_builtins") || exists("pyrex_highlight_builtins")
37+
syn keyword pyrexBuiltin NULL
38+
endif
39+
40+
" This deletes "from" from the keywords and re-adds it as a
41+
" match with lower priority than pyrexForFrom
42+
syn clear pythonInclude
43+
syn keyword pythonInclude import
44+
syn match pythonInclude "\<from\>"
45+
46+
" With "for[^:]*\zsfrom" VIM does not match "for" anymore, so
47+
" I used the slower "\@<=" form
48+
syn match pyrexForFrom "\(\<for\>[^:]*\)\@<=\<from\>"
49+
50+
" Default highlighting
51+
if version >= 508 || !exists("did_pyrex_syntax_inits")
52+
if version < 508
53+
let did_pyrex_syntax_inits = 1
54+
command -nargs=+ HiLink hi link <args>
55+
else
56+
command -nargs=+ HiLink hi def link <args>
57+
endif
58+
HiLink pyrexStatement Statement
59+
HiLink pyrexType Type
60+
HiLink pyrexStructure Structure
61+
HiLink pyrexInclude PreCondit
62+
HiLink pyrexAccess pyrexStatement
63+
if exists("python_highlight_builtins") || exists("pyrex_highlight_builtins")
64+
HiLink pyrexBuiltin Function
65+
endif
66+
HiLink pyrexForFrom Statement
67+
68+
delcommand HiLink
69+
endif
70+
71+
let b:current_syntax = "pyrex"

0 commit comments

Comments
 (0)