Hi,
Short: I’m trying to change a syntax definition so as to stop capturing string.quoted.single.c if the ’ is preceded by a #
Description:
I am switching from Textmate to Sublime Text 2 for LPC programming. This uses mostly C syntax, with a notable exception: we have a ‘closure’ which has the format of:
#'func_name
The problem I’m having is that the ’ in #’ gets captured by the string.quoted.single.c bit of syntax highlighting.
I’d avoided this in Textmate using the following change in the syntax definition:
{ name = 'string.quoted.single.c';
begin = "(?<!#)'";
end = "'";
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.c'; }; };
endCaptures = { 0 = { name = 'punctuation.definition.string.end.c'; }; };
patterns = ( { include = '#string_escaped_char'; } );
},
I tried altering both the C.tmlanguage file with the (?<!#) addition, but this ends in a parsing failure. I’ve tried editing the user specific syntax with a snippet to override string.quoted.single.c.
{ "name": "LPC Single-Quote",
"scopeName": "source.c",
"fileTypes": "c""h"],
"patterns":
{"name": "string.quoted.single.c",
"begin": "(?<!#)'",
"beginCaptures": {
"0" : { "name" : "punctuation.definition.string.begin.c" }
},
"endCaptures" : {
"0" : { "name" : "punctuation.definition.string.end.c" }
},
"patterns" : { "include" : "#string_escaped_char"} ],
"end" : "'"
}
],
"uuid": "2aeaa0d9-69e2-46a5-b631-792d8e0d8182"
}
I’ve tried editing a new snippet with that as well. I’ve also tried creating a new snippet called string.closure.c which tried to match #’ and capture that over the string.quoted.single.c and format it a different colour. I’ve tried placing this snippet in C.sublime-settings. None of these have been successful – and I’m sure it’s because I’m doing something wrong.
Can someone lend a hand? I just want sublime text “C” parser to ignore #’ rather than thinking it’s the beginning of a string.
Thanks
Zyzzyr