Welcome to klebster2's Neovim configuration.
This setup is designed to be powerful, customizable, and beginner-friendly. Whether you're a new user or an experienced Vim/Neovim user, this guide will help you get started quickly and smoothly.
This configuration is built with the following tools:
- Neovim (latest version)
- Lazy.nvim (plugin manager)
- LSP & CMP (for smart autocompletion)
- Treesitter (for syntax highlighting)
- Fzf-Lua (for fast file and command search - derived from Fzf)
- Ollama (optional, for AI-powered code generation)
Before installing, ensure you have the following tools installed:
For instructions see up-to-date Neovim Releases. For unix based systems (Mac, Linux), you will need to know the kernel CPU architecture*. * Get the kernel using
uname -a | rev | cut -d ' ' -f1 | revOther dependencies include jq for querying json files; curl for downloading installation files, ollama.nvim, and plenary.nvim; npm (node package manager), autotools-dev and autoconf
To install them, on Ubuntu, run:
sudo apt-get install jq curl autotools-dev autoconf git -yOn macOS (using Homebrew) run:
brew install neovim jq curl npm git autoconfClone the repo to ~/.config/nvim (the default neovim location)
mkdir -pv ~/.config && git clone "https://github.com/klebster2/vimrc" ~/.config/nvimRun the installation script install.sh
pushd ~/.config/nvim && ./install.sh && popdOllama is useful for generative AI applications.
Generate code candidates using the neovim package: ollama.nvim, or avante.nvim
curl -fsSL https://ollama.com/install.sh | shIMPORTANT
Check your GPU Virtual RAM (VRAM) can hold a model defined in lua/plugins/ollama.lua, under opts.model, configure lua/plugins/avante.lua with the same model under opts.ollama.model.
Key combination remappings here are structured using Mnemonics - for instance - help by allowing the first letter of each word for each command.
Shortcuts
The following section lists commands that will take you to configuration files (both Neovim dependent and other configs)
If you do not know what leader key means, then just assume for now that it means the space <space> (as it is set in this configuration to space).
- Use
<leader>evwhen in normal mode edits theinit.luafile - the main configuration file for neovim. - The configuration file should live by default at the following location
$HOME/.config/nvim/init.lua. Some of the mappings listed below can be found within the following keymapping files:- Use
<leader>emto go tolua/keymappings.lua(the basic set of mappings that should work when running native neovim).
- Use
Miscellaneous configuration file shortcuts (these will only work if you have a configuration file at that location), use:
<leader>etfor Edit Tmux, to edit the tmux configuration file:~/.tmux.conf<leader>ebfor Edit Bash, to edit the bashrc file~/.bashrc<leader>eifor Edit Inputrc, to edit the inputrc file~/.inputrc
Generic commands
Note that the following commands apply to Normal Mode only.
- Use
gdto Go to the Definition. When the Cursor is on a Word (cword), and that word is a function-call, or variable, you can typegdto go to the function Definition or where the variable is set. - When the Cursor is on a File (fullpath, or partial path), you can type
gfto Go to the File. - To exit Insert Mode use
jktyping them together quickly. Note that the default way to exit normal mode in vi, vim and neovim is<ESC>.
Completion menu for LSP and CMP
Note that these completions apply to Insert Mode and Command Mode only, when the cmp popup menu is visible.
Nvim-Cmp is the autocompletion engine used. LspConfig is a NeoVim client that allows for configuring (Language-Server-Protocols in NeoVim)
- Read more about the NeoVim LSP client on the NeoVim LSP help page
To jump to the subsequent completions using Lsp, Cmp, Luasnip, etc. use
<CTRL+p>for Prev completion option<CTRL+n>for Next completion option<CTRL+e>to Exit the completion menu<CTRL+y>to say Yes. E.g. the user wants to complete the text with the current option; confirm and insert the completion<CR>to Accept the completion, replacing everything that was previously there
LuaSnip
LuaSnip is a snippets engine, that permits the user to use snippet templates. These templates should ideally increase the speed of development while not sacrificing code quality.
When completing a snippet, use
<CTRL+k>after selecting a luasnip option to jump to the next snippet jump point<CTRL+j>to jump to the previous snippet jump point
See the snippets file here: lua/plugins/snippets.lua
Completion Docs
Note that this applies to Insert Mode only (as above).
<CTRL-f>to scroll the docs Forwards<CTRL-b>to scroll the docs Backwards
Also see :help vim.lsp.* for documentation on any of the LSP functions
Language Server Protocol (LSP) Diagnostics
Note that this applies to Normal Mode only.
Use:
<SPACE>+eto open a floating window containing the LSP diagnostic (according to the LSP)<SPACE>+qto open a window of LSP diagnostics below the current buffer[dto go to the previous LSP diagnostic]dto go to the next LSP diagnostic
Also see :help vim.diagnostic.* for documentation on any of the Lsp diagnostics.
To see the configuration, go to the file lua/plugins/nvim-cmp-cfg.lua.
Nvim Spell
Use:
<z>+<w>to add the cword to the dictionary.<leader>ssto:set spell(misspelled words will appear underlined)
NvimTree
NvimTree is a plugin used for file / directory viewing.
To active the NvimTree view, use <leader>vs, with the default settings this is <space>vs.
When within the NvimTree viewer, you can use any of the defaults:
<SHIFT+r>to Reread the files contained in the focused project<SHIFT+h>to toggle the display of hidden files and folders beginning with a dot.. Note that some other files may be hidden by default (like git files / directories).<SHIFT+e>to Expand the entire file tree starting from the root folder (workspace)<f>to Find files (opening a search filter that will be applied)<SHIFT+w>To collapse all open folders starting from the root folder<\s>to open the file with the System application set by default for that file type<->(Dash/Hyphen) Allows you to go "backwards" into parent folders. This navigation also allows you to exit the root folder (workspace) to your home directory<SHIFT+f>to close the interactive search<CTRL+k>to display information about the file such as size, creation date, etc.<g+?>to open the help with all the predefined shortcuts for quick reference<q>to close the file explorer
For the NvimTree configuration, go to lua/plugins/nvim-tree.lua
Also note that some files and directories such as .git/, and .gitignore may be omitted from the NvimTree view due to how unusual it is for those files to be edited.
Fzf-Lua
Fzf is a powerful fuzzy-finder.
It can be used to quickly find files using keybindings in the terminal such as <Ctrl+r> for history.
Since the release of one of Fzf's cousins fzf.vim, a github user wrote an Fzf-Lua plugin which is blazingly fast. Allegedly, it is even faster than Telescope.
Use:
<CTRL-f>to start searching for files.<CTRL-t>to search helptags<CTRL-x>to grep the cword (word under the cursor)
MIT License