Configuring my RaspberryPi with VSCodium (and NeoVim) for Nim development

Getting setup for Nim development with VSCodium, NeoVim, and a RaspberryPi 4 isn’t hard, but does take a little patience!

up

2021-02-28

Nim

The first thing we want to do is get Nim setup. Nim doesn’t come prepackaged for armhf (the architecture the RaspberryPi 4 uses), so we need to build it ourselves… fortunately, this is a straight forward process, if somewhat time consuming – not nearly as time consuming as it used to be, though!

It’s outlined pretty well on the Nim Website, I’ll just give a recap here:

$ mkdir nim
$ cd nim
$ wget https://nim-lang.org/download/nim-1.4.4.tar.xz
$ tar xvf nim-1.4.4.tar.xz
$ cd nim-1.4.4
$ sh build.sh
$ ./bin/nim c koch
$ ./koch boot -d:release
$ ./koch tools

I’ve also configured my ~/.profile configuration to have the PATH to my nim executable, something like:

PATH="$HOME/nim/nim-1.4.0/bin:$HOME/.nimble/bin:$PATH"

Once everything is built, and you have your PATH configured, you should be able to get some output from the ‘nim’ command and ‘nimble’ command, something like:

$ nim --version
Nim Compiler Version 1.4.4 [Linux: arm]
Compiled at 2021-02-28
Copyright (c) 2006-2020 by Andreas Rumpf

active boot switches: -d:release

and

$ nimble --version
nimble v0.13.1 compiled at 2021-02-28 17:24:16

NeoVim

NeoVim is extremely useful to use with an extension for VSCodium that brings quality vim bindings and support to VSCodium. This may not be useful for everyone, but at this point I have a lot of muscle memory with vim, and have zero desire to change that. I also really enjoy some of what VSCodium provides for a UI, so why not have the best of both worlds?

The NeoVim project does not provide a armhf compatible build, so it will also have to be built, something like:

$ git clone https://github.com/neovim/neovim.git ./neovim
$ cd neovim
$ sudo make CMAKE_BUILD_TYPE=Release
$ sudo make install

VSCodium

VSCodium is a version of VSCode based on the Open Source code that Microsoft publishes, except it is built without the MS telemetry, and the released product is not burdened by a license that is not Open Source.

Fortunately, the VSCodium project already provides an armhf build, which can be downloaded from the projects github releases page.

Once it is installed, then we’ll want to install a couple of extensions:

  1. Neo Vim
  2. Nim (language support)

For Neo Vim you’ll need to configure the path to the nvim binary (which, by default in the source build, would be /usr/local/bin/nvim).

For Nim there’s not much you should need to configure within VSCodium.

Build Tasks

It can be very useful to have a custom task that can run a nimble build of a project. To do so, just create a custom .vscode/tasks.json file in to your project folder, which could look something like:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "nimble build",
            "type": "shell",
            "command": "nimble build",
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": false
            },
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
}

Then you can run nimble build with something like ctrl-shift-B.