Small guide to get into neovim using lunarvim
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Penguin d6b114e853 updated doc 2 years ago
img added image 2 years ago
README.org updated doc 2 years ago
config.lua fixed missing comma in config 2 years ago

README.org

Getting Started with Neovim/Lunarvim

Background Information

THIS README IS A WORK IN PROGRESS AND IS NOT COMPLETE! This guide will go over very surface-level stuff for lunarvim. It will covering installing neovim and then lunarvim. It will also cover very basic configuration options.

What is Neovim? Lunarvim?

Neovim is a "forked, more feature-rich version of [vim]". It utilizes lua to do its configuration, but vimscript also works just fine in it. In text editors like neovim and emacs, there aren't settings like how a normal IDE or text editor might handle configuration. This is a good thing and a bad thing. On one hand, it means that literally every part of the text editor is yours to configure. Once you are done with it, the text editor is your text editor. Rather than settings, you will make your changes to the editor with code. The bad thing about this is that it is more work, but that doesn't have to be a bad thing. It's only a bad thing if you let it become a bad thing. More on this later.

These configurations you make via code are called… configs. Think of LunarVim as a well put-together config, with a lot of features set up out of the box. It essentially moves a lot of the initial configuration away from you and into the hands of the lunarvim devs. That being said, it is still neovim and is still 100% configurable.

Why use a text editor like lunarvim?

Lunarvim is a great starter text editor because it sets you up to configure things the way you want with lots of documentation without having to focus on primitive features most text-editors already have like a file explorer or window tabs. Think about it like this: Have you ever wanted some really niche feature that most people wouldn't want? In something like VSCode, this is a hard sell. If the extension doesn't exist, you're welcome to try developing it yourself, but that's (in my opinion) an entire project all on its own. In something like neovim or emacs, your tiny feature has probably already been implemented by someone on the internet, and even if it hasn't, it's probably only a small snippet of code to make it happen. I also have to throw in the low hanging fruits of (neo/lunar)vim perks: speed, power, and portability.

Installing Neovim on ubuntu

sudo snap install nvim

One downside of ubuntu is snaps. They are a bait. They generally suck. They are slow. The security features are basically security theater. However, it is the easiest way to install a somewhat up-to-date version of neovim on ubuntu without compiling it from source. I, personally, just compile neovim from source because I hate snaps.

That's really it. I'm not sure why I made this a whole section.

Installing LunarVim

Before we install lunarvim, let's make one thing clear. Lunarvim is not a program. It's literally a super well-thought out config file. I cannot stress that enough because it is important!

AND before we install lunarvim, we should install some prerequisites. These aren't necessary, but you want them. I'm going to assume we already have pip installed. Let's install rust:

Why are we installing rust?

We are installing rust because it installs cargo, the rust package manager. We can use that to install rust programs and toolchains. The only rust program we really care about is ripgrep. Ripgrep is like grep, except ripgrep is, scientifically speaking, fast as f!^k. It will allow you to find keywords in extremely large projects insanely fast, if not instantaneously.

Installing rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME"/.cargo/env # this is just refreshing your environment so it sees the cargo binary

Installing Lunarvim

LV_BRANCH='release-1.2/neovim-0.8' bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/fc6873809934917b470bff1b072171879899a36b/utils/installer/install.sh)

The above snippet is from lunarvims official website: https://www.lunarvim.org/docs/installation If any dependencies are missing, it should tell you what you're missing.

What did this just do?

If you want to know specifically what we just did, open the install.sh file and inspect it! I will give a general overview if you don't want to do that: The install script is really well put together. It verifies that your neovim will work with lunarvim and then it installs lunarvim to ~/.config/lvim. It also installs dependencies (like ripgrep) through cargo, pip, and npm, though I opt not to use npm and say no to that during the install. Inside of your ~/.config/lvim folder, you'll find a config.lua file. That's your config!

Using my config

Prerequisites:

sudo apt install clangd g++-12 global
cargo install tree-sitter-cli

This repo contains a config.lua. It is just the basic lunarvim config with a few of my additions (one being the custom clangd hook so we can set our compiler.) Just copy it into your ~/.config/lvim folder and it will overwrite the default config. Then open your lunarvim and type

:PackerSync
:PackerUpdate

and then you should be good to go!

Fonts (Nerd Fonts)

(Nerd) Fonts are an important part of using lunarvim. Nerd fonts are just regular fonts that have been "patched" with glyphs. There's actually a website purely for looking up glyph codes so you can patch your own fonts: https://www.nerdfonts.com/cheat-sheet. The glyphs in nerd fonts are used as icons for a bunch of things like git, tabs, folders, etc. I use jet brains mono: https://www.jetbrains.com/lp/mono/ (free and open source font), but you can use whatever font you'd like. Here's a list of (pretty much) confirmed working fonts: https://www.nerdfonts.com/font-downloads

WIP Jumping into lunarvim

Documentation

There are also some YouTube videos created by the LunarVim creator, chris@machine. If you wish to see how he essentially created lunarvim, here's his neovim from scratch series. It's not an exact copy of the lunarvim config, but it is a very detailed guide on how to do everything LunarVim does in neovim.

  • Remember to use :help <phrase> for information on vim and nvim functions. A lot of the time the function you need exists already, and it's in the documentation.
  • Lastly, here's a really well written guide on general usage of vanilla lunarvim.

Keybindings and the "Leader" Key

The leader key is your entry point into executing most of your commands from normal mode. It is by default bound to space. This means most things will begin with hitting the spacebar. The following lists of keybinds aren't exhaustive. They're just the important ones. NOTE: These keybinds are viewable via your leader key. Just hit your leader key and wait a second, and a menu (provided by whichkey) will pop up like so: /penguin/intro-to-neovim/src/commit/d6b114e853c153c17ddabef389a183cef2f58214/img/whichkey.png

[meta] LunarVim Keybinds:
Keybind Description
<SPC L k> List all keybinds
<SPC L c> Edit config
<SPC L u> Update LunarVim
<SPC L i> LunarVim Info
<SPC L r> Reload config
Buffer Management Keybinds
Keybind Description
<SPC w Down> Jump to below buffer
<SPC w Left> Jump to left buffer
<SPC w Right> Jump to right buffer
<SPC w Up> Jump to above buffer
<SPC w x> Close buffer
<SPC w h> Next buffer tab
<SPC w l> Previous buffer tab
Miscellaneous
Keybind Description
<SPC /> Comment line (99% of languages work with this command)
<SPC ;> Home (go to dashboard)
<SPC e> (toggle) File explorer
<Ctrl t> (toggle) terminal
<Spc h> Remove search highlight
<Spc q> quit

TODO Window Management vs Buffer Management

TODO Configuring Lunarvim

This section will include snippets from my config to explain what it is doing and why I am doing it.

TODO Setting Keybinds

TODO Setting up language support

TODO Setting up LSP servers (extends language support)

This section will mainly include setting up C/C++ clangd support. Other stuff may or may not show up because it is less important to me.