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

feat(sql): add support for sql #22

Merged
merged 3 commits into from
Aug 10, 2023
Merged

feat(sql): add support for sql #22

merged 3 commits into from
Aug 10, 2023

Conversation

liljaylj
Copy link
Contributor

@liljaylj liljaylj commented Aug 9, 2023

add support for sql

@HiPhish
Copy link
Owner

HiPhish commented Aug 9, 2023

Does this actually work for you? I tried some simple queries and this one is giving me problems:

select *
from products
where (
	Product_Category = 'Fit'
	and  Product_number IN (1234, 1235, 1236, 1237, 1238)
)
or
	(Product_Category in ('Tight', 'Wide') and Product_number = 1324);

The first pair of parentheses is blue (level 2) and the second one is red (level 1), but both should be red (level 1).

Screenshot_20230809_155638

I think the problem is that in the tree all parentheses are on the same level, which means the pattern

(binary_expression
    "(" @opening
    ")" @closing) @container

matches multiple @opening and @closing captures. This might resolve on its own when neovim/neovim#17099 gets solved in Neovim. But I am just guessing here. What is your opinion, should I just merge it as is and hope for the best or should we wait and see? The question is which is the lesser evil, sometimes broken highlight pairs or no highlight pairs at all?

In either case please write a small test file here as well.

@liljaylj
Copy link
Contributor Author

liljaylj commented Aug 9, 2023

i see. may it be because parentheses are outside of binary_expression?

image

@HiPhish
Copy link
Owner

HiPhish commented Aug 9, 2023

No, they are still part of some binary_expression, just not the one you are looking at. Press a in the TS Playground to toggle the anonymous nodes and you will see where in the tree the parentheses are. This would not be a problem if there was some parenthesized_expression node that wraps the pair like in some other languages, but here all the parentheses are children of the same @container node. This makes the @opening and @closing capture match multiple nodes each, which causes chaos.

@liljaylj
Copy link
Contributor Author

@HiPhish , can you, please, look at the changes i made in last commit

@HiPhish HiPhish merged commit f37c05f into HiPhish:master Aug 10, 2023
@HiPhish
Copy link
Owner

HiPhish commented Aug 10, 2023

Looks good. Especially the last pattern, I am quite surprised that it actually works.

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

Successfully merging this pull request may close these issues.

2 participants