Skip to content

nickcernis/neovim-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

193 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neovim config

My Neovim config, one file under 1000 lines.

Setup

Assumes macOS and Neovim 0.11+.

Install dependencies:

brew install neovim ripgrep fzf bat git-delta gnu-sed fd rg lazygit zoxide

Optionally backup existing neovim state:

mv ~/.config/nvim ~/.config/nvim-backup
mv ~/.local/share/nvim ~/.local/share/nvim-backup
mv ~/.cache/nvim ~/.cache/nvim-backup

Or just remove it:

rm -rf ~/.config/nvim ~/.local/share/nvim ~/.cache/nvim

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 # also re-run this if you see caching issues after bat upgrades
bat --list-themes | grep tokyo # should output "tokyonight_night"
echo '--theme="tokyonight_night"' > "$(bat --config-dir)/config"

Note: The upstream theme has a very dark lineHighlight color (#00000030) that makes the highlighted line nearly invisible in fzf-lua previews. To fix this, edit ~/.config/bat/themes/tokyonight_night.tmTheme and change line 38 from:

<key>lineHighlight</key>
<string>#00000030</string>

to:

<key>lineHighlight</key>
<string>#283457</string>

Then rebuild the cache with bat cache --build.

Bindings

Search, nav, file switching

  • <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><tab> for last buffer. (Repeat to alternate between two files.)
  • <space> f b or <space> f t for buffer/'tab' list, then Ctrl-x to close buffer.
  • <space> f y for LSP symbols list.
  • <space> g s for git status, left to stage, right to unstage.
  • <space> f c for recent changes.
  • <space> f j for recent jumps.
  • <space> f r for recent file browser.
  • <space> f <space> for last fuzzy search with entered text retained.
  • <space> j to jump by typed word.
  • s for flash jump by character (letter targets after first typed character).
  • S for flash jump based on treesitter.
  • ds or dS to delete until typed character.
  • <space> r to find-replace across project (uses Grug Find and Replace).
  • <space> f u for undo tree, enter to revert to selected change.
  • <space> f z for project switcher (requires zoxide, expects Ghostty to open in new window).

File handling

  • <space> e to toggle the file tree ('explore'). (Then a to create, r to rename, d to delete, ? for help, <space> e to close.)
  • Ctrl-k to go back in jump list (also reopens closed buffers).
  • Ctrl-j to go forward, :FzfLua jumps for a visual view.

Close, quit

  • Ctrl-w to close the buffer.
  • Ctrl-q to save all and quit.

Window manipulation

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.

Git

  • <space> g c for commit list.
  • <space> g b for branches, type new branch name and control-a to create from current.
  • <space> g s for status (uncommitted files).
  • <space> g h for hunks (good to navigate to recently changed location).
  • <space> g o to open current line or range in GitHub in your browser.
  • <space> g p for a list of GitHub PRs (uses GitHub CLI).
  • <space> h p to preview a git hunk.
  • <space> h r to reset a git hunk.
  • <space> h R to reset the current buffer.
  • <space> h s to stage the hunk.
  • <space> h S to stage the buffer.

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. (Formatters configured in 'conform' block in init.lua.)

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, and a UI with load times.

:Lazy summons the plugin UI.

Wishlist

Things to explore:

Other notes

Terminal

I use 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.)

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

 
 
 

Contributors

Languages