godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.52k stars 149 forks source link

.gdshader syntax highlight doesn't work #496

Closed Rawalanche closed 2 months ago

Rawalanche commented 11 months ago

Godot version

4.1.1 stable

VS Code version

1.82.2

Godot Tools VS Code extension version

1.3.1

System information

Windows 11

Issue description

I have downloaded godot-tools extension via the VSCode marketplace. I went step by step through the entire official instructions: "Settings Godot If you like this extension, you can set VS Code as your default script editor for Godot by following these steps:

Open the Editor Settings Select Text Editor > External Make sure the Use External Editor box is checked Fill Exec Path with the path to your VS Code executable On macOS, this executable is typically located at: /Applications/Visual Studio Code.app/Contents/MacOS/Electron Fill Exec Flags with {project} --goto {file}:{line}:{col} VS Code You can use the following settings to configure Godot Tools:

editor_path - The absolute path to the Godot editor executable. Under Mac OS, this is the executable inside of Godot.app. gdscript_lsp_server_port - The WebSocket server port of the GDScript language server. check_status - Check the GDScript language server connection status."

image

Everything is in order and works for .gdfiles, such as autocomplete, syntax higlight, etc..., and the Language server is correctly detected and reports as Connected: image

the .gdshader files on the other hand have absolutely no syntax highlight whatsoever, despite the language server also being correctly detected as gdshader and language server reporting as connected: image

I use latest stable Godot version, latest stable VSCode version and latest version of the VSCode extension from the marketplace. I followed the setup process carefully and to the letter.

Steps to reproduce

  1. With latest Godot Stable version, latest VSCode stable version and latest godot-tools extension, open any .gdshader file. Result: The syntax highlight doesn't work Expected: The syntax highlight works
DaelonSuzuka commented 11 months ago

Can you share the actual text of TestMap.gdshader?

None of the setup information you posted is relevant to the gdshader syntax highlighting. It doesn't use the language server and doesn't need Godot, so none of those things should be causing this problem.

Additionally, the syntax highlighting is partially working, because the word "shader_type" is blue. I can only guess that there's something in the shader itself that's confusing the syntax highlighter.

Rawalanche commented 11 months ago

Can you share the actual text of TestMap.gdshader?

Sure: TestMap.zip

If you won't be able to repro it, I can share the whole project if needed. It's just a small test project.

DaelonSuzuka commented 11 months ago

It works for me on extension v1.3.1 and VSCode 1.82.2: image

The #include statement is clearly being handled wrong, but everything else works.

If you don't mind uploading the whole project, I'll take a look at that, although it isn't supposed to matter: the syntax highlighting system is dumb and only looks at the file it's highlighting.

I think there's another VSCode extension on the marketplace that adds highlighting for these file types, is it possible you have that installed too?

Rawalanche commented 11 months ago

image I don't think any of these extensions could possibly interfere.

Here's the link to the project: https://drive.google.com/file/d/1UQOlaG4atMe4aj5WSk4S1Uc0FViMN4rY/view?usp=sharing

