Moving from Jetbrains Suite to Neovim: Setting Up Neovim

Table of Contents

Introduction

I have always found the idea of being able to code and work on your projects in the terminal to be a really appealing concept, but I often felt intimidated by it for various reasons, such as the learning curve of using the terminal editor or the time and effort needed for the setup.

It wasn’t until recently that I decided to dive headfirst into it and use a command-line editor as my main development environment instead of the Jetbrains product that I have been using so far. After researching the various tools available, I finally decided to settle on Neovim.

What Is Neovim?

Neovim is a fork of the well-known Vim tool that most people are familiar with. Neovim enables configuration to be done using Lua. Additionally, by providing an enhanced API in comparison to Vim, Neovim has cultivated a dedicated community of developers that create various plugins to enhance the functionality of the tool.

Benefits

The Fun Factor

For me personally, one of the main points of motivation for adopting this tool has been the fun factor. Learning a new tool, configuring it, and customizing it are all very fun for someone who is passionate about tech and programming.

This fun is multiplied when it comes to learning the various shortcuts and macros that can be done using Neovim, which enables the user to abandon the usage of the mouse when coding.

Customizability

Neovim enables every aspect of the editor to be customized, both in terms of the mappings that can be set up in addition to the various plugins that can be added to provide various functionalities.

Enhanced Remote Development Experience

Since Neovim is a command-line tool, this makes it one of the ideal editors to be used when using remote machines for development. You will be able to easily set up the environment on any terminal and work like you would on your own machine.

Subjective Benefit: Enhanced Productivity

While this by itself is a debatable subject, it is perhaps possible to feel your productivity being enhanced by using Neovim. This can be possible due to the shortcuts that exist in the editor and the various customizations that make it the perfect fit for your development needs.

Component Overview

Before we delve into setting up the editor and all the various shortcuts and configurations, I feel that it is necessary that we go over a few basic components that come together to improve the development experience using Neovim.

Plugins

First of these components are the Plugins. Plugins for Neovim are often written in Lua and can be managed using a plugin manager.

Language Servers

What is often abstracted away from us when using an IDE or a text editor are the language servers that are used in order to provide various features such as language-specific auto-completion, go to definition, find all references, etc.

In Neovim, you make use of a plugin that uses a Language Server Protocol, or LSP, to provide the functionalities that these servers have.

Debug Adapters

A debug adapter is the layer that sits between a debugging runtime and the editor. The editor makes use of the Debug Adapter Protocol, DAP, to provide the functionalities of a debugger to us.

Snippets

A Snippet is a reusable piece of code or text that you can insert into your editor with a short trigger. Snippets are designed to increase your coding speed and reduce repetitive typing by allowing you to define templates for common code structures, boilerplate, or frequently used phrases.

Assembling Your Editor

Oh My Zsh

The first tool that needs to be installed is Oh My Zsh. This tool allows us to easily manage and configure our Zsh setup.

Installation

The installation can be done by following this guide on the Oh My Zsh website:

powerlevel10k

Next is Powerlevel10k, this theme for Zsh displays various information using a bar in the terminal.

Installation

The Installation details can be found here:

Neovim

Next, we need to install our editor, Neovim. We will then set up the various plugins and configurations afterwards.

Installation

The installation details for Neovim can be found here:

Plugin Manager

In order to easily install, configure, and manage various plugins that we will be installing for Neovim, it is best to make use of a plugin manager.

I personally installed lazy.nvim, but there are plenty of options to choose from.

Installation

You can find the installation guide here on the official Lazy.nvim website:

File Structure

It is recommended to make use of the “Structured Setup” shown in the guide and have a separate folder and Lua files for each plugin or functionality that is provided by a group of plugins.

Below is an example of a Lua plugin file:

