GDScript highlight support for Gedit and Gnome-Builder

In another post I already wrote how I met Godotengine, accidentally, while playing around with Haiku. I checked it a bit, but did not play around so much with it as was working on Roiny Froity. Once I “finished” this project it was time to start a new one, and decided to move from Unity to Godot, mostly because I try to do everything with Open Source, and Godot is.

I used Gnome-Builder to create my first GTK app, one that I needed in order to automate and standardize the process of starting a new Game Project, so I thought it could be possible to let Gnome-Builder to be used to code Godot projects. Also Gedit. I searched online and found a GDScript language description at Haimat repo on Github. I checked it, and found some things missing. So, as I have yet not so much idea on how to use GitHub, I’m still a newbie at many things, I started a new language file definition for GDScript, to be used with any text editor that complies with GtkSourceview, not just Gedit or Gnome-Builder.

GDScript highlight on Gnome Builder

You can get the language file and the mimetype file at this repo on Github. Remember that this is a WIP, and still many things are not yet available, so check the repo every 15 days, because I’ll update when I have time to.

To achieve this I started with the python.lang file description, the python3.lang file description, and what Haimat did. Highlighting of GDScript works fine right now, with the available rules. These rules will increase over time to include all GDScript language definition, hopefully.

In order to properly use the files you need to follow these steps:

Creating the MimeType for local user

  • go to ~/.local/share dir
  • inside this folder, create a new folder (if it does not exist) and name it mime
  • inside the newly created ~/.local/share/mime dir create a new folder/dir and name it packages
  • copy the gdscript.xml file from the gdscript_highlight folder inside this new packages folder
  • from a terminal emulator run update-mime-database ~/.local/share/mime

With this, the mimetype gdscript would be already available. A new folder appears inside ~/.local/share/mime named text, and there we have the new x-gdscript.xml file

Adding highlight support for Gedit and Gnome-Builder

To add GDScript highlight support for Gedit, Gnome-Builder and any GtkSourceview compliant app the following needs to be done:

  • go to ~/.local/share folder
  • inside ~/.local/share we need to create two new folders: gtksourceview-3.0 and gtksourceview-4. This is because Gnome-Builder seems to use gtksourceview-4, while Gedit and other text editors use gtksourceview-3.0
  • create a folder named language-specs inside each gtksourceview folder, one inside gtksourceview-3.0 and another language-specs folder inside gtksourceview-4
  • copy the gdscript.lang file from the gdscript-highlight folder to language-specs folder inside gtksourceview-3.0 and to the language-specs folder inside gtksourceview-4
  • open any GDScript file with Gedit or Gnome-Builder, and you can see the GDScript highlight option available, and the GDScript file is highlighted.

Now, in order to properly open a Godot project in Gnome-Builder, we need to set Gnome-Builder as the external editor for Godot. We do that by setting an External Editor in Godot Editor Settings>Text Editor>External and

  • In Exec Path field type gnome-builder
  • In Exec Flags type {project} {file}
Setting Gnome-Builder as external editor for Godot Game projects

With these steps, we are ready to use Gnome-Builder as our default code editor for Godot Projects, with GDScript highlight.