godotengine / godotengine/godot-vscode-plugin
Granular TextMate Scope for Function Parameters in GDScript
- Dominant language
- TypeScript
- Stars
- 2.1k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
### Godot version
3.6
### VS Code version
1.121
### Godot Tools VS Code extension version
Latest
### System information
Windows 10
### Problem statement
### Summary
Currently, function parameters in GDScript do not retain a distinct TextMate scope when referenced inside the function body. This makes it impossible for color themes to visually distinguish parameters from regular local variables, limiting the expressiveness of syntax highlighting.
---
### Current Behavior
When inspecting tokens via **Developer: Inspect Editor Tokens and Scopes**, a parameter referenced inside the function body resolves only to:
```
source.gdscript
```
While the same parameter in the function **signature** resolves to:
```
variable.other.gdscript
meta.function.parameters.gdscript
meta.function-call.gdscript
source.gdscript
```
### Expected Behavior
Parameters should carry a dedicated scope such as `variable.parameter.gdscript` both at the declaration site and at every usage site within the function body. This is consistent with how other language grammars handle parameters — for example, Python and TypeScript both expose `variable.parameter` scopes inside function bodies.
### Why This Matters
Without this scope, theme authors have no way to target parameters specifically. The only workaround — targeting `variable.other.gdscript` broadly — incorrectly colorizes all variables, not just parameters, making it unusable.
This is a common request from developers who use custom or third-party color themes and want semantic visual distinction between:
- **Parameters** (passed into the function)
- **Local variables** (declared inside the function)
- **Member variables** (declared at class level)
### Environment
- Extension: `godot-tools` (geequlim.godot-tools)
- Editor: VSCodium / VS Code
- Godot version: 3.x 4.x
- OS: Windows
### Proposed solution
### Suggested Grammar Change
In the GDScript TextMate grammar, parameter tokens inside the function body should be assigned the scope:
```
variable.parameter.gdscript
```
This would allow theme authors to target them precisely:
```json
{
"scope": "variable.parameter.gdscript",
"settings": { "foreground": "#940AFF" }
}
```
Contributor guide
Research direction
Start by locating the GDScript TextMate grammar used by the Godot Tools VS Code extension, then use VS Code's Developer: Inspect Editor Tokens and Scopes on a parameter declaration and reference. The change is done when both sites expose variable.parameter.gdscript without broadly changing local or member variable scopes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- vscode
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100