facelessuser / BracketHighlighter

Bracket and tag highlighter for Sublime Text
https://facelessuser.github.io/BracketHighlighter/
1.75k stars 245 forks source link

CASE and BEGIN tag for SQL Query #611

Closed yanleiberg closed 1 year ago

yanleiberg commented 1 year ago

Hello,

I am requesting a feature to highlight the CASE END and BEGIN END braceket clauses for SQL queries. I have attempted to enable this feature using the settings provided below, but it is not working for me. Could you please provide assistance in getting this feature to work or suggest what is the proper setting should be?

Thank you.

{ "scope_brackets": [ // Quotes { "name": "sql_case", "open": "(?i)case", "close": "(?i)end", "style": "string", "scopes": ["string", "meta.string"], "language_filter": "allowlist", "language_list": [ "Plain text" ], "sub_bracket_search": "true", "enabled": true }, { "name": "sql_case", "open": "(?i)begin", "close": "(?i)end", "style": "string", "scopes": ["string", "meta.string"], "language_filter": "allowlist", "language_list": [ "Plain text" ], "sub_bracket_search": "true", "enabled": true }, ] }

facelessuser commented 1 year ago

You would need to provide:

If you can provide the above, I'm happy to try out your attempt and advise accordingly.

yanleiberg commented 1 year ago

The syntax link:
https://github.com/sublimehq/Packages/blob/master/SQL/SQL.sublime-syntax

An example for BEGIN ... END statement:

BEGIN
    SELECT
        product_id,
        product_name
    FROM
        production.products
    WHERE
        list_price > 100000;

    IF @@ROWCOUNT = 0
        PRINT 'No product with price greater than 100000 found';
END

An example for CASE ... END statement:

SELECT
    CustomerName
   ,City
   ,Country
FROM Customers
ORDER BY (CASE
    WHEN City IS NULL THEN 
            CASE
            WHEN Country IS NULL THEN CustomerName
            ELSE Country
        END
    ELSE City
END);

The common characters that may appear before or after "BEGIN", "CASE" AND "END" are space, tab and linebreak.

The other characters that may appear before "BEGIN" are semicolon and left parenthesis. The other characters that may appear after the "END" of "BEGIN END" are semicolon and right parenthesis.

The other character that may appear before "CASE" is left parenthesis. The other character that may appear after the "END" of "CASE END" is right parenthesis.

The keywords like BEGIN, CASE, ELSE are case insensitive which means "begin", "BeGin" or "bEGIn" are also legitimate.