8000 Update GDScript for Godot 4.x by Cykyrios · Pull Request #3935 · PrismJS/prism · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update GDScript for Godot 4.x #3935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Cykyrios
Copy link
@Cykyrios Cykyrios commented May 14, 2025

I don't know if you're still accepting language PRs for v1, but I needed up-to-date GDSCript syntax highlighting, so I made the changes so it is compatible with Godot 4.x (this also removes some Godot 3.x-specific keywords).

Apart from the string and operators regex which I mostly reused as is, I overhauled the entire lexer taking inspiration from Godot's own pygments implementation for its official documentation. The following GDScript features are now available:

  • Builtin types, builtin objects (all 1003 of them at the time of writing), builtin functions.
  • Specific colors for control-flow keywords vs standard keywords, function definition vs function call, documentation vs standard comments.
  • Annotations (@export and the like).
  • NOTE, TODO, DANGER and other notes in comments and doc comments.
  • nodepaths, string names, placeholders in strings (Godot itself doesn't color them, this is a bonus feature).
  • $ and % shorthands for nodepaths are highlighted as variable tokens.
  • Binary and hexadecimal numbers are their own tokens, in case some themes want to color them differently.
  • INF, NAN, PI and TAU are builtin-number tokens aliased as keyword, null is included in builtin-pseudo along with true and false, which are aliased as boolean.
  • Signals are highlighted properly when declared.
  • Properties/class members are also highlighted.

From my testing, the only thing that does not highlight the way Godot does is class names, where Prism is not able to know they are classes, the rest should work fine.

For reference, here are comparison screenshots with the code in the example html file, in both Godot (using passivestar's theme with the CommitMonoNerd font (bold)) and an appropriately-themed Docusaurus page.

image
image

Edit: Closes #3752.

Copy link
netlify bot commented May 14, 2025

Deploy Preview for dev-prismjs-com ready!

Name Link
🔨 Latest commit ebd5561
🔍 Latest deploy log https://app.netlify.com/sites/dev-prismjs-com/deploys/6824a702daf17b000818c4ff
😎 Deploy Preview https://deploy-preview-3935--dev-prismjs-com.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

No JS Changes

Generated by 🚫 dangerJS against ebd5561

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0