Stillat / vscode-antlers-language-server

Provides rich language features for Statamic's Antlers templating language, including code completions, syntax highlighting, and more.
https://antlers.dev
MIT License
38 stars 3 forks source link

Highlighting Question #11

Closed aarondfrancis closed 2 years ago

aarondfrancis commented 3 years ago

Hey 👋

First of all thanks for writing and maintaining this! It's a great resource.

I do have a question about syntax highlighting in one specific code block:

image

This was taken from the Statamic docs. Any ideas why name and style are different?

Thanks!

JohnathonKoster commented 3 years ago

Hi there!

This extension takes two approaches to syntax highlighting:

  1. A general tmLanguage based approach - this is applied first, and is the same across all projects
  2. A more granular parsing-based approach - this is applied on top of the tmLanguage syntax highlighting

With the more granular parsing, this extension will look at your project's blueprints, as well as how the Antlers tags appear in the document, to determine "what kind" of styling to apply to it. In this case it looks like one of the default syntax rules has taken priority for name.

aarondfrancis commented 3 years ago

Thanks for the response! I'm familiar with the tmLanguage approach, but not sure what the second approach is.

This snippet was taken from the Statamic docs and pasted into a scratch file, so there is no project blueprint to inspect, which makes me think it might be a tmLangauge issue? Maybe that name is being picked up as a keyword where it shouldn't be?

Any ideas?

Thanks!

JohnathonKoster commented 3 years ago

Doing a quick inspect, name is being treated differently than style from the tm grammar in this instance:

style_inspect

I will review the grammar file to see what should be done for out-of-box consistency - most likely will demote name so it's picked up by the variable.other rule

The style inspector can be opened by opening the command window and searching Developer: Inspect Editor Tokens and Scopes (https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#scope-inspector)

For the 2nd approach that uses the parser results, VS Code refers to this as Semantic Highlighting (https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide) - and is pretty cool :)

aarondfrancis commented 3 years ago

Thanks for reopening, and for the helpful links. I'll give the semantic highlighting one a read for sure. I'm building https://torchlight.dev, so that seems kinda important 😂

JohnathonKoster commented 3 years ago

Not a problem! I've been experimenting with torchlight.dev - it's pretty awesome, and will be keeping an eye on it!

aarondfrancis commented 3 years ago

Ha! Small world. Lemme know if you ever have any questions or I can help with anything 🤝

JohnathonKoster commented 3 years ago

name has been removed from the statamic-tag-native-variable list in the grammar files to bring consistency here as of 1.0.24.

I will leave this open as I need to set aside some time to go through the entirety of the grammar some more and fine-tune the rules

aarondfrancis commented 3 years ago

Amazing, thank you!

JohnathonKoster commented 2 years ago

@aarondfrancis

Just a courtesy notice that the grammar has changed dramatically, and will be part of a production release of the extension soon

https://github.com/Stillat/vscode-antlers-language-server/blob/feature/parser-rewrite/client/syntaxes/antlers.json

aarondfrancis commented 2 years ago

awesome, thank you for the heads up @JohnathonKoster!

JohnathonKoster commented 2 years ago

Going to close this for now. Feel free to re-open/add comments/add new issues if you have any more questions regarding the highlighting 🙂