Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize the highlight syntax manually #4

Closed
bscan opened this issue Oct 29, 2020 · 5 comments
Closed

Customize the highlight syntax manually #4

bscan opened this issue Oct 29, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@bscan
Copy link

bscan commented Oct 29, 2020

Hi, this extension is great for VSCode, thanks! For SQL, is it possible to add a setting to disable the highlighting on UPPERCASE statements? I often read existing code with embedded SQL that does not have semicolon endings. For these cases, the highlighting will be incorrect for the rest of the code. Python example below.

print(2) # Highlighted correctly

query = """
SELECT *
FROM db.tbl
"""

print(2) # Not highlighted correctly
@iuyoy
Copy link
Owner

iuyoy commented Nov 1, 2020

Hi @bscan,
This extension implements the highlighting by syntax highlight method , which means there is only a JSON config for highlight rules, and any function of setting should be implemented in TS or JS. So currently, any rule cannot be disabled by settings.

There is a manual way to disable it:

  1. locate to the extension install folder in your computer.
  2. delete highlighted part of the following picture in syntaxes/highlight-string-code.json.
    image
  3. reload this extension or restart VSCode to make it work.

Also, I have an idea to modify the rule JSON config by a TS/JS script, but I am not sure if it can work. Please excuse me for the slow development, because my current work has less relation with SQL or other embedded languages.

@Nu11u5
Copy link

Nu11u5 commented Jan 5, 2023

The SQL uppercase rule is triggered by any match, even if the keyword is in the middle of another word. Additionally, the text must include a ; semicolon for the matching to end.

(Example using PowerShell, where I encountered the issue, but it should affect any language)

image

While the SQL keyword matching is useful for inline text it is more likely to cause problems than solve them as implemented.

At the very least, the SQL keyword rule regex should match if the keyword is preceded by a word boundary metacharacter - this would fix issues where the keyword appears at the end of another word in a non-SQL statement. However, this is only an edge case.

For best experience, the SQL keyword rule should be removed completely. SQL syntax highlighting can still be achieved using multiline text with --beginsql / --endsql comments.

@iuyoy iuyoy changed the title Option to disable UPPERCASE SQL statement Customize the highlight syntax manually Mar 17, 2023
@iuyoy
Copy link
Owner

iuyoy commented Mar 17, 2023

The SQL uppercase rule is triggered by any match, even if the keyword is in the middle of another word. Additionally, the text must include a ; semicolon for the matching to end.

(Example using PowerShell, where I encountered the issue, but it should affect any language)

image

While the SQL keyword matching is useful for inline text it is more likely to cause problems than solve them as implemented.

At the very least, the SQL keyword rule regex should match if the keyword is preceded by a word boundary metacharacter - this would fix issues where the keyword appears at the end of another word in a non-SQL statement. However, this is only an edge case.

For best experience, the SQL keyword rule should be removed completely. SQL syntax highlighting can still be achieved using multiline text with --beginsql / --endsql comments.

In my view, adding a ; is much easier than multiline text to highlight a sql.
If you prefer to disable this feature, the above response can help.

@Nu11u5
Copy link

Nu11u5 commented Mar 21, 2023

In my view, adding a ; is much easier than multiline text to highlight a sql.

In case there is a misunderstanding - adding a ; cannot not fix this issue, since the code is not even SQL. None of the code shown is SQL yet the extension highlights it anyway.

@iuyoy
Copy link
Owner

iuyoy commented Mar 22, 2023

In my view, adding a ; is much easier than multiline text to highlight a sql.

In case there is a misunderstanding - adding a ; cannot not fix this issue, since the code is not even SQL. None of the code shown is SQL yet the extension highlights it anyway.

I understand. I was just explaining why I added the SQL keyword rule. Due to the limitations mentioned in #6, this is the best compromise I can offer. Different people have their own requirements, so I recommend editing the syntaxes to solve your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants