Hero Image

Nim

Beginners guide to a non-sucky NIM experience with vs-code

I have been programming in PERL for quite a while, and decided to learn a memory-safe, type safe program that compiles things. NIM was my choice. This guide DOES NOT tell you how to program, but rather how to setup your editor (in this case vscode oss), to not suck. There were no comprehensive guides to help me with this, so I decided to write a doc.

Basic install of the 'right' Nim plug-in

There are two vscode plugins, one is 'old' an never updated, and the other is new and updated. Its called 'nimsaem'. Search for 'nim' in the vscode marketplace (or oss marketplace). Nim by ''nimsaem". Once this is installed you need to do some basics for your first project.

Using asdf to manage your NIM binary

I am not going to spend a whole lot of time on this, but its fairly important to have a 'recent' version of NIM. For linux and osx, I use asdf. Install NIM per normal:

#!/usr/bin/env fish
asdf plugin-add nim
asdf install nim <choose your version>
asdf global nim <your proper version of nim>

Once this is done, you can proceed to the next phase

On "why is code completion not working"

I had this problem because no one bothered telling me you should do the following PRIOR to editing your file (you need a proper NIM project file).

cd ~/src
mkdir nimproject
cd nimproject
nimble init
(follow prompts, I usually choose 'binary')

This magically got code completion to work. For some reason this makes things 'just work'.

On having non sucky font

The default fonts that come with vscode really aren't that nice. I like using

jetbrainsMono Nerd Font

(the name is REALLY important). To change the default font in vscode, search for 'font' I use the following values if I have it installed, type in ctrl comma (or cmd comma mac), and type in the following after searching for font:

'jetbrainsMono Nerd Font', 'monospace', monospace

On having proper indenting of 2 (4 is evil)

To have indention of '2' rather than 4 (which I think wastes space, additionally it makes the python people go mental, which is an added bonus!).

Go into the main configuration screen ctrl , and then look for 'detect indent' turn it off. It seems to NEVER do what I want it to, so I just set a global of 2'. Secondly, you will need to look for 'editor: tab size' set that to 2 as well.

ON having a pretty easy way to tell levels

Install the 'rainbow' indent plug-in. This makes things look REALLY nice.

Some good starting NIM books and links

When I first started with NIM I had some problems in finding an easy book. While the NIM IN ACTION book is quite good, its for REALLY advanced users. I found a nice book called computer programming with nim. This is a VERY good book. I have also created an epub version GentleNim.epub. Alas the download will use a .zip extension. Just rename it .epub and all will go well. This is the nicest one. There are also some very nice youtube videos which can take you through the whole process as well. Here are some other links for resources about nim:

I will be adding additional resources as I find them.