12 KiB
Haelnorr's NeoVim config
This is a list of all the plugins I use and what they do, along with some documentation on keybinds and other usage.
Contents
Plugins
Plugins are managed using lazy.nvim
- Aerial
- Comment
- Conform
- Feline
- Fugitive
- Gitsigns
- Harpoon
- Markdown Preview
- NVIM Web Devicons
- Oil
- Refactoring
- SUDA
- Surround
- Telescope
- TMUXNav
- TODO Comments
- Treesitter
- Trouble
- Undotree
- Vim be good
- Vim Dadbod UI
Aerial
A code outline window for skimming and quick navigation
| Keybind | Functionality | Mode |
|---|---|---|
<leader>pa |
Toggle Aerial outline for current window | Normal |
{ |
Cycle previous item | Inside Aerial |
} |
Cycle next item | Inside Aerial |
Comment
Smart and powerful commenting plugin for NeoVim
| Keybind | Functionality | Mode |
|---|---|---|
gcc |
Toggles comment on current line using linewise comment | Normal |
gbc |
Toggles comment on current line using blockwise comment | Normal |
[count]gcc |
Toggles the number of line given as a prefix-count using linewise | Normal |
[count]gbc |
Toggles the number of line given as a prefix-count using blockwise | Normal |
gc[count]{motion} |
(Op-pending) Toggles the region using linewise comment | Normal |
gb[count]{motion} |
(Op-pending) Toggles the region using blockwise comment | Normal |
gc |
Toggles region using linewise comment | Visual |
gb |
Toggles region using blockwise comment | Visual |
gco |
Insert comment to next line and enter insert mode | Normal |
gcO |
Insert comment to previous line and enter insert mode | Normal |
gcA |
Insert comment to end of the current line and enter insert mode | Normal |
Conform
Lightweight yet powerful formatter plugin
| Keybind | Functionality | Mode |
|---|---|---|
<leader>f |
Formats entire file | Normal |
<leader>f |
Formats selection | Visual + Select |
Feline
Customizable status line
Fugitive
Git integration
| Keybind | Functionality | Mode |
|---|---|---|
<leader>gs |
Opens fugitive window | Normal |
gu |
<cmd>diffget //2<CR> |
Normal |
gh |
<cmd>diffget //3<CR> |
Normal |
a |
Stage highlighted file | (inside fugitive) |
<leader>s |
:Git add -A |
(inside fugitive) |
<leader>c |
:Git commit |
(inside fugitive) |
<leader>p |
:Git push |
(inside fugitive) |
<leader>P |
:Git pull --rebase |
(inside fugitive) |
<leader>t |
:Git push -u origin <opts> |
(inside fugitive) |
Gitsigns
Customizable git diff decorators
Harpoon
Quick swap between files
| Keybind | Functionality | Mode |
|---|---|---|
<leader>a |
Add current file | Normal |
Alt + e |
Toggle quick menu | Normal |
Alt + h |
Swap to file 1 | Normal |
Alt + j |
Swap to file 2 | Normal |
Alt + k |
Swap to file 3 | Normal |
Alt + l |
Swap to file 4 | Normal |
<leader> Alt + h |
Replace file 1 with current file | Normal |
<leader> Alt + j |
Replace file 2 with current file | Normal |
<leader> Alt + k |
Replace file 3 with current file | Normal |
<leader> Alt + l |
Replace file 4 with current file | Normal |
Markdown Preview
Live preview of markdown files in browser, with synced scrolling
Usage:
:MarkdownPreview - Opens preview window in new tab of browser
NVIM Web Devicons
Provides Nerd font icons for other plugins to use
Oil
Edit/view your filesystem like a normal NeoVim buffer
Refactoring
Quickly refactor variables and functions
| Keybind | Functionality | Mode |
|---|---|---|
<leader>re |
Extract selection to new function | Visual, Select |
<leader>rf |
Extract selection to new file | Visual, Select |
<leader>rv |
Extract selection to new variable | Visual, Select |
<leader>ri |
Inline variation | Normal, Visual, Select |
<leader>rI |
Inline function | Normal |
<leader>rb |
Extract current block | Normal |
<leader>rbf |
Extract current block to file | Normal |
SUDA
Write files using sudo inside NeoVim
Usage:
:SudaRead - Reread current file using sudo
:SudaWrite - Write current file using sudo
Surround
Add delete or remove surrounding pairs with Vim shortcuts
Usage:
The three "core" operations of add/delete/change can be done with the keymaps
ys{motion}{char}, ds{char}, and cs{target}{replacement}, respectively.
For the following examples, * will denote the cursor position:
Old text Command New text
--------------------------------------------------------------------------------
surr*ound_words ysiw) (surround_words)
*make strings ys$" "make strings"
[delete ar*ound me!] ds] delete around me!
remove <b>HTML t*ags</b> dst remove HTML tags
'change quot*es' cs'" "change quotes"
<b>or tag* types</b> csth1<CR> <h1>or tag types</h1>
delete(functi*on calls) dsf function calls
Telescope
Extensible fuzzy finder for NeoVim
| Keybind | Functionality | Mode |
|---|---|---|
<leader>pf |
Find files | Normal |
Ctrl + p |
Find git files | Normal |
<leader>pws |
Search files for <cword> (word the cursor is on) |
Normal |
<leader>pWs |
Search files for <cWORD> (WORD the cursor is on) |
Normal |
<leader>ps |
Search files with grep | Normal |
<leader>vh |
Search builtin documentation | Normal |
TMUXNav
Integrated commands for navigating between tmux panes
| Keybind | Functionality | Mode |
|---|---|---|
Ctrl + h |
Navigate left | Normal |
Ctrl + j |
Navigate down | Normal |
Ctrl + k |
Navigate up | Normal |
Ctrl + l |
Navigate right | Normal |
Ctrl + \ |
Navigate previous | Normal |
TODO Comments
Decorate code with comment highlighting
Usage:
KEYWORD: comment
e.g. in Python:
(NOTE: the highlighting wont appear in the code snippet below)
## List of available keywords
# TODO: this needs implementing
# HACK: hmmm, this looks a bit funky
# WARN: probably want to fix this soon
# PERF: perfectly optimised
# NOTE: this is a clever use of an example :)
# TEST: just making sure
:TodoTelescope - search project todos with Telescope
<leader>ts will enter :TodoTelescope cwd= into the nvim command line. Can
leave blank for default functionality, or enter a directory to restrict the
search to.
Treesitter
Syntax highlighting, the best way
Trouble
Error diagnostics
| Keybind | Functionality | Mode |
|---|---|---|
<leader>tt |
Toggle diagnostics tab | Normal |
<leader>tq |
Toggle quickfix list | Normal |
Undotree
Undotree for NeoVim
| Keybind | Functionality | Mode |
|---|---|---|
<leader>u |
Open undotree | Normal |
Vim be good
Games for praciticing Vim motions
Usage:
:VimBeGood
Vim Dadbod UI
Simple UI for Vim-dadbod. Allows for navigation through databases and saving queries.
Usage:
:DBUI
Language Server
NVIM-LSPConfig
LSP has been setup with the following dependencies:
- williamboman/mason.nvim
- williamboman/mason-lspconfig.nvim
- hrsh7th/cmp-nvim-lsp
- hrsh7th/cmp-buffer
- hrsh7th/cmp-path
- hrsh7th/cmp-cmdline
- hrsh7th/nvim-cmp
- L3MON4D3/LuaSnip
- saadparwaiz1/cmp_luasnip
- j-hui/fidget.nvim
Language servers configured in ensure_installed:
- lua_ls
- bashls
- css_variables
- cssls
- cssmodules_ls
- docker_compose_language_service
- dockerls
- html
- jsonls
- pyright
- ts_ls
LuaSnip has been configured with the following dependencies:
- rafamadriz/friendly-snippets
- benfowler/telescope-luasnip.nvim
Run :Telescope luasnip to search the loaded snippets
| Keybind | Functionality | Mode |
|---|---|---|
Ctrl + p |
auto-complete select prev item | Normal |
Ctrl + n |
auto-complete select next item | Normal |
Ctrl + y |
auto-complete confirm selected item | Normal |
Ctrl + space |
invoke auto-complete | Normal |
Enter |
Confirm the selected auto-complete/snippet (excluding preselect), otherwise CR | Normal |
gd |
jumps to the definition of the symbol under the cursor | Normal |
K |
displays hover information about the symbol under the cursor | Normal |
<leader>vws |
lists all symbols in the current workspace matching {query} | Normal |
<leader>vd |
show diagnostics in a floating window | Normal |
<leader>vca |
selects a code action available at the current cursor (?) | Normal |
<leader>vrr |
lists all references to the symbol under the cursor | Normal |
<leader>vrn |
rename all references to the symbol under the cursor | Normal |
Ctrl + h |
displays signature information about the symbol under the cursor | Insert |
[d |
next diagnostic | Normal |
]d |
prev diagnostic | Normal |
Keymappings
Leader key: <Space>
| Keybind | Behaviour | Normal | Visual | Select |
|---|---|---|---|---|
- |
View parent directory (works in file and in Oil filetree viewer) | ✓ | ✗ | ✗ |
J |
Move selection down and autoindent | ✗ | ✓ | ✓ |
K |
Move selection up and autoindent | ✗ | ✓ | ✓ |
J |
Moves line below current line into sameline | ✓ | ✗ | ✗ |
Ctrl + d |
Jump down page, keeping cursor centered (zz) | ✓ | ✗ | ✗ |
Ctrl + u |
Jump up page, keeping cursor centered (zz) | ✓ | ✗ | ✗ |
n |
(in search) Next item, keeping cursor centered | ✓ | ✗ | ✗ |
N |
(in search) Prev item, keeping cursor centered | ✓ | ✗ | ✗ |
<leader>p |
Replaces selection with buffer without overriding buffer | ✗ | ✓ | ✗ |
<leader>y |
Yanks selection to system clipboard | ✓ | ✓ | ✓ |
<leader>Y |
Yanks line to system clipboard | ✓ | ✗ | ✗ |
<leader>d |
Deletes without replacing buffer, can be used with dd to delete line | ✓ | ✓ | ✓ |
Ctrl + k |
Quickfix next | ✓ | ✗ | ✗ |
Ctrl + j |
Quickfix prev | ✓ | ✗ | ✗ |
<leader>k |
QF Location next | ✓ | ✗ | ✗ |
<leader>j |
QF Location prev | ✓ | ✗ | ✗ |
<leader>s |
search in file for symbol under cursor, and refactor | ✓ | ✗ | ✗ |
<leader>x |
make file executable | ✓ | ✗ | ✗ |
<leader>o |
Add new line below current line | ✓ | ✗ | ✗ |
Ctrl + Q |
Toggle page right divider (colorcolumn) | ✓ | ✗ | ✗ |