- General Info
- Installation
- Requirements
- Configuration
- Getting Started
- Plugins
- Plugin Information
- Screenshots
This guide has information relating to Debian Linux
This is my personal NeoVim config that I use for a wide variety of things. This config is not meant for a specific purpose, but rather to cover a few different purposes that are specific to me as a Computer Science Major. The main uses for this configuration are:
- Making LaTeX Documents
- Coding in C/C++
- Coding in Rust
- Coding in Python
- Front end Development
I am using Primeppuccin Mocha as my main theme and for my LuaLine I use Cyberdream. For font, I use JetBrains Mono, but any Nerd Font will do.
Before you start, enter the .config
directory in the home directory.
Then clone the repository.
cd ~/.config
# Using SSH to clone from GitHub
git clone [email protected]:EthanGilles/nvim.git
If you have a Debian-based Linux distribution, you can install all of the dependencies by running the install script located in the top level of the repository. This will install ALL of the dependencies needed for NeoVim from a barebones Debian OS.
bash install.sh
DO NOT USE SUDO FOR THE INSTALL SCRIPT. IT WILL NOT WORK.
If you would rather go through the dependencies manually, see the Requirements section.
Now open up NeoVim! The Lazy plugin manager and its GUI should load and start downloading all of the plugins for the configuration. Once everything is downloaded, re-open NeoVim and the configuration should be loaded. It may take several minutes for all of the parsers and LSPs to download and install.
- NeoVim version (v0.10.0) is required. I use the NeoVim appimage because it works on every distro.
# Downloads FUSE, needed for app image.
sudo apt install libfuse2 fuse -y
# downloads NeoVim
sudo curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
sudo chmod 555 nvim.appimage
# add a NeoVim folder in the optional binaries directory
sudo mkdir -p /opt/nvim
# move the app image to the optional binaries directory
sudo mv nvim.appimage /opt/nvim/nvim
# add to .bashrc
export PATH="$PATH:/opt/nvim/"
- Cargo/Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- y
. "$HOME/.cargo/env"
- NodeJS
# installs FNM (Fast Node Manager)
curl -fsSL https://fnm.vercel.app/install | bash
source ~/.bashrc
# download and install Node.js and the Node packages needed.
fnm use --install-if-missing 20
npm install --global yarn
npm install -g neovim
- Python/Pip
sudo apt install -y -q python3 python3-pip python3-venv
pip3 install --user --upgrade neovim --break-system-packages
- C/C++ Compiler
apt install build-essential
- CLI Utilites
sudo apt install ripgrep fd-find xclip zip unzip
- Nerd Font
# Install a font caching library and the font files.
sudo apt install fontconfig
sudo curl -OL "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.zip"
# Enter the fonts folder and add the font files.
cd ~/.local/share/fonts \
&& unzip ~/JetBrainsMono.zip \
&& sudo rm ~/JetBrainsMono.zip \
&& fc-cache -fv && cd $HOME
For LaTeX live viewing to work with VimTex there are a few more dependencies needed.
First is a PDF viewer that will update whenever we write to the file. I use Zathura
for this purpose because it comes with Vim style motions out of the box. You can also customize
Zathura to have the colorscheme of your choice. I am using Catppuccin Mocha.
You can use my configuration for Zathura by moving the zathura folder to ~/.config/zathura
.
- Zathura - Reccomended PDF Viewer
sudo apt install zathura
- latexmk: LaTeX Compiler
sudo apt install texlive-full
- tree-sitter-cli: Allows for better syntax highlighting of LaTeX Documents
cargo install tree-sitter-cli
Plugins and Configuration are setup in their own folders within the lua
directory. Keymaps are
found within keymaps.lua
and Vim options are found in options.lua
. Configuration for each plug-in
can be found within it's respective lua file. More Plugin Information.
Some of the options I have on that you might want to change are:
vim.opt.tabstop = 2 -- <TAB> goes two spaces instead of 4.
vim.opt.ignorecase = true -- Ignore capitalization in searches.
vim.opt.wrap = false -- Don't wrap text if it goes off the line.
vim.opt.number = true -- Show line numbers.
vim.opt.relativenumber = true -- Line numbers relative to cursor position.
All the keymaps are listed under Keymaps. They can also be found within the
keymaps.lua
file, where every keymap for this config is listed with its purpose commented around it.
To add a new keymap, it is the following syntax. In the first option, choose either "n"
, "v"
, or "i"
for executing the command in normal mode, visual mode, or insert mode.
keymap.set("[n, v, i]", "[keys to press]", ":[Vim cmd]<CR>", opts)
My global <leader>
key is set to SPACE.
If you would like to change the <leader>
keymap, it is in the globals.lua
file.
WIP
Keymap | Description |
---|---|
leader>m | Switch cursor to file tree |
leader>f | Toggle file tree |
Keymap | Description |
---|---|
leader>s>v | Split pane vertically |
leader>s>h | Split pane horizontaly |
Ctrl+h | Move a pane left |
Ctrl+j | Move down a pane |
Ctrl+k | Move up a pane |
Ctrl+l | Move a pane right |
Keymap | Description |
---|---|
leader>n | Go to the next buffer |
leader>p | Go to the previous buffer |
leader>d | Delete the current buffer |
leader>o | Open a new empty buffer |
Keymap | Description |
---|---|
ENTER | Autocomplete with the current suggestion |
TAB | Cycle to next auto-complete suggestion |
SHIFT+TAB | Cycle to the previous auto-complete suggestion |
Keymap | Description |
---|---|
leader>f>a | Open Telescope |
leader>f>k | Use Telescope to fuzzy find keybindings |
leader>f>f | Use Telescope to fuzzy find files |
leader>f>g | Use Telescope to fuzzy find using live-grep |
leader>f>b | Use Telescope to fuzzy find buffers |
leader>f>r | Use Telescope to fuzzy find recent files |
Ctrl+c | Close the Telescope window |
Keymap | Description |
---|---|
leader>f>i | Fold ALL code by indent level |
z>a | Unfold current code block |
z>f | Fold current code (in visual mode) |
Keymap | Description |
---|---|
leader>s>s | Save the current session |
leader>s>r | Restore the previous session |
Ctrl+s | Search sessions |
Keymap | Description |
---|---|
leader>l>l | Start continous LaTeX compiler and PDF viewer |
leader>l>c | Clean the current LaTeX directory |
leader>l>e | Close the LaTeX error message window |
leader>l>t | See a table of contents for your document |
]>] | Jump to the next section/subsection |
[>[ | Jump to the previous section/subsection |
Keymap | Description |
---|---|
Shift+k | Shows the global implementation for the item under the cursor in a window |
g>r | Show the global references of the variable the cursor is over with Telescope |
g+i | Brings you to the global implementation of the function the cursor is over |
Keymap | Description |
---|---|
Ctrl+/ | Comment out current line, or highlighted code |
Ctrl+> | Shift highlighted code one indent to the right |
Ctrl+< | Shift highlighted code one indent to the left |
Ctrl+c | Clear the current search phrase |
leader>t>o | Toggle the cursor to stay in the center, and not scroll off |
leader>h>n | Hide line numbers |
leader>s>n | Show line numbers |
leader>s>c | Enable Spell Checking |
More plug-in specific keymaps can be found in the documentation for the plugin, found below.
- Action Hints
- Alpha
- Auto Session
- Auto Pairs
- cmp-Ultisnips
- cmp
- cmp-lsp
- cmp-buffer
- cmp-path
- cmp-cmdline
- Codeium
- Colorizer
- Comment
- Cyberdream
- Highlighted Yank
- hlChunk
- Lazy
- LSP Config
- LSP Progress
- LSP Signature
- LSP Kind
- LuaLine
- Mason LSP Config
- Mason
- Noice
- Nui
- nvim-tree
- nvim-treesitter
- nvim-web-devicons
- Primeppuccin
- Plenary
- Smartcolumn
- Telescope
- TS Autotag
- Ultisnips
- Illuminate
- Vim-Snippets
- VimTex
All configuration for plugins are within their respective lua files. This is accomplished by making the configuration a lua function, and then calling that function for the config option.
An example is shown below with the plugin Colorizer
local config = function()
require ('colorizer').setup {
filetypes = {
'*'; -- Highlight all files.
},
}
end
return {
'NvChad/nvim-colorizer.lua',
lazy = false,
config = config,
}
All of the plugin configuration is done in the following fashion, with a function controlling the configuration, within the plugin's lua file. This makes it easy to find options for each plugin. I use Telescope to search for plugins or keymaps wheenever I want to configure something.
- Alpha
- Auto Session
- Auto Pairs
- Primeppuccin
- CMP
- Codeium
- Colorizer
- Comment
- Highlighted Yank
- hlChunk
- LSP Progress
- Mason/LSP Config
- LuaLine
- Noice
- Nvim-tree
- Nvim-treesitter
- Telescope
- UltiSnips
- Illuminate
- VimTex
Alpha is the greeting screen plugin. Alpha is widely used and is extremely customizable.
The greeting screen is something I have pieced together from other people's setups mixed with some
of my own personal preferences. Alpha will appear whenever you just use the command vim
with no specific file.
I have Alpha setup so that you can update all of your plugins from the greeting screen, with easy access
so there is no memorization of commands needed.
To edit the ASCII art, just copy paste into the area where the current logo is.
All of the buttons on the greeting screen can be customized too. For example, a button is defined as:
dashboard.button("e", " New file", ":ene <BAR> startinsert <CR>")
Where the first argument is the hot-key, the second is the displayed text, and the third is the command to execute.
Currently, I have 9 buttons on the greeting screen. The options are
Keymap | Option | Description |
---|---|---|
f | Find file | Use Telescope to look for files |
g | Find word | Use Telescope to live grep through files |
r | Recent files | Use Telescope to look through recent files |
l | Lazy | Open Lazy plugin manager |
m | Mason | Open Mason LSP package manager |
u | Update Plugins | Update plugins through the Lazy plugin manager |
p | Update Parsers | Update all the tree-sitter parsers |
h | Check Health | Use the :checkhealth command to check dependencies |
q | Quit NVIM | Close NeoVim |
Auto Pairs is a quality of life plugin that will pair together parenthesis, brackets, quotes, etc. It also auto moves the cursor to the right if you press a keystroke for a paired character. The reason this plugin is used is because it can be configured to auto-pair for LaTeX as well. This means that the '$' symbol is paired in only tex documents with the same functionality as other characters. I also have a plugin called TS Autotag that will automatically close HTML tags as well.
Auto Session is a quality of life plugin that lets you save all of your current windows and then restore them the next time you use NeoVim. Auto Session also auto-saves your session while you are working if you forget to save a session. Sessions are saved with their name being the current working directory.
There are a few keybinds associated with auto session that can be found here. When you are searching through sessions, here are a couple more keybinds to be aware of.
Keymap | Description |
---|---|
Ctrl+d | Delete the highlighted session |
Ctrl+s | Restore the previous session |
ENTER | Restore the highlighted session |
TAB | Highlight the next session in the list |
SHIFT+TAB | Highlight the previous session in the list |
Primeppuccin is the theme being used. There is some configuration that goes into the theme, like choosing whether you want the background to be transparent or not. I have also turned on integrations for other plugins being used in the configuration. Primeppuccin is just a slight variation of Catppuccin Mocha. All of the colors are slightly muted/dulled to make it easier on my eyes. Using Catppuccin based themes is fantastic as there is support for just about any software that has a customizable color theme.
Codeium is the AI auto-completion plugin being used in this configuration.
It is free and integrates with nvim-cmp to provide suggestions while you're coding.
You'll know it's an AI suggestion as it will label the suggestion with Codeium.
To get started with Codeium, use :Codeium Auth
to link an api key and start using
their service for free. It's slightly buggy right now as I'm still int the process
of integrating it fully into the configuration.
CMP is the auto-completion plugin being used. It uses another plugin to connect it to the native NeoVim LSPs for LSP auto completion, as well as snippet completion through UltiSnips. The combination of autocompletion from Language Servers and Snippets is extremely powerful.
It also provides auto completion for commands within Vim. When typing a command with ':' it will provide auto-completion suggestions just like when typing normally. It also will suggest different file paths for commands as well. For example, typing ':e' will give auto-completion suggestions for different files to edit.
To add new Language auto-completion see the Mason section.
Colorizer highlights color-codes with the color they are representing. Hexcodes, names, RGB values, etc. will be highlighted with its own color. A simple quality of life plugin.
Comment is used to group together and comment out code. The keymaps for this plugin
are set within the comment.lua
file because they access the plugin's api. Currently,
commenting out the current line (in normal mode) and commenting out the highlighted lines in visual mode
are both set to Ctrl+/.
Highlighted Yank does exactly what the name states. It is a simple quality of life plugin that shows exactly what you just copied to the clipboard. It highlights the copied text to show you exactly what was copied. Something I would expect in any modern IDE.
hlChunk will help with highlighting the current block of code.
hlchunk has 4 mini mods but I have two active in this configuration. The first mod is called chunk, which draws an arrow around the code chunk youre working on. I have the color set to gray so it isn't as distracting. An example of the arrow is shown below. As the cursor moves into a further nested code chunk, the arrow will move as well.
The second mini mod is called line_num, and it highlights the line numbers for the block of code being worked in. This causes the numbers on the left to become a blueish color to help navigate the code easier as well. You can see how the numbers adjust with cursor movement in the example above.
LSP Progress Shows the current LSP being used in the status line. This helps if there is a need for different LSPs with the same file extension. It also shows the progress of the LSP being loaded, if you have a large project.
In this photo you can see I'm using the Marksman LSP for creating a markdown file.
Mason Is the LSP Package manager being used for the configuration.
It allows for easy installation of new LSPs and easy Updating for current ones.
To check what LSPs are installed, or to check for updates, use the :Mason
command. There is also access
to the Mason UI through the Alpha greeting screen.
Currently, I am using 10 LSPs for different languages. They are:
- bashls, for bash
- clangd, for c/c++
- jedi_language_server, for python (sometimes I use pyright as well)
- lua_ls, for lua
- marksman, for markdown
- texlab, for LaTex/bibTeX
- rust_analyzer, for rust
- tsserver, for JS/TS
- cssls, for css
- html, for html
To add new LSPs to the configuration, there are several steps.
The first is to open the Mason UI and download the appropriate LSP. Then open the
lspconfig.lua
file. There will be a configuration function that requires the setup
of all of the other pre-installed LSPs. To add the new one, add another line to the config using the following template,
replacing the LSP_NAME with the one installed.
require("lspconfig").LSP_NAME.setup{ on_attach = on_attach, capabilities = capabilities, }
This will setup the LSP with the correct keybindings and auto-completion abilities.
LuaLine helps by giving you information on your NeoVim session. It gives information like the filetype, your git status, the files you have edited, OS, and more. Most NeoVim 'themes' come with a LuaLine theme as well. I use Cyberdream for my LuaLine theme, however, you can find more themes from LuaLine here
To change the theme, locate this code in the config and change the value for theme
require('lualine').setup {
options = {
theme = cyberdream,
globalstatus = true
},
}
The rest of the LuaLine configuration is quite complicated, but it is setup to give lots of information on the current session, with custom icons. To learn more about customizing LuaLine, see their documentation.
The current LuaLine setup has: Buffers, Mode, CoC Diagnostics, git branch, modifications to the file, the time and date, OS, and file-format. I have the buffers in present in the at the top left where you would normally see tabs in an application.
And the Buffers are in the tab line
Noice makes things look, well, noice. It centers your command line and makes things look a lot better in general. I have disabled the notifications that Noice can provide. To enable them, you need a seperate plugin in the dependencies. However, getting notifications for writing to a file, executing commands, etc, is not something I was looking for.
Nvim-tree gives you a file explorer on the left side of the screen. With web-dev-icons the file explorer will also display icon types for each type of file, as well as git status.
It has a couple of configuration settings you might want to change, for example
view = {
width = 25, -- Changes the width of the window
},
renderer = {
group_empty = true, -- Will show folders even if they are empty
},
filters = {
dotfiles = false, -- Will not filter out dot files ('.bashrc', '.config', etc.)
},
Nvim-treesitter gives better syntax highlighting for languages.
I disabled highlighting for LaTeX and BibTex because I was getting errors for the highlighting in LaTeX documents.
I have a list of languages that are installed automatically within the config. To add a new
language you can add it to the list shown below. All of the language servers can be updated on the Greeting screen or
by using :TSUpdate
.
ensure_installed = {
"c",
"cpp",
"latex",
"bibtex",
"rust",
"html",
"css",
"javascript",
"python",
"bash", -- Needed for Noice
"markdown", -- Needed for Noice
"lua", -- Needed for Noice
"markdown_inline", -- Needed for Noice
"regex", -- Needed for Noice
"vim", -- Needed for Noice
},
To remove a language, first remove it from the list above and then run the command :TSUninstall [language]
.
Telescope is the ultimate fuzzy finder for NeoVim. It integrates with Plenary to give you a fuzzy finder with a file previewer right in NeoVim.
Keymaps for when the Telescope window is open | Description |
---|---|
ENTER | Open the selected file |
Ctrl+j | Move down a selection in the menu |
Ctrl+k | Move up a selection in the menu |
SHIFT+TAB | Move down a selection in the menu |
TAB | Move up a selection in the menu |
ESC | Exit the Telescope menu |
Other keymaps for opening different Telescope windows can be found here
I am using UltiSnips for snippet completion. All of my personal snippets are in the UltiSnips folder. Currently, I only have snippets that I use for LaTeX. Most of the snippets I am using can be found here.
To add more snippets for LaTeX, find the tex.snippet
file within the Ultisnips directory
and add another snippet. To add another snippet for a
different language, add a new file to the Ultisnips directory that has the file extension for
the language as the title of the file, with a '.snippets' extension.
The other snippets I have downloaded are from Vim-Snippets.
Illuminate is another quality of life plugin. It highlights all occurrances of the word that your cursor is currently on. It is especially useful for looking at variable names or object types.
VimTex is the perfect plugin for anyone wanting to edit LaTeX files in NeoVim. It allows for
continuous compiling of a '.tex' document. In my configuration, <leader>ll
starts the continuous
compiler and viewer.
When compiling, the LaTeX compiler creates some junk files that can be cleaned up with <leader>lc
as well.
The only configuration I have added in for VimTex is a command in the config to enable expression concealling. To disable it, delete or comment out the following lines from the config.
init = function()
vim.cmd[[set conceallevel=2]]
vim.cmd[[let g:tex_conceal='abdmg']]
end,
VimTex comes with a ton of keybinds beyond the ones I covered in this guide, back in the LaTeX
section of the Keymaps. To explore more of them, check out the VimTex documentation, or :h VimTex
.