info-window.nvim: replacing statusline plugins with floating window

For the past couple of years, neovim has been my text editor of choice. And over those years my init.vim has been through hundreds of iterations. I’ve played with hundreds of plugins and over time I find myself less and less reliant on them. And these days, I even find myself writing my own plugins.

Vim plugins are great and a couple of them such as fzf and nnn.vim became indispensable for my day to day editing. Meanwhile I find other plugins not worth the extra load time at all.

Eventually, one such plugin I want to get rid off is vim-airline. It transforms the statusline into a good-looking one and display an array of useful information about pretty much whatever you want. But it is also quite heavy. I can give up good-looking statusline for faster load time but I find showing information about the current buffer at a glance pretty useful most of time. And so the idea for info-window.nvim came up.

Basically info-window.nvim is a small plugin where you can use neovim’s floating window feature to display whatever information you want in a none distracting way. At its default behavior, it displays some basic information about the current buffer.

Extending the basic information is possible by passing a closure function to the helper functions infowindow#create and infowindow#toggle.

An example where I add the current git branch of the buffer and current position of the cursor.

command! InfoWindowToggle call infowindow#toggle({},
                \   { default_lines ->
                \     extend(default_lines, [
                \       ['branch', fugitive#head()], 
                \       ['cursor', getcurpos()[1] . ', ' . getcurpos()[2]], 
                \     ])
                \   }
                \ )

As you can probably tell, the window is brought up on-demand instead of always being shown. In my opinion, this makes it less distracting than a colorful statusline.

A bonus effect after removing vim-airline is that I notice a drop in neovim start up time from 120ms to 80ms. If you ask me, that’s quite a noticeable speed up.

And that’s it, I hope you find the plugin useful. At the moment, it only support neovim but hopefully I’ll find the time to extend the support to vim and add some more features.