---
title: "Build A Neovim Qt AppImage from Source"
blurb: "Building an AppImage package from source allows us to run the
latest version of Neovim-QT on our machine running the Debian Linux
distribution."
...

![Neovim Qt](/images/neovim-qt-sample.png)

## Introduction

We have [Debian](https://www.debian.org/) installed on our machine and would like to run [Neovim](https://neovim.io/) with the latest version of the [Neovim Qt](https://github.com/equalsraf/neovim-qt) GUI. While a Debian `neovim-qt` package exists, it is not the latest version. To solve this problem, we will build Neovim Qt from source and package it as an AppImage.

### Requirements

We will assume Neovim is already installed. Neovim AppImages are available from the [Neovim GitHub repo](https://github.com/neovim/neovim/releases).

## 1. Install [Toolbox](https://containertoolbx.org/)

We will have to install all the Neovim Qt build dependencies, so we will use Toolbox to build in a container, keeping our system clean.

    $ sudo apt-get update
    $ sudo apt-get install podman-toolbox

## 2. Download Neovim Qt

We start by downloading the latest `*.tar.gz` source code asset from the [Neovim Qt GitHub repository](https://github.com/equalsraf/neovim-qt/releases/).

Then, we unpack and unzip it and `cd` into the directory.

    $ tar -xzvf neovim-qt-0.2.18.tar.gz
    $ cd neovim-qt-0.2.18

## 3. Create and enter a new Toolbox container

    $ toolbox create --distro debian neovim-qt
    $ toolbox enter neovim-qt

## 4. Add `deb-src` to the sources list

Toolbox's base Debian image only lists binary archive types in the sources list. We will have to add the archive type for source packages, as well.

    $ sudo nano /etc/apt/sources.list.d/debian.sources

We change the two lines that read `Types: deb` to `Types: deb deb-src` and save the changes.

    Types: deb deb-src
    ...

    Types: deb deb-src
    ...

## 5. Install build dependencies

We can install all the build dependencies we will need to build Neovim Qt with the `build-dep` option. `fuse` will be needed to build the AppImage package.

    $ sudo apt-get update
    $ sudo apt-get build-dep neovim-qt
    $ sudo apt-get install fuse

## 6. Add a build script

We copy a sample `cmake` build-script from the [appimage.org online documentation](https://docs.appimage.org/packaging-guide/from-source/native-binaries.html#bundle-qtquickapp-with-cmake) into a file called `build-with-cmake.sh`.

Alternatively, we can download it directly from their GitHub repository with

    $ wget https://raw.githubusercontent.com/linuxdeploy/QtQuickApp/master/travis/build-with-cmake.sh

We need to make two changes.

1. On the line that contains

        cmake "$REPO_ROOT" -DCMAKE_INSTALL_PREFIX=/usr

    we add the variable `DCMAKE_BUILD_TYPE` and set it to `Release` (per the [Neovim Qt build instructions](https://github.com/equalsraf/neovim-qt/wiki/Build-Instructions)):

        cmake "$REPO_ROOT" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release

2. On the very last line,

        mv QtQuickApp*.AppImage "$OLD_CWD"

    we remove the sample app name, `QtQuickApp`.

        mv *.AppImage "$OLD_CWD"

    (We could, optionally, set it to `mv Neovim-Qt*.AppImage "$OLD_CWD"`, but for our case, it's not necessary).

## 7. Run the build script

We make the script runnable and then run it.

    $ chmod +x build-with-cmake.sh
    $ ./build-with-cmake.sh

## 8. Test-run the AppImage

We should now have an AppImage package in our directory that we can run.

    $ ./Neovim-Qt-x86_64.AppImage

When we run it we should see Neovim open in a new GUI window.

![Neovim Qt Running In a Window](/images/neovim-qt-test-run.png)

## 9. Exit the Toolbox container

    $ exit
    logout

The Toolbox container is still running. We can stop it with

    $ podman stop neovim-qt

## 10. Add the package to our user-specific executable directory

According to the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), user-specific executables belong in `$HOME/.local/bin`. We will place our AppImage in its own directory in `~/.local/neovim-qt` and create a symlink to it in `~/.local/bin`.

    $ mkdir ~/.local/neovim-qt
    $ mv ./Neovim-Qt-x86_64.AppImage ~/.local/neovim-qt
    $ ln -s ~/.local/neovim-qt/Neovim-Qt-x86_64.AppImage ~/.local/bin/nvim-qt

We can now run it by calling `nvim-qt` directly from the command line.

    $ nvim-qt --version
    NVIM-QT v0.2.18.0
    Build type: Release
    Compilation: -Wall -Wextra -Wno-unused-parameter -Wunused-variable
    Qt Version: 5.15.8
    ...

## 11. Add Neovim Qt to the applications menu

We simply need to copy the `.desktop` file from the source directory.

    $ cp src/gui/nvim-qt.desktop ~/.local/share/applications/

## 12. Add an icon

And finally, we copy over the icon from the source directory as well.

    $ mkdir ~/.local/neovim-qt/icons
    $ cp third-party/neovim.png ~/.local/neovim-qt/icons/nvim-qt.png
    $ mkdir -p ~/.local/share/icons/hicolor/192x192/apps
    $ ln -s ~/.local/neovim-qt/icons/nvim-qt.png ~/.local/share/icons/hicolor/192x192/apps/
    $ xdg-icon-resource forceupdate --mode user

## Conclusion

When we search for `neovim` in our applications menu, we should now see an entry we can use to start our new Neovim Qt AppImage.

![Neovim Qt Application Menu Entry](/images/neovim-qt.png)
