I modded my Textmate Javascript bundle today to treat 'true' and 'false' different to the other constants. http://vennt.net/tempting/intelibool.png So now true gets a green highlight and false a red one so you can read if statements at a glance etc
Here are the lines I modified
{ name = 'constant.language.js'; match = '\b(false|null|super|this|true)\b'; }, was replaced with
{ name = 'constant.language.js'; match = '\b(null|super|this)\b'; }, { name = 'constant.language.js.true'; match = '\b(true)\b'; }, { name = 'constant.language.js.false'; match = '\b(false)\b'; },
Then I just added rules to my current theme for "constant.language.js.true" and "constant.language.js.false"
I would have done it Textmate wide but I don't know enough about the system for that, is there any implications for what I have done here?
{ name = 'constant.language.js'; match = '\b(null|super|this)\b'; }, { name = 'constant.language.js.true'; match = '\b(true)\b'; }, { name = 'constant.language.js.false'; match = '\b(false)\b'; },
Then I just added rules to my current theme for "constant.language.js.true" and "constant.language.js.false"
I would have done it Textmate wide but I don't know enough about the system for that, is there any implications for what I have done here?
There is actually a quasi-standard here, in the languages that scope booleans they are "constant.language.boolean.* The language part always goes last. So if you want to do this I'd use "constant.language.boolean.true.js" etc.
There isn't any real reason not to do this, the only real issue is that in customizing your language like this you fork it off, ie: you'll no longer get updates to the grammar when it'd changed in the future.
Looking at Javascript it is a 'flat' language currently so you could create a new language grammar with your two custom rules then just inherit javascript and you'd keep getting updates.
No downside to putting this in the main grammar though if no one objects. I'm always one for more scope info. ;)
{ name = 'constant.language.js'; match = '\b(false|null|super|this|true)\b'; },
was replaced with
{ name = 'constant.language.js'; match = '\b(null|super|this)\b'; }, { name = 'constant.language.js.true'; match = '\b(true)\b'; }, { name = 'constant.language.js.false'; match = '\b(false)\b'; },
Ok, I just commited a change to make them constant.language.boolean.true|false.js
I notice in the above that your actually using a reasonably old Javascript syntax, super|this was moved to variable.language back in August, might want to update your copy of TM :)
Once the next update goes out you can go into your ~/Library/ Application Support/TextMate/Bundles folder and remove the Javascript bundle there to get back to the default grammar. Unless of course you have other changes in there you want to keep.