Getting Started (Neovim)

Setting up Lua !

So what is Lua and why should you care?

It's a scripting language that has a runtime built-in to Neovim. With that, the floodgates have opened up and we've seen an explosion of plugins. It's been a game-changer for the Vim community.

So how do we set it up? By default, Neovim will look in various paths for a configuration file...specifically, init.lua. We will set one up now with some simple things and expand on it during the series.

First, we'll start by creating the file ~/.config/nvim/init.lua

nvim ~/.config/nvim/init.lua

Now you'll want to immediately write this file with :w.

And it is written!

Let's start off with some basics. We're going to set some vim configurations.

These are fairly straightforward to configure how we use spaces, how many spaces when we hit tab etc.

These are just preferences, so feel free to tweak these.

set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2

Now we can save this file again with :w. Once we do that, you can source this file by using the command :source %

Now if you've followed my instructions up to this point, you'll see an ERROR!

Why did we get this error? Because the above is vimscript. This is a lua file! We still need to setup vim configurations though — how do we do that?

We use meta-accessors!

We're able to wrap API functions and manipulate options as if they were variables. So for us, our preferences should actually look like this.

NOTE: we're also setting our leader key to be space !

vim.cmd("set expandtab")
vim.cmd("set tabstop=2")
vim.cmd("set softtabstop=2")
vim.cmd("set shiftwidth=2")
vim.g.mapleader= " "

Initial Lua File