Skip to content

jhockett/sublime-syntaxhl-gdscript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GDScript for Sublime Text

A syntax-highlighting package for GDScript, the scripting language used by the Godot game engine. Targets GDScript 2.0 (Godot 4) while keeping Godot 3 keywords highlighted so older projects still look right.

Works with Sublime Text 4 (Build 4000+).

Features

  • .sublime-syntax v2 grammar covering:
    • # comments and ## documentation comments
    • Single, double, triple, raw (r"..."), StringName (&"...") and NodePath (^"...") string literals
    • Integer, float, hex (0xff), binary (0b1010) and underscore-separated numeric literals
    • All control-flow, declaration, modifier, and operator keywords
    • Annotations (@tool, @export, @onready, @rpc, @warning_ignore, …)
    • Function definitions with parameter types, default values, and return types
    • class / class_name / extends highlighted as class declarations
    • enum, signal, var, const declarations
    • Built-in types (Vector2, Dictionary, PackedByteArray, …) and built-in functions (print, lerp, clamp, …)
    • Node-path sugar: $Node, $Parent/Child, $"Quoted Name", %UniqueName
    • Lambdas (func(...): ...) and match / when guards
  • Comment toggling with Ctrl+/ (#)
  • Python-style auto-indent after :
  • Goto Symbol (Ctrl+R) lists functions, classes, and signals
  • Tab-based indentation by default, matching the official GDScript style guide
  • A handful of snippets: ready, process, physics, input, class, export, onready

Installation

Option 1 — Package Control (recommended once published)

Not yet on Package Control. Use Option 2 for now.

Option 2 — Install the .sublime-package file

  1. Download GDScript.sublime-package.
  2. In Sublime Text, open the menu Preferences → Browse Packages…
  3. Navigate up one level, then into the Installed Packages folder.
  4. Drop GDScript.sublime-package into that folder.
  5. Restart Sublime Text.

Option 3 — Install from source

  1. Preferences → Browse Packages…
  2. Copy the entire GDScript folder (with all the files in this repo) into the Packages directory.
  3. Restart Sublime Text.

Verifying it works

Open any .gd file (or tests/sample.gd in this package) and confirm the bottom-right of the Sublime status bar shows GDScript. If it shows something else, switch with View → Syntax → GDScript.

Customisation

To override per-syntax settings, open a .gd file and choose Preferences → Settings — Syntax Specific. The defaults can be found in GDScript.sublime-settings.

Colour mapping uses standard TextMate scopes (keyword.control, support.type, entity.name.function, variable.annotation, etc.), so every Sublime colour scheme will produce reasonable output. The annotation scope (variable.annotation) is also used by some Python packages, so @export will pick up whatever your theme uses for decorators.

Package contents

GDScript/
├── GDScript.sublime-syntax        # the grammar
├── GDScript.sublime-settings      # default editor settings for .gd files
├── Comments.tmPreferences         # Ctrl+/ uses '#'
├── Indentation Rules.tmPreferences
├── Symbol List - Function.tmPreferences
├── Symbol List - Class.tmPreferences
├── Symbol List - Signal.tmPreferences
├── snippets/
│   ├── ready.sublime-snippet
│   ├── process.sublime-snippet
│   ├── physics_process.sublime-snippet
│   ├── input.sublime-snippet
│   ├── class.sublime-snippet
│   ├── export.sublime-snippet
│   └── onready.sublime-snippet
├── tests/
│   └── sample.gd
└── README.md

About

Syntax highlighting package for Godot Script in Sublime Text

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors