Skip to content

Conversation

@zacccharv
Copy link

@zacccharv zacccharv commented Apr 1, 2025

1. Added export_tool_button Annotation Support

I've added the export_tool_button keyword to the annotation term match list in the grammar file. That way the syntax highlighter properly recognizes and styles this annotation in VScode.

"annotations": {
	"match": "(@)(export|export_group|export_color_no_alpha|export_custom|export_dir|export_enum|export_exp_easing|export_tool_button|export_file|export_flags|export_flags_2d_navigation|export_flags_2d_physics|export_flags_2d_render|export_flags_3d_navigation|export_flags_3d_physics|export_flags_3d_render|export_global_dir|export_global_file|export_multiline|export_node_path|export_placeholder|export_range|export_storage|icon|onready|rpc|tool|warning_ignore|static_unload)\\b",
	"captures": {
		"1": { "name": "entity.name.function.decorator.gdscript" },
		"2": { "name": "entity.name.function.decorator.gdscript" }
	}
},

2. Added Variable Declaration Name Grammar Support

I've implemented grammar support for variable field name declarations with this pattern:
Also wanted to add grammar support for variable field name declarations like this:

"variable_declaration_name": {
	"name": "meta.variable.declaration.name.gdscript",
	"begin": "(?<=\\b(var|const)\\s+)",
	"end": "(?!\\s*:=)(?!\\w*)|([A-Za-z_]\\w*)",
	"patterns": [
		{ "include": "#any_variable" }
	]
},

This would:

  1. Start capturing text right after seeing "var " or "const "
  2. Capture the variable name or "#any_variable" (which must follow GDScript naming rules)
  3. Stop capturing when it reaches something that's not part of the variable name or when it completes capturing a valid identifier

@zacccharv zacccharv marked this pull request as draft April 1, 2025 16:44
@zacccharv zacccharv marked this pull request as ready for review April 1, 2025 17:44
@DaelonSuzuka
Copy link
Collaborator

What's the point of the second change? I'm pretty sure variable declarations are already covered.

@zacccharv
Copy link
Author

zacccharv commented Apr 1, 2025

What's the point of the second change? I'm pretty sure variable declarations are already covered.

Variable declaration is supported but the entire declaration is in scope, so for example this entire line is the variable declaration:

var my_variable: String = "test string"

What I wanted was a textmate scope just for the variable field name so just my_variable when it's first declared

@DaelonSuzuka
Copy link
Collaborator

Yes, the variable name is already being tagged as variable.other.gdscript.

Code_pZn7uwtScO

@zacccharv
Copy link
Author

@DaelonSuzuka in that example it works however every time any variable comes up in the meta.variable.declaration.gdscript wether declared beforee or not it's labaled as variable.other.gdscript

Screen.Recording.2025-04-01.174718.mp4

@zacccharv
Copy link
Author

Here's the difference with my added scope.

Screen.Recording.2025-04-01.175750.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants