top of page

NeoVim



Introduction

I've been motivated this year to make Neovim my main IDE environment. After years of trying back and forth, I finally feel like I have a system that works and can work efficiently working with the text editor and all of its extensions. I've had several friends ask me how to set up my environment and thought I would share a quick overview of my environment.





Disclaimer

This is not a learn vim tutorial. I would recommend downloading tools in VS code or your current IDE to learn the basics. I would also recommend Vim-Adventures as a good option to play and learn at the same time. https://vim-adventures.com/






Installing Neovim


This section of the tutorial will cover how to put NeoVim on Windows because it is the hardest of the OSs to set everything up correctly. If you use a Mac or Linux user, you can follow the link below. It will get you set up and then we can continue the rest of the tutorial.



Now for the Windows users, first I would suggest if you are following this tutorial go back to my previous tutorial on setting up Windows Terminal.



Once we have your terminal set up, let's dive into installing the correct tools. Choose one of the package managers below download them onto Windows and then use the command lines listed to install Neovim.



Chocolatey

You can install Chocolatey by using the command below. Chocolatey is a useful package manager to have. Many people use it in different tutorials for Windows power users.

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Once it has finished installing, you can use the command below to install Neovim.

choco install neovim

Winget

Winget is another option. You can try installing it using the command below.

winget search nvim

Install by running this command

winget install Neovim.Neovim

Scoop

Scoop is the last option. You can set up Scoop by running the command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

Once it is setup, you can run the commands below and install NeoVim.

scoop bucket add extras
scoop install vcredist2022
# Install Nvim
scoop install neovim
# Install Nvim's GUI
scoop install neovim-qt


NeoVim Package Managers

Neovim contains several cool plugins and tools to make developing easier and more relatable to the common IDEs we use today. The first thing to decide on while working in Neovim is which package system you want to use. I currently prefer Lazy.


I used Packer in the past, which worked out pretty well but have more recently switched over to Lazy. I found editing the packages was a bit easier and managing my environment took less time and needed less knowledge of Lua to make everything sexy. My configuration is below from my GitHub and this tutorial will cover some of the top-level details for getting started and understanding how to work with Neovim.


Managing Plugins


Plugins are a way to make Neovim seem more like common-day IDEs. I am using Lazy as my package manager so you can always look at your plugins and manage them using the lazy shortcut. (For me its SPACE+L, this configuration can be found in the shortcuts section below.



To install a new plugin, I have been going to the Github repo for the package and there is usually a description on how to create a Lua file for the package. So let's get started by checking out a widely used plugin.

https://github.com/ThePrimeagen/harpoon Big shout out to ThePrimagen aka Vim Jesus. Watch his streams. I enjoy the content he makes and always enjoy finding random posts from the man himself while I've been digging through Vim. If you work through his README file, you will find all the code you need to add to your project. With Lazy, we have to change it a bit. The code below is in the Lua/Plugins/Harpoon.lua script and contains the code he listed in one nice file.

return {
    'ThePrimeagen/harpoon',
    event = 'VimEnter',
    config = function ()

        local harpoon_status_ok, harpoon = pcall(require, 'harpoon')
        if not harpoon_status_ok then
            return
        end

        local harpoon_mark_status_ok, harpoon_mark = pcall(require, 'harpoon.mark')
        if not harpoon_mark_status_ok then
            return
        end

        local harpoon_ui_status_ok, harpoon_ui = pcall(require, 'harpoon.ui')
        if not harpoon_ui_status_ok then
            return
        end

        local opts = { noremap = true, silent = true }
        local keymap = vim.keymap

        harpoon.setup({
            menu = {
                width = 60,
            },
        })

        keymap.set('n', '<leader>h', harpoon_mark.add_file, opts)
        keymap.set('n', '<C-e>', harpoon_ui.toggle_quick_menu, opts)

        keymap.set('n', '<leader>1', function() harpoon_ui.nav_file(1) end, opts)
        keymap.set('n', '<leader>2', function() harpoon_ui.nav_file(2) end, opts)
        keymap.set('n', '<leader>3', function() harpoon_ui.nav_file(3) end, opts)
        keymap.set('n', '<leader>4', function() harpoon_ui.nav_file(4) end, opts)
        keymap.set('n', '<leader>5', function() harpoon_ui.nav_file(5) end, opts)
        keymap.set('n', '<leader>6', function() harpoon_ui.nav_file(6) end, opts)
        keymap.set('n', '<leader>7', function() harpoon_ui.nav_file(7) end, opts)
        keymap.set('n', '<leader>8', function() harpoon_ui.nav_file(8) end, opts)
        keymap.set('n', '<leader>9', function() harpoon_ui.nav_file(9) end, opts)

    end
}

I will share the list of plugins I have in my Neovim at the end of the tutorial. There are a lot of them and many of them complement the other plugins they use. Take some time to look over them and play with the ones you find most relevant to your interests.


Managing Shortcuts


This is the document that lists all of the hotkeys I have programmed into Neovim. A note on when you download new packages, you will find previous keys may not work anymore and needs to be edited here and in the lua/plugins folder.

https://github.com/SkylarCastator/nvim/blob/main/lua/v9/keymaps.lua Generally, when working with hotkeys, you want to place them here. Sometimes when you are installing new plugins into Lazy using Lua files, they contain a shortcut in the file, I would suggest moving them into the keymaps file so they are all associated in the same location. The example below is the shortcut I use to access the Lazy prompt:

keymap.set('n', '<leader>l', ':Lazy<CR>', opts)

To learn more about making shortcuts you can go to the Neovim documentation and learn more about the proper protocols.

Understanding Lsp Servers

Lsp Servers is how Neovim manages the formatting for different languages for your Neovim environment. I use Mason to manage all my servers and it's easy to set up. You can run the ":Mason" command which will open up the UI to download or remove the Servers you need.

It's important to set up your language servers here. You can list them in the Lua files, but I recommend doing it here for easy access. Once you set up a language server, you can include linting and formatting for the programming language. At this point, you should be able to start writing code.


My Packages


This is a long list of all the packages I use. I would encourage you to research and play with each package individually until you understand how they impact the environment.

  • Alpha-nvim: A fast, fully programmable greeter for Neovim, allowing for a customizable startup screen with useful information and shortcuts.

  • Bufferline: Enhances the Neovim buffer line with a stylish look and tabpage integration, all built with Lua for performance and customization.

  • ChatGPT: Assumed to integrate ChatGPT-like functionalities within Neovim, potentially for code suggestions, documentation help, or conversational interactions.

  • CMP-Buffer: Part of the nvim-cmp ecosystem, it enables auto-completion from the open buffers, making code writing faster by suggesting words used in the project.

  • CMP-nvim-lsp: Integrates the Language Server Protocol (LSP) with Neovim's completion framework, nvim-cmp, for rich coding assistance like autocomplete, go-to-definition, and hover documentation.

  • CMP-Path: Enhances path autocompletion in Neovim by providing file and directory suggestions as you type.

  • CMP-Luasnip: Integrates LuaSnip, a snippet engine for Neovim, with the completion framework nvim-cmp, enabling seamless snippet completions.

  • Comment: Simplifies commenting code in Neovim, supporting multiple programming languages with easy toggle comments functionality.

  • Conform: A lightweight but powerful formatting plugin for Neovim that supports a variety of languages and formatting tools.

  • Flash: Assumed to be a plugin that highlights cursor movements or actions to improve visibility, especially useful in presentations or tutorials.

  • Format-On-Save: Likely a plugin that automatically formats your code upon saving, ensuring consistent code style without manual effort.

  • Friendly-Snippets: A community-driven collection of snippets for a variety of programming languages and tools, compatible with multiple snippet engines.

  • GitSigns: Provides super fast git decorations in Neovim, implemented purely in Lua, including git blame, diff, and added/removed lines.

  • Gruvbox-Baby: A variation of the popular Gruvbox color scheme for Neovim, optimized for readability and aesthetics.

  • Hardtime: Helps to break bad navigation habits in Vim by restricting the use of inefficient navigation keys, encouraging more efficient movements.

  • Harpoon: A plugin to improve workflow by allowing quick navigation to a predefined set of files, making it easier to switch between frequently used files.

  • Indent-Blankline: Adds indentation guides to Neovim, making nested code easier to read and follow.

  • Lazy: Likely refers to a plugin management tool that simplifies the installation and management of Neovim plugins.

  • Lsp-Zero: A streamlined setup for Neovim's LSP, providing sensible defaults and easy customization for a variety of programming languages.

  • Lspkind: Enhances the visual presentation of LSP completions with icons, making the completion menu more informative and visually appealing.

  • Lualine: A highly customizable status line for Neovim, built in Lua for performance and flexibility.

  • LuanSnip: A Lua-powered snippet engine for Neovim, allowing for dynamic and complex code snippets to speed up coding.

  • Markdown-Preview: Provides a real-time preview of Markdown files in a browser, improving the documentation and note-taking workflow.

  • Mason-Lspconfig: Integrates Mason, a Neovim plugin manager for LSP servers, linters, and formatters, with Neovim's LSP configuration, simplifying the setup process.

  • Mason: A package manager for Neovim that simplifies the installation and management of LSP servers, linters, and formatters.

  • Material: A Material Design-inspired color scheme for Neovim, offering a sleek and modern aesthetic for coding.

  • Neodev: Enhances Neovim's Lua development experience with additional LSP features, making Lua script development smoother and more powerful.

  • Novice: This could refer to a plugin designed to aid new Neovim users, possibly through tutorials, hints, or simplified navigation.

  • Nui: Offers a suite of UI components for Neovim, enabling the creation of user interfaces with dialogs, menus, and more, all within Neovim.

  • Nvim: Possibly refers to general Neovim configurations or plugins designed to enhance the core experience.

  • Nvim-Cmp: A powerful autocompletion plugin for Neovim, supporting a wide range of sources and languages, highly customizable and efficient.

  • Nvim-Dap: Adds debugging capabilities to Neovim, integrating with the Debug Adapter Protocol (DAP) for an improved coding and debugging workflow.

  • Nvim-Dap-Go: Extends Nvim-DAP with support for Go programming language, enabling powerful debugging tools within Neovim for Go developers.

  • Nvim-Lint: Integrates linters into Neovim, providing real-time feedback on code quality and potential errors.

  • Nvim-LspConfig: Configures Neovim's built-in LSP client, allowing for integration with a wide range of language servers for advanced coding assistance.

  • Nvim-Navic: Displays a navigation breadcrumb based on the LSP symbols, enhancing code navigation and context awareness.

  • Nvim-Notify: A fancy, customizable notification manager for Neovim, improving the display of messages and alerts.

  • Nvim-Tree: A file explorer sidebar for Neovim, allowing easy navigation and management of your project's file structure.

  • Nvim-Treesitter: Enhances Neovim's syntax highlighting, code folding, and parsing capabilities using the Treesitter parsing library for more accurate and visually appealing code.

  • Nvim-ts-autotag: Automatically updates HTML/XML tags with the help of Treesitter, simplifying web development in Neovim.

  • Nvim-Web-Devicons: Adds filetype icons to Neovim plugins like Nvim-Tree, buffer lines, and more, using web development icons for a visually enhanced experience.

  • Oil: Could refer to a plugin aimed at optimizing or enhancing the Neovim experience, though the exact functionality is not specified.

  • Persistence: Likely a plugin that enables session management in Neovim, allowing users to save and restore their workspaces across sessions.

  • Plenary: A Lua library required by many Neovim plugins, offering utility functions and essentials for plugin development.

  • Rainbow-Delimiters: Adds color-coded delimiters to code, making nested structures easier to differentiate and navigate.

  • Telescope: A highly extensible fuzzy finder over lists, enabling powerful search functionality within Neovim for files, LSP actions, and more.

  • Todo-Comments: Highlights and manages TODO comments in your code, making it easier to track tasks and issues directly within Neovim.

  • toggleTerm: Simplifies terminal management within Neovim, allowing users to easily open and toggle terminal windows.

  • Tokyonight: A Neovim color scheme inspired by the Tokyo night skyline, offering both light and dark modes for a pleasant coding environment.

  • Trouble: A diagnostic list plugin for Neovim, making it easier to navigate and fix problems in your code with LSP integration.

  • Undotree: Visualizes the undo history for editing sessions in Neovim, allowing users to navigate changes and revisions more effectively.

  • Vim-Fugitive: A Git wrapper for Neovim/Vim, enabling powerful git operations directly from the editor.

  • Vim-Lichess: Assumed to integrate or interact with the Lichess online chess platform directly from Neovim, potentially for playing, studying, or watching games.

  • Vim-Surround: Provides tools for manipulating surroundings in code, like parentheses, brackets, quotes, XML tags, and more, with ease.

  • Vim-Visual-Multi: Enables multiple cursors for simultaneous editing in Neovim, similar to features found in editors like Sublime Text and VSCode.

  • VScode: This could refer to plugins or configurations that mimic or integrate VSCode functionalities within Neovim, enhancing compatibility or user experience.

  • ZenMode: Offers a distraction-free writing and coding environment within Neovim, focusing on the central editing area by hiding UI elements.

  • Dadbod: A Vim plugin for database interaction, offering a modernized approach to execute SQL queries, browse schemas, and more, directly from Neovim.


Conclusion

Let's admit Neovim takes a lot to set up and learn. I will say once you start feeling comfortable in the text editor you will not want to go back. It's faster and allows you to stay focused on the work you are doing. The moment I started realizing I didn't have to access several different menus to make a setting work for a software project and that I could stay in one editor for all of my different projects I became committed. I hope this tutorial was useful for you and also helpful to start your Vim journey. Most of all, now you can be a real hipster and say "Hey I use Vim BTW".


 
 
bottom of page