But I worry it's not project related, because I don't get syntax highlight even if I open the copy of the file outside of the project :( It must be something with the VSCode setup, but I have no idea what I could possibly do wrong, aside misconfiguring the extension, but it doesn't have many settings that leave any room for error.

DaelonSuzuka commented 11 months ago

There's an almost zero percent chance it's project related because of how the extension works, but something is definitely wrong in your screenshots so I figured it's worth checking anyways.

Rawalanche commented 11 months ago

There's an almost zero percent chance it's project related because of how the extension works, but something is definitely wrong in your screenshots so I figured it's worth checking anyways.

Is there possibly anything that could restrict the function of the syntax highlight to the folder you've put the file into? Such as syntaxes/examples?

Other than that, only other thing I can imagine being a factor are VSCode user settings. I am attaching my vscode user settings.json settings.zip

I tried commenting out the entire contents of settings.json, and even that didn't make gdshader syntax highlight work. I am still puzzled mainly by the fact that .gd file syntax highlight works flawlessly, so there shouldn't be anything wrong with the way I installed and set up the extension.

atirut-w commented 11 months ago

I'm guessing it's one of the extensions that you installed. I think there's a way to test for faulty extensions, but I don't remember how.

Rawalanche commented 11 months ago

I'm guessing it's one of the extensions that you installed. I think there's a way to test for faulty extensions, but I don't remember how.

I've disabled all the extensions except godot-tools. Still no change: image Worth to mention that I am on Win 11, not Linux or Mac.

atirut-w commented 11 months ago

I decided to actually test this myself and turns out, it is a problem with this extension. image

DaelonSuzuka commented 11 months ago

There are no settings that effect the syntax highlighting, and it literally only looks at one file at a time.

Worth to mention that I am on Win 11, not Linux or Mac.

This already really, really shouldn't matter either.

zaha commented 10 months ago

Same issue happens to me, shader_type is the only thing getting syntax highlighted: image

godot-tools 1.3.1 VS Code 1.83.1

DaelonSuzuka commented 10 months ago

@zaha Can you post the code from your example as text?

atirut-w commented 10 months ago

For the impatient:

shader_type canvas_item;

uniform vec3 highlight_color: source_color = vec3(1);
uniform float progress: hint_range(0.0, 1.0, 0.1) = 0;

void fragment() {
    float current_a = texture(TEXTURE, UV).a;
    vec4 target_color = mix(texture(TEXTURE, UV), vec4(highlight_color, current_a), progress);
    COLOR = target_color;
}

This is how it looks in VSCode 1.83.1 with Godot Tools 1.3.1: image

Rawalanche commented 10 months ago

I am starting to suspect that there's actually something unique about the extension developer's setup/development environment that makes it work rather than something unique about some peoples' setups/environment that breaks it.

Was this actually ever tested on any machine/setup other than the workstation of the developer who made it?

zaha commented 10 months ago

Thanks @atirut-w! Didn't get to my PC earlier.

@Rawalanche Ah yes, the classic "works on my machine"-pitfall, we've all been there. It does indeed start to smell like this.

DaelonSuzuka commented 10 months ago

@atirut-w Thanks for typing that up.

@atirut-w and @zaha What OS are you each using?

@zaha Unfortunately, I can't replicate your example either. Here's what I see in VSCode 1.83.1, on Kubuntu this time, with extension v1.3.1 on the left and the upcoming v1.4.0 on the right :

image

atirut-w commented 10 months ago

Can you try with a fresh setup of VSCode or in a Windows VM?

DaelonSuzuka commented 10 months ago

Can you please answer the question I asked you directly? What OS are you using?

atirut-w commented 10 months ago

It's Windows 11, same as everyone else.

DaelonSuzuka commented 10 months ago

Windows 11

Thank you.

same as everyone else.

You can't say "same as everyone else" when only one other person has listed their operating system.

chrisl8 commented 10 months ago

As a bystander I thought I'd test this to see what I see, in case it could help.

The .gdshader does not (fully?) work for me with the published online 1.3.1 version of the extension that is available in the VSCode extensions marketplace sidebar:

image

System information Windows 11, or as Godot reports: Godot v4.2.beta2 - Windows 10.0.22621 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3080 Ti (NVIDIA; 31.0.15.4584) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads) (I'm not sure why Godot says 10.0.22621 when it is 11, but maybe that is really what Windows calls "11" internally. Not sure it matters.)

It does work if I pull the extension from the GIthub repo and build it by hand:

image

It appears to me that this has been fixed in a version of the extension that has not been released yet.

DaelonSuzuka commented 10 months ago

Thanks for the report, @chrisl8. At this point it seems likely this only happens on Win11, but I cannot imagine what's different between 10 and 11 that would cause this.

It appears to me that this has been fixed in a version of the extension that has not been released yet.

Yes, the gdshader grammar was rewritten from scratch after 1.3.1 was published. The conclusion to this thread was always going to be "wait for 1.4.0", but I foolishly wanted to figure out what was actually causing the problem.

zaha commented 10 months ago

@atirut-w and @zaha What OS are you each using?

I'm using Windows 11 Pro 22H2. I can also test it on my Win 10 machine these days if it's working there.

zaha commented 10 months ago

Finally got the chance to get to my Win 10 desktop PC. I've opened the same gdshader file in VSCode (with synced settings) and I'm getting the same issue here.

image

Edition     Windows 10 Pro
Version     22H2
OS build    19045.3570
Experience  Windows Feature Experience Pack 1000.19052.1000.0
dxu commented 9 months ago

I want to add another data point here - I'm seeing the same issue, except I'm running it on an M1 Mac (Ventura).

godot-tools version 1.3.1, and vscode 1.84.2

Rawalanche commented 8 months ago

Quarter of a year later after being reported, and it's still not working. It's quite odd to have code editor extension for a language and not having something as essential as syntax highlighting working.

.gdshaderinc highlight doesn't work at all either, not even scope brackets coloring.

And also, for shader files, there's no error checking so writing the shaders outside of the built in Godot editor is essentially pointless, which is really sad as one can't utilize tools like GitHub Copilot.

micheal-w-wells commented 4 months ago

Works for me: 4.3 godot (built from source) v2 godot-vscode-plugin VSCode version: 1.88.1 M1 Sonoma 14.2.1

DaelonSuzuka commented 2 months ago

Anybody experiencing a similar problem with extension v2.0.0 or greater is welcome to open a new issue, but I'm considering this one resolved because the gdshader textmate grammar was completely rewritten between 1.3.1 and 2.0.0.