/nvim

My pure Lua based NeoVim configuration focused on DevOps, Python and Golang

Primary LanguageLuaMIT LicenseMIT

My NeoVim Configuration

This is my first Lua based NeoVim (>0.5) configuration. My goal was to achieve the same functionality as my old vimrc and move onwards to a full Lua based configuration and Lua based plugins especially the promising builtin LSP and Treesitter.

💻 This configuration is working on my Manjaro Linux as well as on my macOS!

Have a look at my rice how my Linux machine is configured and at my mac-setup how my MacBook is configured. The Tmux configuration you can see in the image is here (as well as my other dotfiles).

Motivation

There is a number of great NeoVim configurations online (see Inspiration) that give you a pleasant experience right out of the box. However, I am a long time (Neo)Vim user with a specific workflow and needs. Additionally, I do not have any Lua background and was not willing to spent too much time into that. Therefore, it was quite hard for me to customize and strip down the existing configs to my needs especially because the code is quite sophisticated.

So I decided to move to a fresh Lua based NeoVim on my own trying to accomplish the following principles:

Principles

  1. At least feature parity with my mentioned old vimrc (my lua config is superior almost since day one (or two 😉)).
  2. Migrate to Lua based alternative plugins.
  3. Keep the config as simple as possible knowing that this would possibly impact the code quality.
  4. Modular and meaningful directory structure and file naming.
  5. Just make it work and not make it beautiful 😃. Of course, NeoVim itself must look beautiful but my Focus is not on beautiful code or utilizing all Lua features.

Features

General ⚙️

  • Package management and plugin configuration via Packer
  • Mnemonic keyboard mappings inspired by Spacemacs via which-key.nvim; no more than three keystrokes for each keybinding
  • Minimal yet awesome status line via Lualine
  • Terminal integration via nvim-toggleterm.lua
  • Startup in under 60ms 🚀

Navigation 🧭

Coding 🖥️

Structure

Each plugin to be installed is defined in plugins.lua and each plugin has its own configuration file (if necessary) in lua/config which is loaded by packer.

.
├── ftplugin/         # file specific settings
├── init.lua          # main entry point
├── lua
│   ├── autocmd.lua   # vim autocommands
│   ├── config/       # each plugin configuration is in its own file
│   ├── mappings.lua  # Vim keymaps defintions -> config/which.lua for more
│   ├── options.lua   # non plugin related (vim) options
│   └── plugins.lua   # define plugins to be managed via Packer
├── plugins           # packer_compiled
├── snippets          # snippets for vsnip
└── spell             # my spell files linked from another repo

Useful non leader bindings

Mode key binding
n space  Leader key
v ga Easyalign
v/n gcc Toggle line comment
n ↑ ↓ ⟶ ⟵ Resize panes
i Move out of closing bracket
n <c-h|j|k|l change pane focus (including Tmux panes)

Top level leader key bindings

See ./lua/config/which.lua for details.

key cluster
b Buffer management
c Language specific actions (only in Go, e.g. run tests)
f File management
g Git actions 
h Harpoon integration
l LSP integration
m Misc stuff
s Searching
t Trouble integration
w Window management
x Languagetool integration
y YAML integration (only in YAML files)
z Spell bindings

Remove plugins

Basically, you can remove unwanted plugins by just removing the appropriate line in ./lua/plugins.lua and, if applicable, delete its configuration file in ./lua/config/.

ℹ️ Keep in mind that some plugins are configured to work in conjunction with other plugins. For instance, autopairs is configured in ./lua/config/treesitter.lua. For now there is no logic implemented that cross-checks such dependencies.

Requirements

There are some tools that are required in order to use some features/plugins:

Tools

Autoformatting

Language Servers

For the builtin LSP (see lspconfig for more info about LSP configuration)

  • sudo npm i -g bash-language-server dockerfile-language-server-nodejs yaml-language-server typescript typescript-language-server vscode-langservers-extracted
  • go get golang.org/x/tools/gopls (optional golangci-lint, gomodifytags, gorename)
  • terraform-ls
  • texlab and tectonic
  • lua-language-server
  • For advanced spell checks via vim-grammarous Java 8+ is required

Inspiration