CTAGS-LANG-GDSCRIPT(7)

πŸ“¦
version 6.2.1 Β· 6 versions
, in alpine 3.24, fedora 43, fedora 44

πŸ’– ctags-lang-gdscript β€” no cap, the tea on tagging GDScript πŸ’–

okay bestie, so this is a page from the Universal Ctags manual set β€” it's CTAGS-LANG-GDSCRIPT(7), and it's literally just a lil scrapbook of random notes about tagging GDScript source code with Universal Ctags. Not a full spec, not a tutorial, just vibes and field names. πŸ¦‹


✨ SYNOPSIS ✨

Like, the whole point in three lines:

ctags ... --languages=+GDScript ...
ctags ... --language-force=GDScript ...
ctags ... --map-GDScript=+.gd ...

That's it. That's the vibe check. πŸ’…


🌸 DESCRIPTION 🌸

This man page gathers random notes about tagging GDScript source code with Universal Ctags. Random notes!! It's giving "my friend sent me screenshots of the docs instead of a link" energy and honestly? iconic. πŸŽ€


πŸŽ€ STORING ANNOTATIONS πŸŽ€

So listen. The Python parser stores decorations in the decorations field, right? Well the GDScript parser is its own main character and stores annotations β€” the ones starting from @ β€” into a language specific field called annotations. 🫢

And here's the tea: even though the examples below enable the field explicitly, it's enabled by default. So you don't even have to ask. She's already there.

"input.gd"

@export
var s = "Hello"

@master
func f(msg):
        print(msg)

"output.tags" with --options=NONE --sort=no --fields-GDScript=+{annotations} -o - input.gd

s       input.gd        /^var s = "Hello"$/;"   v       annotations:export
f       input.gd        /^func f(msg):$/;"      m       annotations:master

see how the annotations just ✨show up✨ in their own lil column? obsessed.


πŸ”₯ EXTRACTING FUNC πŸ”₯

A language object defined with the func keyword gets tagged with the method kind. periodt. πŸ’…

And just like with annotations, the parser stashes keywords that modify func β€” stuff like static β€” into the annotations field too. she's consistent, we love that.

"input.gd"

func f(x):
        return x

static func f_s(x):
        reutrn x

remote func f_r(x):
        return x
yes bestie the reutrn typo is in the original, we're preserving it exactly, no editing the source material, that's the rule πŸ™ˆ

"output.tags" with --options=NONE --sort=no --fields=+K --fields-GDScript=+{annotations} -o - input.gd

f       input.gd        /^func f(x):$/;"        method
f_s     input.gd        /^static func f_s(x):$/;"       method  annotations:static
f_r     input.gd        /^remote func f_r(x):$/;"       method  annotations:remote

three funcs, three methods, two with annotation receipts. ate. πŸ”₯


πŸ‘‘ TAGGING IMPLICITLY DEFINED CLASSES πŸ‘‘

"A file is a class!" β€” that's the GDScript motto, fr fr. A class is implicitly defined. Functions, variables, constants, and signals are all parts of that class, even though the class is unnamed by default. she's anonymous, she's mysterious, she's everywhere. 🧚

Now β€” if the language specific extra implicitClass is enabled, the parser makes an anonymous tag for the class. And then it fills the scope fields of the tags for all language objects defined in the file with that anonymous tag. chain reaction, gorgeous. πŸ’œ

Let's see an example demonstrating the effect of the extra.

Turning off the extra:

"input.gd"

func f(x):
        return x

"output.tags" with --options=NONE --fields=+KZ --extras-GDScript=-{implicitClass} -o - input.gd

f       input.gd        /^func f(x):$/;"        method

just the one tag, no scope, lowkey minimalist.

Turning on the extra:

"input.gd"

func g(x):
        return x

"output.tags" with --options=NONE --fields=+KZ --extras-GDScript=+{implicitClass} -o - input.gd

anon_class_84011bee0100 input.gd        /^func g(x):$/;"        class
g       input.gd        /^func g(x):$/;"        method  scope:class:anon_class_84011bee0100

boom πŸ’₯ anon class tag materializes, and g gets a scope:class:anon_class_84011bee0100 glow-up. the way that anon tag just appears out of nowhere... main character energy tbh.


πŸ¦‹ TAGGING THE NAME SPECIFIED WITH CLASS_NAME πŸ¦‹

class_name is the keyword for giving a name to that implicitly defined class. she finally gets an identity. 😭

  • If implicitClass is turned off, the parser just extracts the name coming after the keyword with the class kind.
  • If implicitClass is turned on, the parser converts the anonymous tag into a non-anonymous tag with the specified name. And while she's converting, the parser also updates the scope fields of the other tags in the file. teamwork!! 🫢

Turning off the extra:

"input.gd"

class_name c

func f(x):
        return x

"output.tags" with --options=NONE --fields=+KZ --extras-GDScript=-{implicitClass} -o - input.gd

c       input.gd        /^class_name c$/;"      class
f       input.gd        /^func f(x):$/;"        method

Turning on the extra:

"input.gd"

class_name C
func g(x):
        return x

"output.tags" with --options=NONE --fields=+KZ --extras-GDScript=+{implicitClass} -o - input.gd

C       input.gd        /^class_name C$/;"      class
g       input.gd        /^func g(x):$/;"        method  scope:class:C
yes bestie, the second example really does use capital C and the first uses lowercase c, and yes the second example really has no blank line between class_name C and func g(x):. we copy exactly. character for character. that's the whole rule. πŸ’–

🌈 FILLING INHERITS FIELD 🌈

The extends keyword specifies the super class for the implicitly defined class. and if the implicitClass extra is turned on, the parser fills the inherits field of the tag for that implicitly defined class with the name of the super class. she's got lineage now. πŸ‘‘

"input.gd"

extends B
class_name C

"output.tags" with --options=NONE --fields=+Ki --extras-GDScript=+{implicitClass} -o - input.gd

C       input.gd        /^class_name C$/;"      class   inherits:B

and now the plot twist β€” when --extras=+r is given, the parser extracts the class specified with the extends keyword as a reference tag of class kind with the extended role. cross-reference era. πŸ”—

"input.gd"

extends B

"output.tags" with --options=NONE --fields=+rEK --extras=+r -o - input.gd

B       input.gd        /^extends B$/;" class   roles:extended  extras:reference

roles:extended AND extras:reference?? she's doing both. multitasking queen. πŸ’…


⭐ SEE ALSO ⭐


that's the whole page bestie, you're officially fluent in GDScript tagging πŸŽ€βœ¨

this was CTAGS-LANG-GDSCRIPT(7) from the Universal Ctags manual, version 6.2.1 β€” k bye, ily, go tag something πŸ’œπŸŒΈπŸ¦‹

πŸ“¦ where this page comes from