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

Different semantic tokens for invalid references #805

Closed
dbanck opened this issue Feb 24, 2022 · 5 comments
Closed

Different semantic tokens for invalid references #805

dbanck opened this issue Feb 24, 2022 · 5 comments
Labels

Comments

@dbanck
Copy link
Member

dbanck commented Feb 24, 2022

After updating the highlighting of constant keywords in hashicorp/syntax#24, semantic tokens should take care of highlighting broken references.

Use-cases

It would be helpful to get feedback when referencing a not-defined variable (or similar item).

CleanShot 2022-02-15 at 17 54 09

Proposal

Instead of highlighting the var keyword differently (see screenshot above), it is proposed to change the highlighting of the reference name. In the example above, non_existing should be highlighted differently.

@Rabattkarte
Copy link
Member

Instead of highlighting the var keyword differently (see screenshot above), it is proposed to change the highlighting of the reference name. In the example above, non_existing should be highlighted differently.

Other plugins (in this case Azure ARM Tools) do it with a squiggly underline like seen in the screenshot:

CleanShot 2022-02-25 at 08 13 58@2x

Some decoration like this screams at a user: "There's a problem!", personally I like this and see this behavior in multiple plugins.

@radeksimko
Copy link
Member

@Rabattkarte Yes, this looks like diagnostics and we plan to do this via diagnostics. I think the question here was whether we could also leverage the semantic highlighting.

In retrospect - maybe it's stretching what semantic highlighting is designed for - at least with the current feature set. I'm assuming that diagnostics are pretty much always supported by the client - as it's quite an essential part of LSP - so maybe we just end up adding that to the list in hashicorp/hcl-lang#57

@jpogran
Copy link
Contributor

jpogran commented Feb 25, 2022

The only method syntax/semantic tokens have to indicate 'invalid' is a red color which, in addition to being problematic for color-blind users, does not give any information for why it's invalid. We won't be able to do squiggly lines or text to say why the thing is incorrect.

This is truly where diagnostic warning and errors shine, so the effort is better spent in hashicorp/hcl-lang#57

@radeksimko
Copy link
Member

I'm going to close this issue as there's nothing we can immediately in terms of semantic highlighting do and it's also unclear whether we should. hashicorp/hcl-lang#57 covers alternative solution involving diagnostics.

On the note of the clarity I opened microsoft/language-server-protocol#1415 upstream

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants