519 words
3 minutes
From NeoVim to LunarVim
Anubhav Gain
2024-04-13

From NeoVim to LunarVim#

Guangzhou, China

Installation#

Prerequisites:

  • Make sure you have installed the latest version of Neovim v0.9.0+.
  • Have git, make, pip, python, npm, node, and cargo installed on your system.
Terminal window
LV_BRANCH='release-1.3/neovim-0.9' bash <(curl -s https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh)

Optional:

Terminal window
sudo npm install -g neovim tree-sitter-cli
pip install pynvim

Updating LunarVim#

Inside LunarVim :LvimUpdate

Updating Plugins inside LunarVim :LvimSyncCorePlugins

From the command-line lvim +LvimUpdate +q

Post install#

LunarVim uses icons from Nerd Fonts. If you don’t want to use them, set lvim.use_icons to false.

Terminal window
mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts && curl -fLO https://github.com/ryanoasis/nerd-fonts/raw/HEAD/patched-fonts/DroidSansMono/DroidSansMNerdFont-Regular.otf

After installing your font, refresh your font cache:

Terminal window
fc-cache -f -v

Cheat Sheet#

Keybinds#

Exiting:

  • :q: Close file
  • :qa: Close all files
  • :w: Save
  • :wq / :x: Save and close file
  • ZZ: Save and quit
  • ZQ: Quit without checking changes

Navigating:

  • h j k l: Arrow keys
  • <C-U> / <C-D>: Half-page up/down
  • <C-B> / <C-F>: Page up/down
  • 0: Start of line
  • $: End of line
  • b / w: Previous/next word
  • ge / e: Previous/next end of word

Line:

  • ^: Start of line (after whitespace)

Document:

  • gg: First line
  • G: Last line
  • :{number}: Go to line {number}
  • {: Jump to beginning of paragraph
  • }: Jump to end of paragraph

Operators:

  • d: Delete
  • w: Motion
  • y: Yank (copy)
  • c: Change (delete then insert)
  • >: Indent right
  • <: Indent left
  • =: Autoindent
  • u: Undo
  • <C-R>: Redo

Configuration#

You can configure LunarVim by using the configuration file located in:

cat ~/.config/lvim/config.lua

Read the docs

Custom Keybinds#

-- Move selected line with K or J
vim.keymap.set("v", "K", ":m '\<-2\<cr\>gv=gv")
vim.keymap.set("v", "J", ":m '\>+1\<cr\>gv=gv")
-- Scroll with ctrl-d and ctrl-j while keeping centered
vim.keymap.set("n", "\<C-d\>", "\<C-d\>zz")
vim.keymap.set("n", "\<C-u\>", "\<C-u\>zz")
-- Find next with n and N while keeping centered
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- Use system clipboard when copying with SPACE+y
-- You may need to install xclip (X11) or wl-clipboard (wayland)
vim.keymap.set("n", "\<leader\>y", "\"+y")
vim.keymap.set("v", "\<leader\>y", "\"+y")
vim.keymap.set("n", "\<leader\>Y", "\"+Y")

Python#

Configure LunarVim for Python development:

lvim.builtin.treesitter.ensure_installed = {
"python",
}
local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup { { name = "black" }}
lvim.format_on_save.enabled = true
lvim.format_on_save.pattern = { "*.py" }
local linters = require "lvim.lsp.null-ls.linters"
linters.setup { { command = "flake8", args = { "--ignore=E
203" }, filetypes = { "python" } } }
From NeoVim to LunarVim

Other#

Terminal window
:TSInstall json
:TSInstall javascript
:TSInstall typescript
:TSInstall tsx
--move selected line with K or J
vim.keymap.set("v", "K", ":m '\<-2\<cr\>gv=gv")
vim.keymap.set("v", "J", ":m '\>+1\<cr\>gv=gv")
--scroll with ctrl-d and ctrl-j while keeping centered
vim.keymap.set("n", "\<C-d\>", "\<C-d\>zz")
vim.keymap.set("n", "\<C-u\>", "\<C-u\>zz")
--find next with n and N while keeping centered
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
--use system clipboard when copying with SPACE+y
--you may need to install xclip (X11) or wl-clipboard (wayland)
vim.keymap.set("n", "\<leader\>y", "\"+y")
vim.keymap.set("v", "\<leader\>y", "\"+y")
vim.keymap.set("n", "\<leader\>Y", "\"+Y")
lvim.builtin.treesitter.ensure_installed = {
"json",
"javascript",
"typescript",
"tsx",
}
From NeoVim to LunarVim
https://mranv.pages.dev/posts/from-neovim-to-lunarvim/
Author
Anubhav Gain
Published at
2024-04-13
License
CC BY-NC-SA 4.0