Skip to content

Better gdscript-ts-mode highlighting #165

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

Merged
merged 9 commits into from
Apr 20, 2025

Conversation

TideSofDarK
Copy link
Contributor

@TideSofDarK TideSofDarK commented Apr 10, 2025

  • Support for annotations
  • Support for punctuation
  • More operators
  • Regex-based types and keywords, added missing ones
  • Regex-based constants
  • Moved feature list to defvar so it's possible to modify in user configs
  • Removed variable highlighting for more consistency among different color themes
Before/After Screenshots

Kanagawa
1337
Xcode

@TideSofDarK TideSofDarK marked this pull request as ready for review April 10, 2025 14:35
@TideSofDarK
Copy link
Contributor Author

Regarding escape sequences:
C/C++ goes like (string (string_contents) (escape_sequence) (string_contents))
GDScript goes (string " (escape_sequence) ") and I couldn't make it work properly with higher priority (escape_sequence) making string white (default face).
Let me know if it can be fixed.

@TideSofDarK
Copy link
Contributor Author

image
Do we want different face for "basic" types such as Array, Vector3 etc?
We can use font-lock-builtin-face for that.
But I don't mind all types having the same color and would rather use that face for resource paths, what do you think?

@xiliuya
Copy link
Collaborator

xiliuya commented Apr 20, 2025

Regarding escape sequences: C/C++ goes like (string (string_contents) (escape_sequence) (string_contents)) GDScript goes (string " (escape_sequence) ") and I couldn't make it work properly with higher priority (escape_sequence) making string white (default face). Let me know if it can be fixed.

Use this patch will fix, but operator-face still not work in eask emacs.

diff --git a/gdscript-ts-mode.el b/gdscript-ts-mode.el
index efdb063..5a6e3f1 100644
--- a/gdscript-ts-mode.el
+++ b/gdscript-ts-mode.el
@@ -176,9 +176,11 @@ It must be a function with two arguments: TYPE and NAME.")
    :language 'gdscript
    `(["+" "+="   "-" "-=" "*" "*=" "/" "/=" "^"  "^="  ">"  ">="
       "<" "<="   "|" "|=" "%" "%=" "&" "&=" ">>" ">>=" "<<" "<<="
-      "||" "&&" "==" "!=" "->" "~" "=" ":="] @font-lock-operator-face)
+      "||" "&&" "==" "!=" "->" "~" "=" ":="]
+     @font-lock-operator-face)

    :language 'gdscript
+   :override t
    :feature 'escape-sequence
    '((escape_sequence) @font-lock-escape-face)))

Copy link
Collaborator

@xiliuya xiliuya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Nice work!

@NathanLovato NathanLovato merged commit 1938aa7 into godotengine:master Apr 20, 2025
16 checks passed
@NathanLovato
Copy link
Collaborator

Thank you very much for taking the time to contribute!

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.

3 participants