Using Geany for C++ and GTK programming

Previously I had been using VS Code for my programming. That all changed when I came to Manjaro. When I copied the files from my VS Code install from Pop!-OS to Manjaro, they broke. VS Code couldn’t find my compiler, it couldn’t do code completion, and it generally only worked as a text editor.

VS Code is very difficult to set up under Linux in the first place. It needs a copy of all the include files as well compiler and linker options. Entering all these files into VS Code can be quite tedious. And worse, if you enter something wrong, things begin not working correctly. Programming under Linux is different, however. It has tools that take care of most of these annoyances for you. All you have to do is use the tools that are designed for Linux programming.

With that in mind, I still spent a little while trying to track down the errors that were preventing it from finding my compiler then decided it might serve me better to see what other options I have at my disposal.

I am very glad that I did. I found something that works better than VS Code, is lighter, faster, more configurable, works seamlessly with the tools that I already use, and has easy access to code completion as well as all the other perks that I like to have in a light weight IDE.

Installing Geany

To install Geany on Manjaro, all you have to do is search for Geany using the pamac package manager. With one click and your password it will be installed and ready to use. It will already be set to use make and makefiles. It had no problems finding my compiler, and the syntax highlighting worked flawlessly right out of the box.

But there is one more thing that I added to Geany to make it superior to VS Code in every way. I added code completion. And while VS Code does code completion with enough work, it is simple to set up with Geany.

Code Completion in Geany – autocomplete

Geany uses specially created “tags” files for its autocomplete. While you can make these files yourself, you can also download tags files created by others that you can add to Geany so that it can autocomplete your language of choice as well as other things like GTK, Qt, and gtkmm. Simply choose the files corresponding to the language/libraries that you want Geany to autocomplete – or download them all – and add them to Geany’s configuration.

There is a collection of files on Geany’s Wikipedia page for tags files that are available for anyone interested. While I might download more in the future, I have selected one for the standard C++ headers, one for the standard template library, and one for GTK C++ interface which is what you need to work with gtkmm.

Once you have downloaded the files you want, you need to copy them into Geany’s configuration folder.

Geany has two different locations where it stores configuration data. The first place is global data. The second place is where you want to put copy the tags files to.

You can check where Geany’s configuration locations are by starting Geany, selecting Help then Debug Messages. In the messages you should see something like this:

Geany INFO : System data dir: /usr/share/geany
Geany INFO : User config dir: /home/(username)/.config/geany

If your version of Geany uses the same locations as mine does, then you can open a terminal in your home directory and type the following commands:

cd ./config/geany/tags/

That is the directory you want to copy the tags files into.

Assuming you downloaded the tags files into the Downloads directory, you could type the following commands into the terminal to get the files into the proper directory.

cd ~/Downloads/
cp *tags ~/.config/geany/tags/

Once this is done, start Geany and it should have code completion working.