A zero-plugin Neovim configuration derived from my main setup to git good at native Vim/Neovim features without relying on plugins. Despite its simplicity, this config is still completely usable for day-to-day editing ;)
Note
There are no plans to add plugins, only auto commands or custom commands where they make sense.
-
Language Servers (LSP):
These must be installed via your system package manager (e.g.
pacmanon Arch,brewon macOS, etc.).-
The LSPs I personally use are defined in the
lspdirectory. -
To add another server:
- Create a file under
lsp/named<lsp_name>.lua. - Add the lsp configurations to the file.
- In
lua/config/lsp.lua, add your server to the Enable LSPs section:
vim.lsp.enable({ ..., "<lsp_name>", })
- Create a file under
-
Tip
- Use
:checkhealth vim.lspto view LSPs attached to the current buffer or any LSP related issues. - Available LSPs: https://microsoft.github.io/language-server-protocol/implementors/servers/
- Example configurations: https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
-
Glow: for Markdown previewing.Install it separately using your system’s package manager.
If you want to fully switch to this setup, clone it into your Neovim configuration directory:
git clone https://github.com/TheKangChen/nvim0.git ~/.config/nvimImportant
If you already have an existing Neovim config, back it up first:
mv ~/.config/nvim ~/.config/nvim_backupThen, launch Neovim:
nvimYou can load this config under a different directory using Neovim’s NVIM_APPNAME environment variable.
git clone https://github.com/TheKangChen/nvim0.git ~/.config/nvim-zeroThen start Neovim with:
NVIM_APPNAME=nvim-zero nvimTip
You can create an alias in your bashrc or zshrc file to avoid typing all of this every time.
Neovim will treat ~/.config/nvim-zero as its config directory, keeping your main ~/.config/nvim untouched.
To update configuration to latest version run this command inside the config directory (~/.config/nvim or ~/.config/nvim-zero):
git pullFor general Vim help, use:
:helpto open documentation:Tutorfor a 30-minute interactive Vim tutorial
See lua/config/options.lua for all configuration options, or run :opt.
For the full range of features provided by Neovim’s built-in LSP, such as go-to definition, hover documentation, references, and more, use the :map command to see all available key bindings.
Completions rely entirely on Neovim’s built-in LSP client. They should appear automatically as you type. If not, try:
<Ctrl-X><Ctrl-O>for omni-completion<Ctrl-N>to cycle through completions if available
Tip
See :help i_CTRL-X for more about completion sub-modes.
Use the gra keymap (in normal mode) to view and trigger available LSP code actions.
Use z= (in normal mode) to view spelling suggestions for the word under the cursor.
Here's a list of custom key mappings. To view all active mappings, use :map.
| Key Map | Description | Key Map | Description |
|---|---|---|---|
<Space>qq |
Write & quit all buffer | <Space>o |
Open file in explorer |
<Space>- |
Window horizontal split | <Space>_ |
Open alt file in split |
<Space>\ |
Window vertical split | <Space>| |
Open alt file in vertical split |
<Space>bn |
Next buffer | <Space>bp |
Previous buffer |
<Space>bb |
Switch to alternate file | <Space>mm |
Open Explorer (Netrw) |
<Space>ff |
Find file | <Space>rc |
Edit config file |
<Space>tr |
Switch to regular theme | <Space> |
Switch to alternative theme |
<Space>z |
Toggle center cursor | <Space>p |
Preview markdown in vertical split |
<Space>e |
Preview diagnostic in float | <Space>dl |
Show all diagnostics in location list |
<Space>dx |
Toggle diagnostics virtual text | <Space>sS |
Save session (global) |
<Space>ss |
Save session (local) | <Space>sl |
Load saved session |
<Space>T |
Toggle floating terminal | <ESC> |
Close floating terminal |
K |
LSP hover documentation | gh |
LSP Signature documentation |
gD |
Go to declaration | gd |
Go to definition |
gra |
LSP code action | grn |
Rename all references |
grr |
LSP references | gri |
LSP implementation |
grt |
LSP type definition | <Space>cf |
Format buffer |
<Ctrl-x><Ctrl-o> |
Omni completion | <Space>v |
Go to definition in vertical split |
<Space>wa |
Add workspace folder | <Space>wr |
Remove workspace folder |
<Space>wl |
List workspace folders | <Ctrl-q> |
Toggle quickfix window |
<Space>a |
Add current file to quickfix | <Space>1...9 |
Go to file #n on quickfix |
<Ctrl-k> |
Focus window top | <Ctrl-j> |
Focus window below |
<Ctrl-h> |
Focus window left | <Ctrl-l> |
Focus window right |
<Alt-d> |
Delete without yanking | <Alt-c> |
Change without yanking |
<Alt-j> |
Move line down | <Alt-k> |
Move line up |
<Alt-h> |
Unindent line | <Alt-l> |
Indent line |
Note
To change key bindings, go to lua/config/keymaps.lua and to change LSP related key bindings, go to lua/config/lsp.lua.
The base configuration is intentionally minimal, but I may add or refine keymaps, autocmds, default options, etc. as I continue to use this setup.
- Remove the floating terminal (keymap
<leader>T). I mainly usetmux, so it’s not particularly useful. Keeping it for now just in case. - Add custom statusline
- Auto commands highlighting tasks (e.g.
TODO,BUG,FIX,INFO, etc.)