Currently SQL storage like "varchar(24)" is all defined as storage.type.sql
It would be nice if the numeric length was picked out as constant.numeric.sql
So a suggestion for whomever maintains the sql bundle: can we change the simple regexp for storage type to a capture type.
I think something like this?
{ name = 'meta.storage.type.sql'; match = '(?i:\b(bigint|bigserial|bit|bit\svarying(\d+)|boolean|box|bytea|character \s(varying)?(\d+)|char(\d+)|var\schar(\d+)|char((\d+))?|cidr|circle| date|double\sprecision|float(\d+)|inet|int|integer|interval(\d+)|line|ls eg|macaddr|money|number((\d+))?|numeric((\d+,\d+))?|oid|path|point|polyg on|real|smallint|serial|sysdate|text|times((\d+))(\swithoutstimeszone)?|ti mestamp(s((\d+))(\swithoutstimeszone)?)?|tinyint(\d+)|varchar\d?((\d+) )?)\s*)\b';
captures = { 1 = { name = 'storage.type.sql'; }; 2 = { name = 'constant.numeric.sql'; }; }; },
On 24. Oct 2006, at 21:31, Timothy Bates wrote:
So a suggestion for whomever maintains the sql bundle: can we change the simple regexp for storage type to a capture type.
I think something like this? [...]
Well, because of how the commands have different use of integers, it ends up being a lot of captures, but I “unfolded” it into the rule below.
Looking at that pattern though, I wonder if the last brahcn shouldn’t use \s instead of s?
I.e. with s it matches: ‘timestamps(42) withoutstimeszone’ instead of ‘timestamp (42) withoutstimeszone’.
{ match = '(?xi)
# normal stuff, capture 1 \b(bigint|bigserial|bit|boolean|box|bytea|cidr|circle|date| double\sprecision|inet|int|integer|line|lseg|macaddr|money|oid|path| point|polygon|real|serial|smallint|sysdate|text)\b
# numeric suffix, capture 2 + 3i |\b(bit\svarying|character\s(?:varying)?|tinyint|var\schar| float|interval)((\d+))
# optional numeric suffix, capture 4 + 5i |\b(char|number|varchar\d?)\b(?:((\d+)))?
# special case, capture 6 + 7i + 8i |\b(numeric)\b(?:((\d+),(\d+)))?
# special case, captures 9, 10i, 11 |\b(times)(?:((\d+)))(\swithoutstimeszone\b)?
# special case, captures 12, 13, 14i, 15 |\b(timestamp)(?:(s)((\d+))(\swithoutstimeszone\b)?)?
'; captures = { 1 = { name = 'storage.type.sql'; }; 2 = { name = 'storage.type.sql'; }; 3 = { name = 'constant.numeric.sql'; }; 4 = { name = 'storage.type.sql'; }; 5 = { name = 'constant.numeric.sql'; }; 6 = { name = 'storage.type.sql'; }; 7 = { name = 'constant.numeric.sql'; }; 8 = { name = 'constant.numeric.sql'; }; 9 = { name = 'storage.type.sql'; }; 10 = { name = 'constant.numeric.sql'; }; 11 = { name = 'storage.type.sql'; }; 12 = { name = 'storage.type.sql'; }; 13 = { name = 'storage.type.sql'; }; 14 = { name = 'constant.numeric.sql'; }; 15 = { name = 'storage.type.sql'; }; }; },