I’ve been trying to add a language file to a Fedora 43 setup in order to have syntax highlighting on files when viewing them in GNOME Text Editor. Some of the advice from the GTKSourceView documentation ( GtkSource – 5: Language Definition v2.0 Introduction ) suggests one can do this by placing an appropriate .lang file in a user-specific directory like ~/.local/share/gtksourceview-5/language-specs/ assuming you have the directory parent of gtksourceview-5 listed in either $XDG_DATA_HOME or $XDG_DATA_DIRS.
With this in mind I’ve tried the following:
- Create a folder named
gtksourceview-5in~/.local/share/(i.e.mkdir ~/.local/share/gtksourceview-5/) if there isn’t already one. (NOTE: I have also tried this with the namelibgedit-gtksourceview-300instead too.) - Create a subfolder named
language-specs(i.e.mkdir ~/.local/share/gtksourceview-5/language-specs). - Copy in your
.langfile (in my specific scenario I was trying to play with one called 1. beancount.lang ) - We need a consistent way for the
~/.local/share/folder to be in the environment variable$XDG_DATA_DIRS. Some other posts out there suggest putting in an export line in~/.xsessionrc, but that applies to X11 setups, not Wayland. Some also suggest putting it in~/.profile, but I personally haven’t observed that to work in practice. I’ve found myself creating a link to the user-specific folder via a system-wide (i.e. need sudo) script by creating axdg.shfile in/etc/profile.dbased on the advice here, with the following line in it:
export XDG_DATA_DIRS=$HOME"/.local/share/:"$XDG_DATA_DIRS
(NOTE: I have also tried setting the$XDG_DATA_HOMEenvironment variable withexport XDG_DATA_HOME=$HOME"/.local/share/") - Okay, with the folder created, the lang file installed, and the script to set the environment variable setup, try logging out of your gnome session or rebooting your machine. Then log back in and:
- Check that
$XDG_DATA_DIRSis set by runningecho $XDG_DATA_DIRS. - Try opening up Text Editor in GNOME, clicking the circle-i icon in the upper right, select ‘Document Type’ and see if your desired language appears. This is where I’m having issues - I don’t seem to ever see my custom language file here, despite seeing the directory set in
$XDG_DATA_DIRS, and trying other directory name variations (e.g.libgedit-sourceview-300), etc.
- Check that
Any idea what might be going wrong?