1 " Vim highlighting for PyOpenCL
2 " -----------------------------
4 " (C) Andreas Kloeckner 2011, MIT license
6 " Uses parts of mako.vim by Armin Ronacher.
9 " Just drop this file into ~/.vim/syntax/pyopencl.vim
12 " :set filetype=pyopencl
14 " """//CL// ...code..."""
15 " for OpenCL code included in your Python file.
17 " You may also include a line
18 " vim: filetype=pyopencl.python
19 " at the end of your file to set the file type automatically.
21 " Optional: Install opencl.vim from
22 " http://www.vim.org/scripts/script.php?script_id=3157
24 runtime! syntax/python.vim
26 unlet b:current_syntax
28 syntax include @clCode syntax/opencl.vim
30 syntax include @clCode syntax/c.vim
33 unlet b:current_syntax
34 syn include @pythonTop syntax/python.vim
38 syn region clmakoLine start="^\s*%" skip="\\$" end="$"
39 syn region clmakoVariable start=#\${# end=#}# contains=@pythonTop
40 syn region clmakoBlock start=#<%!# end=#%># keepend contains=@pythonTop
42 syn match clmakoAttributeKey containedin=clmakoTag contained "[a-zA-Z_][a-zA-Z0-9_]*="
43 syn region clmakoAttributeValue containedin=clmakoTag contained start=/"/ skip=/\\"/ end=/"/
44 syn region clmakoAttributeValue containedin=clmakoTag contained start=/'/ skip=/\\'/ end=/'/
46 syn region clmakoTag start="</\?%\(def\|call\|page\|include\|namespace\|inherit\|self:[_[:alnum:]]\+\)\>" end="/\?>"
48 " The C highlighter's paren error detection screws up highlighting of
49 " Mako variables in C parens--turn it off.
53 if !exists("c_no_bracket_error")
57 syn cluster clmakoCode contains=clmakoLine,clmakoVariable,clmakoBlock,clmakoTag
59 hi link clmakoLine Preproc
60 hi link clmakoVariable Preproc
61 hi link clmakoBlock Preproc
62 hi link clmakoTag Define
63 hi link clmakoAttributeKey String
64 hi link clmakoAttributeValue String
68 syn region pythonCLString
69 \ start=+[uU]\=\z('''\|"""\)//CL\(:[a-zA-Z_0-9]\+\)\?//+ end="\z1" keepend
70 \ contains=@clCode,@clmakoCode
72 syn region pythonCLRawString
73 \ start=+[uU]\=[rR]\z('''\|"""\)//CL\(:[a-zA-Z_0-9]\+\)\?//+ end="\z1" keepend
74 \ contains=@clCode,@clmakoCode
76 " Uncomment if you still want the code highlighted as a string.
77 " hi link pythonCLString String
78 " hi link pythonCLRawString String
82 let b:current_syntax = "pyopencl"
84 " vim: foldmethod=marker