Nice Neovim Configuration

This is just a nice neovim configuration to make neovim work like an IDE while still running reasonably fast. It's based on the neovim configuration shown in this series: Neovim IDE from Scratch - Introduction (100% lua config) - YouTube. However, I've gone beyond what the series shows, changed some of the configurations used in the series and have generally made this configuration my own

Usage

This configuration is intended to be used as an IDE. Most features should appear after hitting one of the following keys. The leader key, or space, is to find features that are used once and then only used after a bit of time. For example, you'll find all the commands for finding text or files here. Hitting the square bracket keys [ or ] will allow you to jump forward to different blocks or lines in your file. It's how you jump between hunks, diagnostics, functions, etc. The g key is for commands that are common and will be used over and over again. It's also responsible for commands that make you go to certain locations, like different files. This includes commands like showing a line's diagnostic or going to definitions or declarations. These are bound to change as I use this more and other people use it and I determine what's easiest to understand and most comfortable.

Which key is used to tell you what commands you can run from your current keybinding. If you hit "g", you'll see all the commands you can run from "g". If you hit "", you'll see all the commands you can run from that. Currently, which key outputs every helpful binding it can, but that may be fine tuned in the future.

Below, I describe what all the plugins do, and, in the case they do a lot more than we use, I describe what exactly we use from each plugin

Of course, in terms of navigating the editor and editing things, just use all the neovim stuff you know and love.

Plugins

Dependencies

If you ever want to see if you are missing any dependencies, run :checkhealth

Extending the Existing Plugins

You can use this source - rockerBOO/awesome-neovim - to find more plugins that may be useful to you. Once you find one, go to plugins.lua and add a use statement to import the plugin. Then, create a new file at the same level as plugins.lua called <plugin_name>.lua. In that file, require the new plugin and add all your configurations. When requiring the plugin, do it like this

local status_ok, project = pcall(require, "project_nvim")
if not status_ok then
    return
end

So that the plugin doesn't throw a bunch of unecessary errors in the case it isn't installed.

In terms of the actual configurations, most plugins provide a section where they show all the default configurations in one big object. I would recommend copy and pasting that over so you can change settings easier. This does mean the config will break on some updates and you'll need to fix it, but it's good to know about config changes and it's good to know what all the possible configurations you can do are.

In any case, after you write your configurations, go to the top level init.lua file and add the line require "user.<plugin_name>".

If you are working on adding a lot of plugins for a particularly complex feature, like LSP stuff, you can add a folder into user and group all the configurations there. Use LSP as an example if you need to do that.

Useful Files to Know About

  • plugins.lua is where Packer installs all our plugins

  • whichkey.lua configures the popup that comes up when you hit the leader key, g or ctrl-w

  • options.lua is what configures all the options you get with neovim out of the box

  • keymaps.lua is where the key mappings that aren't displayed in whichkey.lua are configured.

  • lsp/handlers.lua is where most of the visible parts of the LSP configuration are configured, and is where all the keymaps not shown in the popup for LSP are configured

Useful Commands to Know About

  • In most areas, hitting g? will toggle a help pane to give you the commands possible in that buffer

  • Hitting I in nvim tree pulls up all your git ignored files, they are hiddedn by default

    • There are various other commands in nvim tree for hiding/showing certain files, use g? to learn them all

Troubleshooting

  • A lot of the LSP stuff and plugins work by automagically determining what set of folders and files make up a project. Makign your project a git repo can suddenly make a lot of features that are bugging out suddenly work

Potential Things to Work On

  • Keymaps will always need work! I want to make them easier to understand and more useful over time

  • Currently with debugging, you have to hit <leader>d to get any of the commands to appear. I'm considering using something like anuvyklack/hydra.nvim to create a debugging mode, but I'm not too sure on that yet

  • g, as can be expected, stores A LOT of keybindings, I'm wondering if there's a way to reduce the strain on g based bindings

  • Each language should probably be organized into its own file for the dap stuff. Also, apparently Mason somehow provides the executable so you don't need to dig up the dap path, but I can't figure that out

  • null-ls has code actions and other features that would be great to implement

  • Should possibly configure nvim-dap-ui to look nicer and to close the file tree when it starts up

  • Currently, I use prettier to lint markdown files, because it is easy to setup and doesn't require me creating a configuration file, but perhaps I should use markdownlint, which would require some JSON file

  • Potentially port lua code over to fennel (the Fennel programming language (fennel-lang.org))? It looks interesting, but I'm not sure if it's worth it yet