Skip to content

Granular TextMate Scope for Function Parameters in GDScript #1021

Description

@mauriciofelippe

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:

{
  "scope": "variable.parameter.gdscript",
  "settings": { "foreground": "#940AFF" }
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions