Skip to content

nickcernis/neovim-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neovim config

My personal Neovim config, Lua-only, from scratch.

Setup

Assumes macOS and Neovim 0.9+.

brew tap homebrew/cask-fonts
brew install neovim ripgrep fzf bat git-delta gnu-sed fd rg lazygit font-fira-code-nerd-font

You'll also need node, golang, zig and zstd to auto-install language servers (zstd is used to compress the Zig language server):

brew install node golang zig zstd

Then:

mkdir ~/.config && cd ~/.config
git clone https://github.com/nickcernis/neovim-config nvim

Optionally set the theme for bat to match Neovim, so that preview colours match:

mkdir -p "$(bat --config-dir)/themes"
cd "$(bat --config-dir)/themes"
curl -O https://raw.githubusercontent.com/folke/tokyonight.nvim/main/extras/sublime/tokyonight_night.tmTheme
bat cache --build
bat --list-themes | grep tokyo # should output "tokyonight_night"
echo '--theme="tokyonight_night"' > "$(bat --config-dir)/config"

Layout

├── README.md                 -> You are here.
├── init.lua                  -> ASCII art and includes.
├── lazy-lock.json            -> Plugin lockfile updated by Lazy.
├── local-plugins/            -> Personal plugins not yet released publicly.
└── lua
    └── config
        ├── autocommands.lua  -> Auto-strip whitespace, file picker on load.
        ├── keymaps.lua       -> Do things when you press things.
        ├── lazy.lua          -> Bootstrap the Lazy plugin manager.
        ├── options.lua       -> General settings.
        └── plugins           -> Plugin configs, loaded automatically by Lazy.
            ├── [plugin1].lua
            ├── [plugin2].lua
            └── [...].lua

Bindings

General

  • <space> f p to find files in current project.
  • <space> f f to find lines in current file (similar to swiper in Emacs).
  • <space> f g to search text in current project (backed by ripgrep).
  • <space> e or Ctrl-e to toggle the file tree. (Then a to create, e|r|Ctrl-r to edit, d to delete, ? for help, Ctrl-e to close.)
  • <space> f j for the project switcher.
  • <space> f b for buffer list, then Ctrl-x to close buffer.
  • <space> f y for LSP symbols list.
  • <space> f s for git status, left to stage, right to unstage.
  • Ctrl-j for word jump targets.
  • Ctrl-t for tab jump targets.
  • Ctrl-o to go back in jump list (also reopens closed buffers), Ctrl-i to go forward, :FzfLua jumps for a visual view.
  • Ctrl-w to close the buffer.
  • Ctrl-q to save all and quit.
  • Alt-f to find-replace in current buffer (uses Spectre).
  • Alt-g to find-replace in current project (uses Spectre).
  • Alt-h|Alt-l|Alt-[number] to navigate tabs. Important to set the left option key to Esc+ in iTerm's key prefs (profile settings) for Alt bindings to work on macOS.

Other bindings

I use these in normal mode in place of the default Ctrl-w window commands, since I map Ctrl-w to close buffer:

  • <space> w v to split vertically.
  • <space> w s to split horizontally.
  • <space> w h to move cursor left.
  • <space> w l to move cursor right.
  • <space> w r to rotate buffers between window.
  • <space> w d|x to close the window.
  • <space> b d|x to close the buffer.

Additional leader key bindings

  • <space> t t to spawn a new Kitty tab using Neovim's current working directory.
  • <space> t r to repeat the last ran command in the spawned shell window (great for repeated compilation/runs).
  • <space> t g to spawn a new Kitty tab running lazygit, or to switch to it.
  • <space> g h to display a GitHub CLI UI.
  • <space> h p to preview a git hunk.
  • <space> h r to reset a git hunk.

LSP

  • K to show LSP hints.
  • gl to show LSP issues.
  • gd to go to definition and Ctrl-o to return.
  • gr to show references and :q to exit.
  • F2 to rename current cursor position.
  • F4 for code actions on the current cursor position.
  • Ctrl-; to format the current buffer or selection if the LSP server provides formatting support.

Commands

  • :Lazy to update/install plugins.
  • :FzfLua for all FzfLua pickers.
  • :Mason to manage LSP servers.
  • :LspInfo is sometimes useful, as is :LspInstall.

Plugins

Managed with Lazy, which gives us a lockfile, automatic caching and bytecode compilation, a smart upgrade/install UI with load time reports, and easy plugin config split across files.

Configs in ./lua/config/plugins/ are automatically loaded.

:Lazy summons the plugin UI.

Wishlist

Things to explore:

Git

Formatting

Misc

Other notes

Terminal

I use Kitty panes or tabs instead of Neovim's terminal emulation. Long-running terminal processes in Neovim itself reduce editor performance for me. (If I open a toggleterm, then run yes and toggle the terminal closed, Neovim movements and edits lag for me in both iTerm and Kitty.)

Git

I use git and GitHub CLI in the terminal, as well as lazygit in a separate long-running terminal tab.

Inspiration and reference

About

Personal Neovim setup.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages