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

Highlight tagged template fn as fn #920

Merged
merged 2 commits into from
Feb 13, 2024
Merged

Conversation

zth
Copy link
Collaborator

@zth zth commented Feb 13, 2024

This highlights tagged template functions used as a function.

Before:
image

After:
image

@zth zth requested a review from cristianoc February 13, 2024 19:31
@zth zth requested a review from fhammerschmidt February 13, 2024 19:48
@zth zth merged commit 0167930 into master Feb 13, 2024
5 checks passed
@zth zth deleted the tagged-template-highlight-fn branch February 13, 2024 20:13
@DZakh
Copy link
Contributor

DZakh commented Feb 27, 2024

@zth @fhammerschmidt I wonder how correct it is to highlight it as a function, when we usually treat functions as regular variables in other places

image

@zth
Copy link
Collaborator Author

zth commented Feb 27, 2024

Other variables we don't know whether they're functions or not, because we'd need to do potentially expensive lookups. This one we always know is a function because only a function can be used as a tagged template literal function.

@DZakh
Copy link
Contributor

DZakh commented Feb 27, 2024

I'm just thinking that it might be better to be consistent in not highlighting functions

@zth
Copy link
Collaborator Author

zth commented Feb 27, 2024

I don't think that's a problem, this is also a pretty isolated context from other functions so it's fine.

@DZakh
Copy link
Contributor

DZakh commented Feb 27, 2024

Other variables we don't know whether they're functions or not, because we'd need to do potentially expensive lookups.

By the way, do you know how TS does it?

@zth
Copy link
Collaborator Author

zth commented Feb 27, 2024

Other variables we don't know whether they're functions or not, because we'd need to do potentially expensive lookups.

By the way, do you know how TS does it?

They use semantic highlighting, and look up the actual type definition for each identifier to see if it's a function.

We could do the same, but we'd need to benchmark it because it might be taxing on performance. So far we haven't used any of the type information for highlighting (IIRC). But we could probably try it out as an experiment, should be easy enough. Would be good to have benchmarks for it.

@DZakh
Copy link
Contributor

DZakh commented Feb 27, 2024

I see. But I actually like functions of the same color as variables 😁

aspeddro pushed a commit to aspeddro/rescript-vscode that referenced this pull request Mar 4, 2024
* highlight tagged template fn as fn

* changelog
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.

3 participants