Neovim configuration
Introduction
- I was facinated by vim from the time I was introduced to it by one of my professors in my university during my first year of bachelors.
- From not being able to quit vim during my first time resulting in me closing the terminal directly to becoming good at vim keybinds, it was quite a journey for me where I learnt a lot about how text editors generally work.
- Getting used to vim keybinds took me around one month of time and by the time I got good at it, I became intrested in creating my own workflow using custom vim script and vim keybinds and wrote my first vim configuration using the .vimrc in vimscript.
- I made sure my entire configuration is stuffed in just a single file so that I have the flexibility to curl or wget it anywhere.
- A while after that, I found out neovim which was gaining more attraction since it was multi-threaded unlike my current editor which was single threaded.
- Neovim also supported lua for configuring itself altough I was a bit hesitant to learn a new language again after going through the pain of learning vim script which I felt was cryptic than your regular languages at that time and hence migrated my .vimrc to init.vim and did not use lua to configure it.
- Till then, I was using a basic LSP based auto completion setup with ALE and later switched to vim-lsp .
- Once I secured my first job via campus placements and started working at an enterprise level, I quickly realised that my current auto completion setup was very slow since it was in vim script and the plugins which I was using were also in it.
- Additionally I also needed debuggers to debug stuff unlike before when I used to make do with print statements. Altough there was a plugin for it like Vimspector , I felt like dabbling anymore with vim script is not going to meet my needs.
- Hence, I made the decision to learn lua and wrote my first configuration using it with LSP and DAP integration.
- Since then, I became fairly decent at lua and wrote a basic configuration using the around 80+ plugins for supporting LSP and DAP and especially Java which was a pain to setup initially.
- Now came the problem of performance . On one hand I had 80+ plugins making my editor start with a delay of around one second since I did not do lazy loading as I wrote my initial configuration using the plugin manager Paq for simplicity and it did not support lazy loading. On the other hand I had to deal with java files whose source code was more than 50000+ lines and the file sizes crossed 2MB making treesitter and plugins which depend on it very slow. Also most utility plugins I use were full of bloat which I never used.
- Then comes mini.nvim to save me from all this trouble. It provided many utilities which were not bloated and were pretty good at doing just the single thing they were meant to do.
- I slowly replaced many of my utility plugins with alternatives of it provided my mini.nvim . One of my biggest migrations was to integrate the plugin manager provided by it and lazy load configuration when possible reducing the editor's startup time.
- Finally I fixed all issues related to my configuration being performant on very big files . I did this by opening sqlite.c file from the sqlite3 source code which was a amalgamated file with 200000+ lines of code and the size of the file was 8MB+. Most of the issues I faced came from treesitter and completion plugins.
- After all these iterations of changing my editor's configuration, I ended up with around 50+ plugins most of which are from mini.nvim . The startup time of my configuration is less than 150ms and it works on files as big as 8MB without any delays thus achieving the ideal state which I always dreamt of.
- Since I have achieved my ideal state, I promised myself not to touch my editor's configuration unless necessary . You can look at my github configuration commits to verify this claim.
Acknowledgement
I am really greatful to all neovim contributors, maintainers and plugin authors who do such a great job of patching neovim, developing features in it and creating such high quality plugins.