132 lines
5.3 KiB
Markdown
132 lines
5.3 KiB
Markdown
---
|
|
title: "My Neovim Setup"
|
|
date: 2023-01-17
|
|
draft: true
|
|
---
|
|
|
|
So I have, for the last six or so months, been really trying to learn to use
|
|
Neovim. I started with Vim, as I imagine many people do, and had a simple
|
|
single file configuration with a couple of plugins and little else interesting
|
|
going on. This original setup was *stolen* from Luke Smith, who really
|
|
introduced me to Vim and why it's so great. However, it didn't take me long to
|
|
learn about Neovim, and quickly I wanted to switch.
|
|
|
|
I think I got lucky regarding when I learnt about Neovim. It was soon after
|
|
they integrated Lua into it and people were starting to really explore plugins
|
|
for Neovim written in Lua. I quickly came across creators like TJ DeVries,
|
|
chris@machine, and ThePrimeagen. By this point it was too late to turn
|
|
back.
|
|
|
|
## A Short Timeline
|
|
|
|
- Initially I was using plain old vim, a pretty much vanilla experience with
|
|
much holding of j, k, and the rest of the bad habits. This was based on Luke
|
|
Smiths setup. My favourite part of this was his autocommand to clear
|
|
whitespace on write.
|
|
- Following this I moved on to nvim and came across chris@machines config for
|
|
nvim. I don't believe he maintains one anymore due to his work on LunarVim. I
|
|
found his config right as he was making the decision to give up maintaining
|
|
it, which turned out to be a blessing as I had to figure out many issues and
|
|
really learned a lot about Lua, Neovim, and their combination. I also learned a
|
|
lot about the different plugins available for nvim.
|
|
- After getting Chris's setup functional I quickly realised that much of it was
|
|
not exactly to my liking, so I took it upon myself to rewrite it. Although I
|
|
did so from scratch, much of it remained very similar, i.e.: the way he had
|
|
his LSP setup.
|
|
- I spent a while working on this new config, tinkering with bits here and
|
|
there. I used/am using it for most of my personal development and my work at
|
|
University. I was generally very happy with it.
|
|
- About 2 weeks ago, from time of writing, I came across folke's post on
|
|
[r/Neovim](https://www.reddit.com/r/Neovim) about his new plugin manager
|
|
[lazy.nvim](https://github.com/folke/lazy.nvim). I had until that point been
|
|
using [packer.nvim](https://github.com/wbthomason/packer.nvim) and before
|
|
that I was using [vim-plug](https://github.com/junegunn/vim-plug), which I
|
|
honestly still love. This is where this story really starts.
|
|
|
|
# [My Config](https://gitlab.inkletblot.com/inkletblot/config/-/tree/main/.config/nvim)
|
|
|
|
Starting two weeks ago I started a full rewrite of my nvim config based around
|
|
[lazy.nvim](https://github.com/folke/lazy.nvim) and the early commits of [LazyVim](https://github.com/LazyVim/LazyVim) which is the *distribution* of nvim
|
|
folke and others are creating around lazy.
|
|
|
|
> I want to be really honest and clear here, Although I wrote all of my config
|
|
> myself, I leant very heavily on LazyVim. I learn by doing more than I learn
|
|
> by reading. I want to be clear that I am not taking credit for other peoples
|
|
> work. Folke is a wizard of a dev.
|
|
|
|
In this post I'm only going to cover setting up lazy.nvim in the manner than I
|
|
have it configured. I will go further into depth about my config in future
|
|
posts. I will omit things like my utility functions, keymaps, and indepth
|
|
descriptions of my list of plugins.
|
|
|
|
## File Structure
|
|
|
|
In the `~/.config/nvim/` folder I have the following items:
|
|
|
|
```
|
|
lua/
|
|
chris/
|
|
...
|
|
lazyvim/
|
|
config/
|
|
icons.lua
|
|
autocommands.lua
|
|
keymaps.lua
|
|
options.lua
|
|
plugins/
|
|
core.lua
|
|
...
|
|
utils/
|
|
init.lua
|
|
...
|
|
init.lua
|
|
init.lua
|
|
lazy-lock.json
|
|
```
|
|
|
|
The `chris` subdirectory contains my old config which I didn't want to simply
|
|
delete before completing my setup with lazy. I won't be going into detail about
|
|
what it contains here.
|
|
|
|
## `init.lua`
|
|
|
|
Following the design of LazyVim my configuration is in its own module so my
|
|
`init.lua` contains only a single line requiring said module. I used to
|
|
configure each plugin separately and require them all from this file.
|
|
|
|
## `lazy-lock.json`
|
|
|
|
This is a file that is automatically generated by lazy.nvim, it allows you to
|
|
specifically version the plugins you have installed, down to specific commits.
|
|
I don't do this. Some people complain about their configurations breaking all
|
|
the time due to plugin updates however I have had this happen only once so the
|
|
effort required to version everything just isn't worth it.
|
|
|
|
## `lua/lazyvim/`
|
|
|
|
This is where the magic happens. It is a self contained module which describes
|
|
and defines my config for Neovim.
|
|
|
|
## `lua/lazyvim/config`
|
|
|
|
The `config` directory contains all of my non-plugin related configuration. I
|
|
will omit `icons.lua`, and `options.lua` because they are fairly personal. If
|
|
you are curious feel free to take a peek at the files
|
|
[here](https://gitlab.inkletblot.com/inkletblot/config/-/blob/main/.config/nvim/lua/lazyvim/config/icons.lua)
|
|
and
|
|
[here](https://gitlab.inkletblot.com/inkletblot/config/-/blob/main/.config/nvim/lua/lazyvim/config/options.lua).
|
|
|
|
## `lua/lazyvim/utils`
|
|
|
|
The utils folder contains some miscellaneous utilities such as a function to
|
|
get a projects root for Language Server Protocols (LSPs) or a workspace
|
|
switcher function for Neorg (a org mode like plugin for nvim). I won't detail
|
|
the specifics here.
|
|
|
|
## `lua/lazyvim/init.lua`
|
|
|
|
|
|
|
|
## `lua/lazyvim/plugins`
|
|
|