return {
	"nvim-treesitter/nvim-treesitter",
	build = ":TSUpdate",
	config = function()
		local configs = require("nvim-treesitter.configs")

		configs.setup({
			ensure_installed = {
				"c",
				"lua",
				"vim",
				"vimdoc",
				"query",
				"elixir",
				"heex",
				"javascript",
				"html",
				"java",
				"css",
				"python",
			},
			sync_install = false,
			highlight = { enable = true },
			indent = { enable = true },
		})
	end,
}

Plugins

neo-tree.nvim

Neo-tree gives Neovim a file explorer view that can be used to navigate the various files in the system within Neovim itself.

Installation

The installation guide can be found here:

telescope.nvim

Telescope can be thought of as a tool that will help you easily search for files and text in your project.

Installation

The installation guide can be found here:

telescope-ui-select.nvim

This plugin maps the various UI select functionalities of Neovim to the Telescope UI.

Installation

The installation guide can be found here:

catppuccin

Unfortunately, the usual theme that I use for my editors and tools was not available for Neovim, so this led me to have to completely re-evaluate the theme that I used across all my tools, and that’s where I landed on Catppuccin.

While similar to the old theme, I am already enjoying it much more.

Installation

The installation guide can be found here:

lualine.nvim

Lualine is a plugin that adds a bar similar to that of powerlevel10k in the Neovim environment, which gives the editor a much more appealing look.

Installation

The installation guide can be found here:

nvim-treesitter

nvim-treesitter is a plugin that gives us enhanced highlighting in our code and allows us to better navigate our codebase.

Installation

The installation guide can be found here:

mason.nvim

Mason can be thought of as a package manager for various components of Neovim, such as LSPs, Linters, Formatters, etc.

Installation

The installation guide can be found here:

nvim-lspconfig

nvim-lspconfig is a Neovim plugin focused on simplifying the configuration of Language Server Protocol (LSP) clients. It provides pre-defined, default settings for numerous LSP servers, including the commands to start them and the filetypes they should attach to.

Installation

You can use the below Lua file for installing this plugin:

	{
		"neovim/nvim-lspconfig",
		dependencies = { "saghen/blink.cmp" },
		opts = {
			servers = {
				lua_ls = {},
				ts_ls = {},
				ruff = {},
				jdtls = {},
			},
		},
		config = function(_, opts)
			local lspconfig = require("lspconfig")
			for server, config in pairs(opts.servers) do
				config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities)
				lspconfig[server].setup(config)
			end
		end,
	}

mason-lspconfig.nvim

This plugin helps bridge the gap between lspconfig and mason and enables easy usage of lspconfig with the LSP servers installed through mason.

Installation

The installation guide can be found here:

nvim-autopairs

This plugin simply adds the functionality of closing brackets, quotes, etc., to be added when the opening one is typed.

Installation

The installation guide can be found here:

blink.cmp

blink.cmp is the battery-included completion engine that requires very minimal setup.

Installation

The installation guide can be found here:

nvim-dap

nvim-dap is a Debug Adapter Protocol (DAP) client implementation for Neovim. It’s a plugin that allows you to debug your code directly within Neovim by communicating with language-specific debuggers.

Installation

The installation guide can be found here:

none-ls.nvim

none-ls.nvim is a Neovim plugin crafted in Lua that serves as a bridge, enabling Neovim to function as a Language Server for integrating capabilities from sources that don’t inherently use the Language Server Protocol (LSP).

Installation

You can use the below Lua file for installing this plugin:

return {
	"nvimtools/none-ls.nvim",
	dependencies = {
		"nvimtools/none-ls-extras.nvim",
	},
	config = function()
		local null_ls = require("null-ls")
		local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
		null_ls.setup({
			sources = {
				null_ls.builtins.formatting.stylua,
				null_ls.builtins.formatting.prettier,
				null_ls.builtins.formatting.black,
				null_ls.builtins.formatting.isort,
				null_ls.builtins.completion.spell,
				require("none-ls.diagnostics.eslint"),
			},

			on_attach = function(client, bufnr)
				if client.supports_method("textDocument/formatting") then
					vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
					vim.api.nvim_create_autocmd("BufWritePre", {
						group = augroup,
						buffer = bufnr,
						callback = function()
							vim.lsp.buf.format({ async = false })
						end,
					})
				end
			end,
		})

		vim.keymap.set("n", "<leader>ff", vim.lsp.buf.format, {})
	end,
}

