Skip to content

Use font-lock-preprocessor-face for annotations#209

Open
charjr wants to merge 1 commit into
godotengine:masterfrom
charjr:extract-annotations
Open

Use font-lock-preprocessor-face for annotations#209
charjr wants to merge 1 commit into
godotengine:masterfrom
charjr:extract-annotations

Conversation

@charjr

@charjr charjr commented May 24, 2026

Copy link
Copy Markdown
Contributor

Changes

Separates Annotations from keywords so they can use a different face.

before after
Screenshot From 2026-05-23 07-49-15 Screenshot From 2026-05-24 15-30-06

I picked the font-lock-preprocessor-face since GDScript TS Mode uses this already:

:language 'gdscript
:feature 'annotation
'((annotation "@" @font-lock-preprocessor-face
(identifier) @font-lock-preprocessor-face))

Side Note

The highlighting could be simplified to just take any string after an @ symbol, this would be more performant and less maintenance. But since the keywords exist and provide some additional completion, I just used them for now.

Simplified the regex to match Godot editor behaviour: Godot immediately highlights anything starting with @.

@charjr charjr force-pushed the extract-annotations branch from a34ebfc to 127aff4 Compare May 24, 2026 15:34
@charjr

charjr commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Just as further corroboration: The built-in php-ts-mode also uses font-lock-preprocessor-face for PHP's Attributes which are functionally similar to GDScript's Annotations.

   :language 'php
   :feature 'attribute
   '((((attribute (_) @attribute_name) @font-lock-preprocessor-face)

Where an attribute looks like this:

#[Attribute]
function foo ()

@charjr charjr closed this Jun 29, 2026
@charjr charjr force-pushed the extract-annotations branch from 0e08f18 to e4b1cf3 Compare June 29, 2026 17:41
@charjr charjr reopened this Jun 29, 2026
@charjr

charjr commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Did not mean to close it, sorry. I was squashing the commits (as the ones in the middle did not work on their own, so don't really provide a useful history).

@jcs090218 Sorry to be a bother but if you have the time, please may you review this?

If it's too big, I can reduce it to the change in gdscript-syntax.el. This would improve the highlighting.

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