Improve highlighting for Godot shaders#86
Open
YuriSizov wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please check if the PR fulfills these requirements:
What kind of change does this PR introduce?
General improvements to the syntax highlighting for Godot shader files.
Does this PR introduce a breaking change?
No
New feature or change
What is the new behavior?
This changeset aims to provide better markup for highlighting Godot shaders, add some of the missing rules and make some others use more appropriate capture names (according to existing grammars and colors available in GUI themes for Zed. Alongside these changes the test shader file has been expanded to provide reference for many of the covered cases.
Here are some of the key changes:
vec3(1.0)), not as method calls.The
highlights.scmfile has also been slightly restructured.Other information
The tree-sitter that we use for Godot shaders is not so great at this time. There are several problems with it, to name a few:
Preprocessor directives are not parsed consistently.
#define(and its related control flow),#pragma, and#errorare not parsed correctly and cannot be highlighted at all. Paradoxically,#endifis also not available for highlighting, despite other control flow being available (perhaps unintentionally). Understandably, supporting#definemight be pretty hard. Should be possible to compare notes with the C/C++ grammar.Since defines are not parsed at all, it seems that it doesn't know what to do with defined flags and macros in following code either.
Out of 4 possible ways to initialize arrays, only the third one listed in the docs is parsed correctly.
COLORis not identified as a built-in, or special in any way, butSCREEN_TEXTUREis, which is not available in Godot 4. If the tree sitter should support Godot 3 and 4 at the same time, this might be an issue. In the same vein,filter_linear_mipmapis not recognized as a valid hint name; perhaps none of this family of hints are.Using
call_expfor cases likevec3(1.0)might be wrong? It's all internal markup, of course, and it is targettable through queries, but can be confusing.Multiplicating assignement (
blurred *= intensity;) throws an error between two parts of the operator.And perhaps there is more.