Migrating Neovim config to Lua

Posted on 2022-08-21

In the last few days, I decided to migrate my Neovim configuration to Lua, mainly inspired by the following post:

Rust and Neovim - A Thorough Guide and Walkthrough

The migration

The migration was really easy, the main part was just figuring out what Lua-functions to call instead of the vimscript-things. Here is a short overview:

local o = vim.o
local g = vim.g
local map = vim.api.nvim_set_keymap

vim.o.expandtab = true -- set expandtab
vim.g.mapleader = " " -- let g:mapleader = ' ' 
map('n', '<leader>zf', ":lua require('telekasten').find_notes()<CR>", { noremap = true, silent = false }) -- nnoremap <leader>zf :lua require('telekasten').find_notes()<CR> 

While I was at it, I also split up my config into many smaller files, imported into `init.lua` for example via `require('plugins')`. Lua is definitely a great improvement compared to the vimscript way I was doing before. It is also great in that regard that many new neovim plugins this day (e.g. integration with LSP) only show a way to configure it with Lua, which would have required wrapping the configuration in `lua` in the traditional way.

Plugins

I also invested my time (read: got distracted by) searching for some new plugins that might be useful. Here is a short overview of all the new plugins I found:

I also removed some plugins:

Worth it?

Is it worth migrating the config? I would definitely say so. Lua is easier to handle than the old vimscript-way. Furthermore, the migration is really not hard, it maybe takes an hour to migrate (except if you decide to go deeper and find new plugins, new configs, ...). And if you would excuse me now, I have some more programs to rice.

Return to home