DEV Community

Cover image for The Journey to Neovim
Leo Spratt
Leo Spratt

Posted on • Originally published at enchantedcode.co.uk

The Journey to Neovim

Intro

I started off as a Python developer using PyCharm, this is a fine editor if you only do Python programming, however like most developers; I started to branch out into other languages. Because of this I started to look for more IDEs to use. And so my journey of installing IDEs for every language started.

I realised after a while that filling my computer with many IDEs was not a good idea. Each time I switched to use a different language I had to learn all the shortcuts and buttons again, this slowed down my development quite a lot.

There must be a solution???

The Interim

Enter Visual Studio Code (in beta at the time), the editor that completely changed my development experience. This editor finally allowed me to migrate from using many editors to just one. Unlike all the other editors I used; it finally allowed me to customise it to my liking, whether that was the theme or the keymaps. It allowed me to develop in many languages and get the advanced features expected in a traditional IDE; due to the LSP (an amazing creation).

I have seen overtime the majority of developers are still using language specific IDEs, where they are: slow, consume large amounts of memory and are not easily extendable. I can now safely say that large; language specific IDEs are not necessarily needed for most users. For example Visual Studio is only really required when developing something specific to Windows like building a desktop app using their GUI frameworks. Game programming may also be one of the use-cases where the IDE specific to the engine is required for example Unity. However for the rest of us; we are free to choose from the many available options.

However after a while of being a proud Visual Studio Code user; the limitations of it caught up, the more extensions that were installed made the program feel sluggish; even on fast machines. Also it started to freeze when I typed too fast, most likely all these issues were due to it using Electron; which is known to have certain performance issues.

It was time to change, yet again...

The Last Hope?

I have now almost switched completely to NeoVim (using VsCode just for the debugger, which I rarely use). This editor allows even more customisation compared to VsCode and is much more powerful since I can quickly make my own plugins using lua. Like VsCode it also has inbuilt support for the LSP, allowing for powerful integration with nearly any programming language.

As NeoVim is based on Vim it uses vim motions, which once learnt; can make your code editing fast. Traditional editors which use the mouse to navigate and interact with the editor, slows you down since every-time you switch between the mouse and keyboard; is time not typing, putting your mouse aside and just using your keyboard to manipulate any section of text or move/switch buffers is much more efficient.

This editor by default has a lot already setup in terms of keyboard interaction, however there are a few defaults that I had to change to make it suit me. The first change was to alter the leader key to be bound to the space key, for me this is more ergonomic than the default which is the backslash character. I also changed the key for opening the directory explorer to <leader>pv, which I find easier to press more accurately and faster since both hands can be used to activate it; allowing me to open it rapidly.

To give Neovim IDE features, I have installed several plugins, one of the most important ones is "LSP Zero" which provides suitable defaults and configuration of the LSP and integrates with Mason allowing easy install of LSP servers, linters and formatters. Another plugin I enjoy using is "Harpoon" which allows you to mark files and then navigate to them quickly through keybindings; rather than repeatedly using buffer next/previous. "Telescope" is also another plugin that can allow you to quickly navigate between files, I have multiple keybindings setup so I can use it in it's different modes (file names, git files, file contents). There are many more plugins that I use which I am not going to mention, however you can navigate to my dotfiles repository to view my configurations yourself.

Whilst setting up and getting used to vim motions did take some time, I can finally say that I am satisfied with my editor. It allows me to manipulate text quicker and more accurately than ever before. I have also recently paired it with tmux, a terminal multiplexer; allowing me to quickly switch between terminals and use vim motions.

Some of you may be wondering if I have tried out Emacs (and also Doom Emacs). In fact I actually have. Whilst I found it could be customised maybe more than Neovim, I just cannot get used to it. By default in Emacs most keymaps default to using one side of the keyboard which is not ideal for me. It also uses a subset of Lisp, which I do not like writing in. In NeoVim by default the keymaps make sense and have vim-motions; it can also be customised by using lua, which I find a much nicer language to write small functions in.

Conclusion

I will now leave now with a question, will this be the last editor I use? I guess stay tuned! For others I would urge anyone wanting to improve their text editing experience to try out NeoVim. Or even migrate to use Visual Studio Code, which is still better than most IDEs out there at the moment in my opinion.

Even if you do not want to switch to Neovim for your main code editor, learning vim can be useful if you have servers or maintain them for someone else. I say this because whilst maintaining my own servers having traditional vim installed and the knowledge to use vim-motions has been very useful, since I can now edit config files with the same speed as I would on my desktop.

This post was not endorsed or sponsored by any of the mentioned parties. My views are my own.

Looking for more self-hosted related content or programming help, join the Enchanted People community here:

Links

Top comments (0)