Useful Shortcuts

Basic Navigation

Moving around your code efficiently is crucial. These shortcuts are your bread and butter in Normal mode:

  • h: Move cursor left
  • j: Move cursor down
  • k: Move cursor up
  • l: Move cursor right
  • w: Move to the beginning of the next word
  • b: Move to the beginning of the previous word
  • e: Move to the end of the current word
  • 0 (zero): Move to the beginning of the current line
  • $: Move to the end of the current line
  • gg: Go to the first line of the file
  • G: Go to the last line of the file
  • :{number}: Go to a specific line number (e.g., :15 to go to line 15)

Entering Insert Mode

Switching to Insert mode allows you to type and modify text. Here are common ways to enter it:

  • i: Insert before the cursor
  • a: Append after the cursor
  • o: Open a new line below the current line and enter Insert mode
  • O: Open a new line above the current line and enter Insert mode
  • I: Insert at the beginning of the current line
  • A: Append at the end of the current line

Editing

These shortcuts in Normal mode let you perform common editing tasks quickly:

  • dd: Delete the current line
    • Example: 5dd deletes five lines starting from the current line.
  • yy: Yank (copy) the current line
    • Example: 3yy yanks three lines starting from the current line.
  • p: Paste after the cursor
  • P: Paste before the cursor
  • x: Delete the character under the cursor
  • u: Undo the last change
  • <Ctrl> + r: Redo the last undone change
  • r{char}: Replace the character under the cursor with {char} (e.g., ra replaces with ‘a’)
  • cw: Change the current word (delete and enter Insert mode)
  • cc: Change the current line (delete and enter Insert mode)

Visual Mode (Text Selection)

Visual mode allows you to select text for various operations:

  • v: Enter Visual mode (character-wise selection)
  • V: Enter Visual Line mode (line-wise selection)
  • <Ctrl> + v: Enter Visual Block mode (rectangular selection)
  • Once in Visual mode, use navigation keys (h, j, k, l, w, b, etc.) to select text.
  • d: Delete the selected text
  • y: Yank (copy) the selected text
  • c: Change the selected text (delete and enter Insert mode)
  • >: Indent the selected lines to the right
  • <: Indent the selected lines to the left

File Operations

Managing your files within Neovim is straightforward with these commands (entered with : in Normal mode):

  • :w: Save the current file
  • :w {filename}: Save the current file as {filename}
  • :q: Quit Neovim (if no changes have been made)
  • :q!: Quit Neovim without saving changes
  • :wq: Save the current file and quit Neovim
  • :e {filename}: Open {filename} for editing

Ending Notes

While the adoption of Neovim as a code editor needs a lot of practice, it is a consensus shared among developers who utilize this tool that once mastered, it becomes very difficult to go back to any old method of coding. More importantly, the joy coding with Neovim provides is comparable to that of a photographer using an analog camera to take photos.

While this blog post does not cover all the details of Neovim or the installation of the various plugins, I hope to have provided a foundation with which those who are interested in adopting this tool can use to make it possible.

Related Posts

Quitting smoking wasn’t just about breaking a habit—it was about learning the true meaning of determination. In this post, I share my journey, the battles fought within, and how these lessons in resilience can apply far beyond addiction, even to challenges in our careers and lives.

Read More

Application optimization can seem daunting for newcomers, but it’s a crucial skill for improving performance. This blog explores practical strategies, like minimizing loops, bulk fetching data, and leveraging database capabilities, to help you write more efficient code and take your development skills to the next level.

Read More

Getting to know a new codebase can feel overwhelming, but it’s a skill you can master with the right approach. In this post, I’ll share insights on how to break down and familiarize yourself with any codebase

Read More