I'm writting a syntax file for Direct3D and I have a problem with the attributes:
[unroll]
for(int i = 0...)
Here, "unroll" is an attribute. I'm using a regex to find some keywords inside square brackets to identify them as attributes. The regex I'm using works, except when there are no spaces before the opening square bracket:
[unroll] // does not work
[unroll] // works
It doesn't matter the number of whitespaces (or tabs) before the opening square bracket as far as there is at least one.
This is the regex (simplified to match only unroll) I'm using:
syn match hlslAttribute /^\s*\[unroll\]/
The same problems if using:
syn match hlslAttribute /.*\[unroll\]/
EDIT: As stated in a comment: It works while searching on the file, but not when matching the pattern for syntax highlighting.
The current syntax highlighting file can be found at: http://pastebin.com/zr1bGLt0
To enable the syntax hilighting for .fx or .hlsl files you must copy the hlsl.vim file (the one at pastebin) to the location of the syntax files in any Vim installation (/syntax: /usr/share/vim/vim73/syntax/) and add this line to your .vimrc:
autocmd BufNewFile,BufRead *.fx,*.fxc,*.fxh,*.hlsl set ft=hlsl
Then create a file with one of the previous extensions and write:
[unroll]
[unroll]
The second line will be all the same color, while the first won't. Both of them should be like the second one.