Neovim configuration¶
Files¶
The file .config/nvim/init.lua
is the entry point of the nvim config.
Unless otherwise specified, paths on this page are relative to
~/.config/nvim
.
~/.config/nvim/init.lua
has general settings.~/.config/nvim/lua/plugins.lua
has plugin settings.
The .vimrc
file has only basic setup for vim, in case you need to use
/usr/bin/vim
.
Note
See Migrating to Neovim Lua config and Why Lua if you’re coming here from using older versions of these dotfiles.
Screencasts¶
Added in version 2024-03-31.
Sometimes it’s much easier to see what’s going on than to read about it…
screencast of lazy.nvim setting up plugins
See Plugins for more details.
screencast of switching buffers
See Switching buffers for more; this uses bufferline.nvim for the tabs, nvim-tree for the file tree, and telescope for the fuzzy-finder.
Using the mouse¶
In addition to allowing clicking and scrolling, set mouse=a
also:
Supports mouse-enabled motions. To try this, left-click to place the cursor. Type y then left-click to yank from current cursor to where you next clicked.
Drag the status-line or vertical separator to resize
Double-click to select word; triple-click for line
Non-printing characters¶
Non-printing characters (tab characters and trailing spaces) are displayed. Differentiating between tabs and spaces is extremely helpful in tricky debugging situations.
~/.config/nvim/init.lua
has these lines:
vim.cmd(":autocmd InsertEnter * set listchars=tab:>•")
vim.cmd(":autocmd InsertLeave * set listchars=tab:>•,trail:∙,nbsp:•,extends:⟩,precedes:⟨")
With these settings <TAB> characters look like >••••
. Trailing spaces show up
as dots like ∙∙∙∙∙
.
The autocmds here mean that we only show the trailing spaces when we’re outside of insert mode, so that every space typed doesn’t show up as trailing. When wrap is off, the characters for “extends” and “precedes” indicate that there’s text offscreen.
Switching buffers¶
Added in version 2023-11-01: <leader>b using bufferline plugin
Three main ways of opening file in a new buffer:
command |
description |
---|---|
:e <filename> |
Open filename in new buffer |
<leader>ff |
Search for file in directory to open in new buffer (Telescope) |
<leader>fb |
Toggle file browser, hit Enter on file (nvim-tree) |
See nvim-tree for more on navigating the file tree shown by <leader>fb.
Once you have multiple buffers, you can switch between them in these ways:
command |
description |
---|---|
[b, ]b |
Prev and next buffers |
H, L |
Prev buffer, next buffer |
<leader>1, <leader>2 |
First buffer, last buffer |
<leader>b then type highlighted letter in tab |
Switch buffer |
The display of the bufferline is configured in lua/plugins.lua
, as part
of the bufferline plugin. It is additionally styled using the
zenburn.nvim plugin/colorscheme.
Format options explanation¶
The following options change the behavior of various formatting; see :h formatoptions
:
vim.cmd("set formatoptions=qrn1coj")
Explanation of these options:
q: gq also formats comments
r: insert comment leader after <Enter> in insert mode
n: recognize numbered lists
1: don’t break a line after a 1-letter word
c: autoformat comments
o: automatically insert comment leader afer ‘o’ or ‘O’ in Normal mode.
Use Ctrl-u to quickly delete it if you didn’t want it.
j: where it makes sense, remove a comment leader when joining lines
Spell check¶
In case you’re not aware, vim has built-in spellcheck.
command |
description |
---|---|
|
Enable spell check |
]s |
Next spelling error |
[s |
Previous spelling error |
z= |
Show spelling suggestions |
Shortcuts¶
Changed in version 2024-01-21: Added <leader>p for pasting formatted Markdown/ReST links
Changed in version 2024-03-31: Added <leader>cp for a convenient “copy mode”
Here are some general shortcuts that are defined in the included config. With
the which-key
plugin, many of these are also discoverable by hitting the
first key and then waiting a second for the menu to pop up.
Note
Mappings that use a plugin are configured in the lua/plugins.lua
file and are described below under the respective plugin’s section.
If you’re definign your own keymappings, add a desc
argument so that
which-key will provide a description for it.
command |
description |
---|---|
, |
Remapped leader. Below, when you see <leader> it means ,. |
<leader>r |
Toggle relative line numbering (makes it easier to jump around lines with motion operators). |
<leader>H |
Toggle highlighted search. Sometimes it’s distracting to have all the highlights stick around. |
<leader>W |
Remove all trailing spaces in the file. Useful when cleaning up code to commit. |
<leader>R |
Refresh syntax highlighting. Useful when syntax highlighting gets wonky. |
@l |
Macro to surround the line with quotes and add a trailing comma. Useful for making Python or R lists out of pasted text |
<leader>- |
Fills in the rest of the line with “-”, out to column 80. Useful for making section separators. |
<leader><TAB> |
Useful for working with TSVs. Starts the command |
<leader>` |
(that’s a backtick) Adds a new RMarkdown chunk and places the cursor inside it |
<leader>ry |
Used for RMarkdown; writes commonly-used YAML front matter (mnemonic: rmarkdown yaml) |
<leader>ko |
Used for RMarkdown; writes an RMarkdown chunk with commonly-used knitr global options (mnemonic: knitr options) |
<leader>d |
Insert the current date as a ReST or Markdown-formatted title, depending on the file type. Useful when writing logs. |
<leader>p |
Paste the contents of the OS clipboard into a formatted link as appropriate for the file type (ReST and Markdown currently supported) and puts the cursor in the link description. Note that this will not work to paste to vim on a remote server, unless you do tricky things with X forwarding, so consider it local-only. |
<leader>cp |
Toggle a sort of “copy mode”. Turns off line numbers and the vertical indentation lines from indent-blankline, so you can more easily copy text into another app. |
Plugins¶
The plugins configured in lua/plugins.lua
have lots and lots of
options. Here I’m only highlighting the options I use the most, but definitely
check out each homepage to see all the other weird and wonderful ways they can
be used.
Plugins are now configured using lazy.nvim. This supports lazy-loading of plugins to keep a snappy startup time, and only load plugins when they’re needed. See Migrating to Neovim Lua config for my rationale on that.
Each plugin spec in lua/plugins.lua
is a table. The first property is
the name of the plugin. Other properties:
lazy
: only load when requested by something else. Saves on initial load time, but use this with care since it can get confusing.ft
: only load the plugin when editing this filetype. Implies lazy=true.cmd
: only load the plugin when first running this command. Implies lazy=true.keys
: only load the plugin when using these keymappings. Implies lazy=true.config
: run this stuff after the plugin loads. If config = true, just run the default setup for the plugin.init
: similar to config, but used for pure-vim plugins
If keys are specified, this is the only place they need to be mapped, and they
will make their way into the which-key menu even if they trigger a lazy-loaded
plugin. Use the desc
argument to give which-key a description to use.
Here, plugins are sorted roughly so that the ones that provide additional commands come first.
Note
Don’t like a plugin? Find it in lua/plugins.lua
and add enabled
= false
next to where the plugin is named. For example:
-- ... other stuff
{ "user/plugin-name", enabled = false },
-- ... more stuff
Or delete it, or comment it out.
The vim config has changed over the years. Depending on when you last updated, there may be plugins added or removed or changed in some way. This table keeps track of what has changed recently.
plugin |
date added |
date changed |
---|---|---|
2016 |
||
2017 |
||
2018-09-26 |
||
2019-02-27 |
||
2019-03-27 |
||
2019-09-30 |
||
2021-02-14 |
||
2021-02-14 |
||
2022-12-27 |
2024-03-31 |
|
2022-12-27 |
||
2023-10-10 |
||
2023-10-11 |
||
2023-10-15 |
||
2023-10-15 |
2023-11-07 |
|
2023-10-15 |
||
2023-10-15 |
||
2023-10-15 |
||
2023-10-15 |
||
2023-10-15 |
||
2023-10-15 |
||
2023-10-15 |
||
2023-10-15 |
||
2023-11-01 |
||
2023-11-01 |
||
2023-11-01 |
||
2023-11-01 |
2024-03-31 |
|
2023-11-01 |
||
2023-11-01 |
||
2024-03-31 |
||
2024-03-31 |
||
2024-04-27 |
||
2024-04-27 |
Sometimes there are better plugins for a particular functionality. I’ve kept the documentation, but noted when they’ve been deprecated here and in the linked description.
plugin |
date added |
deprecated |
---|---|---|
2022-12-27 |
deprecated 2024-03-31 in favor of flash |
|
2019-02-27 |
deprecated 2023-11-14 in favor of treesitter |
|
2019-02-2 |
deprecated 2023-11-14 in favor of treesitter |
|
2019-02-27 |
deprecated 2023-11-14 in favor of treesitter |
vim-commentary
¶
Added in version 2023-10-15.
vim-commentary lets you easily toggle comments on lines or blocks of code.
command |
description |
---|---|
gc on a visual selection |
toggle comment |
gcc on a single line |
toggle comment |
beacon
¶
Added in version 2023-10-15.
Changed in version 2023-11-07: Only commands below will trigger the beacon
Beacon provides an animated marker to show where the cursor is.
command |
description |
---|---|
KJ (hold shift and tap kj) |
Flash beacon |
n or N after search |
Flash beacon at search hit |
telescope
¶
Added in version 2023-10-15.
Telescope opens a floating window with fuzzy-search selection.
Type in the text box to filter the list. Hit enter to select (and open the selected file in a new buffer). Hit Esc twice to exit.
command |
description |
---|---|
<leader>ff |
Find files under this directory. Handy alternative to |
<leader>fg |
Search directory for string. This is like using ripgrep, but in vim. Selecting entry takes you right to the line. |
<leader>/ |
Fuzzy find within buffer |
<leader>fc |
Find code object |
<leader>fo |
Find recently-opened files |
Other useful things you can do with Telescope:
:Telescope highlights
to see the currently set highlights for the colorscheme.:Telescope builtin
to see a picker of all the built-in pickers. Selecting one opens that picker. Very meta. But also very interesting for poking around to see what’s configured.:Telescope planets
to use a telescope:Telescope autocommands
,:Telescope commands
,:Telescope vim_options
,:Telescope man_pages
are some other built-in pickers that are interesting to browse through.
nvim-tree
¶
Added in version 2023-10-10.
nvim-tree is a file browser.
command |
description |
---|---|
<leader>fb |
Toggle file browser |
- (within browser) |
Go up a directory |
Enter (within browser) |
Open file or directory, or close directory |
The window-switching shortcuts <leader>w and <leader>q (move to windows left and right respectively) also work
which-key
¶
Added in version 2023-10-15.
which-key displays a popup with possible key bindings of the command you started typing. This is wonderful for discovering commands you didn’t know about, or have forgotten.
The window will appear 1 second after pressing a key (this is configured with
vim.o.timeoutlen
, e.g. vim.o.timeoutlen=500
for half a sectond). There
is no timeout though for registers ("
) or marks ('
) or spelling (z=
over a word).
You can hit a displayed key to execute the command, or if it’s a multi-key
command (typically indicated with a +prefix
to show there’s more), then
that will take you to the next menu.
Use <Backspace> to back out a menu. In fact, pressing any key, waiting for the menu, and then hitting backspace will give a list of all the default mapped keys in vim.
There is currently no extra configuration. Instead, when a key is mapped
(either in lua/mappings.lua
or lua/plugins.lua
), an
additional parameter desc = "description of mapping"
is included. This
allows which-key to show a description. Mappings with no descriptions will
still be shown.
-- example mapping using vim.keymap.set, with description
vim.keymap.set('n', '<leader>1', ':bfirst<CR>',
{ desc = "First buffer" })
-- example mapping when inside a plugin spec
{ "plugin/plugin-name",
keys = {
{ "<leader>1", ":bfirst<CR>", desc = "First buffer" },
}
}
command |
description |
---|---|
any |
after 1 second, shows a popup menu |
<Backspace> |
Goes back a menu |
z= (over a word) |
Show popup with spelling suggestions, use indicated character to select |
' |
Show popup with list of marks |
" |
Show popup with list of registers |
accelerated-jk
¶
Added in version 2023-10-15.
accelerated-jk speeds up j and k movements: longer presses will jump more and more lines.
Configured in lua/plugins.lua
. In particular, you might want to tune
the acceleration curve depending on your system’s keyboard repeat rate settings
– see that file for an explanation of how to tweak.
command |
description |
---|---|
j, k |
Keep holding for increasing vertical scroll speed |
nvim-cmp
¶
Added in version 2023-10-15.
nvim-cmp provides tab-completion.
By default, this would show a tab completion window on every keypress, which to me is annoying and distracting. So this is configured to only show up when I hit <Tab>.
Hit <Tab> to initiate. Hit <Tab> until you like what you see. Then hit Enter. Arrow keys work to select, too.
Snippets are configured as well. If you hit Enter to complete a snippet, you can then use <Tab> and <S-Tab> to move between the placeholders to fill them in.
command |
description |
---|---|
<Tab> |
Tab completion |
aerial
¶
Added in version 2023-10-15.
aerial provides a navigation sidebar for quickly moving around code (for example, jumping to functions or classes or methods). For markdown or ReStructured Text, it acts like a table of contents.
command |
description |
---|---|
<leader>a |
Toggle aerial sidebar |
{ and } |
Jump to prev or next item (function, snakemake rule, markdown section) |
For navigating complex codebases, there are other keys that are automatically mapped, which you can read about in the README for aerial.
treesitter
¶
Added in version 2023-10-15.
treesitter is a parsing library. You install a parser for a language, and it figures out which tokens are functions, classes, variables, modules, etc. Then it’s up to other plugins to do something with that. For example, colorschemes can use that information, or you can select text based on its semantic meaning within the programming language.
In ~/.config/lua/plugins.lua
, treesitter is configured to ensure the
listed parsers are installed. These will be attempted to be installed
automatically, but they do require a C compiler to be installed.
On a Mac, this may need XCode Command Line Tools to be installed.
A fresh Ubuntu installation will need
sudo apt install build-essential
RHEL/Fedora will need
sudo dnf install 'Development Tools'
(and may need the EPEL repo enabled).Alternatively, if you don’t have root access, you can install compiler packages via conda,
Alternatively, comment out the entire ensure_installed
block in
~/.config/lua/plugins.lua
; this means you will not have
treesitter-enabled syntax highlighting though.
command |
description |
---|---|
<leader>cs |
Start incremental selection |
<Tab> (in incremental selection) |
Increase selection by node |
<S-Tab> (in incremental selection) |
Decrease selection by node |
nvim-lspconfig
¶
Added in version 2023-11-01.
Changed in version 2024-03-31: Changed next diagnostic to ]d rather than ]e for better mnemonic (and similar for [d)
nvim-lspconfig provides access to nvim’s Language Server Protocol (LSP). You install an LSP server for each language you want to use it with (see mason.nvim for installing these). Then you enable the LSP server for a buffer, and you get code-aware hints, warnings, etc.
Not all features are implemented in every LSP server. For example, the Python LSP is quite feature-rich. In contrast, the R LSP is a bit weak. Install them with mason.nvim.
The Python LSP may be quite verbose if you enable it on existing code, though in my experience addressing everything it’s complaining about will improve your code. You may find you need to add type annotations in some cases.
Because the experience can be hit-or-miss depending on the language you’re
using, LSP is disabled by default. The current exception is for Lua, but you
can configure this behavior in lua/plugins.lua
. Use <leader>cl
to start the LSP for a buffer. See trouble.nvim for easily viewing all the
diagnostics.
Note
You’ll need to install NodeJS
./setup.sh --install-npm # install nodejs into conda env
command |
description |
---|---|
<leader>cl |
Start the LSP server for this buffer |
<leader>ce |
Open diagnostic details |
[d |
Prev diagnostic |
]d |
Next diagnostic |
<leader>cgd |
Goto definition (e.g., when cursor is over a function) |
<leader>cK |
Hover help |
<leader>crn |
Rename all instances of this symbol |
<leader>cr |
Goto references |
<leader>ca |
Code action (opens a menu if implemented) |
mason.nvim
¶
Added in version 2023-11-01.
mason.nvim easily installs
Language Server Protocols, debuggers, linters, and formatters. Use :Mason
to open the interface, and hit i on what you want to install, or
g? for more help.
Note
Many language servers use the npm (javascript package manager) to install.
This is the case for pyright
, for example. You can use ./setup.sh
--install-npm
to easily create a conda env with npm and add its bin dir to
your $PATH
.
For Python, install pyright
.
For Lua (working on your nvim configs), use lua-language-server
(nvim-lspconfig calls this lua-ls
).
For R, you can try r-languageserver
, but this needs to be installed within
the environment you’re using R (and R itself must be available). It’s not
that useful if you want to use it in multiple conda environments. It doesn’t
have that many features yet, either.
command |
description |
---|---|
|
Open the mason interface |
trouble.nvim
¶
Added in version 2023-11-01.
trouble.nvim organizes all the LSP diagnostics into a single window. You can use that to navigate the issues found in your code.
command |
description |
---|---|
<leader>ct |
Toggle trouble.nvim window |
gitsigns
¶
Added in version 2023-10-15.
gitsigns shows a “gutter” along the left side of the line numbers, indicating where there were changes in a file. Only works in git repos.
This plugin is in a way redundant with vim-fugitive. Fugitive is more useful when making commits across multiple files; gitsigns is more useful when making commits within a file while you’re editing it. So they are complementary plugins rather than competing.
Most commands require being in a hunk. Keymappings start with h
, mnemonic
is “hunk” (the term for a block of changes).
command |
description |
---|---|
[c |
Previous change |
]c |
Next change |
<leader>hp |
Preview hunk (shows floating window of the change, only works in a change) |
<leader>hs |
Stage hunk (or stage lines in visual mode) |
<leader>hr |
Reset hunk (or reset lines in visual mode) |
<leader>hu |
Undo stage hunk |
<leader>hS |
Stage buffer |
<leader>hR |
Reset buffer |
hb |
Blame line in floating window |
tb |
Toggle blame for line |
hd |
Diff this file (opens diff mode) |
td |
Toggle deleted visibility |
Additionally, this supports hunks as text objects using ih
(inside hunk).
E.g., select a hunk with vih, or delete a hunk with dih.
See also
vim-fugitive, gitsigns, vim.gv, and diffview.nvim are other complementary plugins for working with Git.
toggleterm
¶
Added in version 2022-12-27.
Changed in version 2024-03-31: Version of toggleterm is pinned because later versions have issues with sending multiple selected lines to the terminal.
ToggleTerm lets you easily interact with a terminal within vim.
The greatest benefit of this is that you can send text from a text buffer
(Python script, RMarkdown file, etc) over to a terminal. This lets you
reproduce an IDE-like environment purely from the terminal. The following
commands are custom mappings set in .config/nvim/init.vim
that affect
the terminal use.
Note
The terminal will jump to insert mode when you switch to it (either using keyboard shortcuts or mouse), but clicking the mouse a second time will enter visual mode, just like in a text buffer. This can get confusing if you’re not expecting it.
You can either click to the text buffer and immediately back in the terminal, or use a or i in the terminal to get back to insert mode.
command |
description |
---|---|
<leader>t |
Open terminal to the right. |
<leader>w |
Move to the right window (assumes it’s terminal), and enter insert mode |
<leader>q |
Move to the text buffer to the left, and enter normal mode |
<leader>cd |
Send the current RMarkdown code chunk to the terminal, and jump to the next chunk |
gxx |
Send the current line to the terminal buffer |
gx |
Send the current selection to the terminal buffer |
<leader>k |
Render the current RMarkdown file to HTML using knitr::render(). Assumes you have knitr installed and you’re running R in the terminal buffer. |
<leader>k |
Run the current Python script in IPython. Assumes you’re running IPython in the terminal buffer. |
vim-fugitive
¶
Added in version 2018-09-26.
vim-fugitive provides a git interface in vim.
This is wonderful for making incremental commits from within vim. This makes it a terminal-only version of git-cola or an alternative to tig. Specifically:
command |
description |
---|---|
:Git |
Opens the main screen for fugitive (hint: use vim -c “:Git” from the command line to jump right into it) |
= |
Toggle visibility of changes |
- (when over a filename) |
Stage or unstage the file |
- (when in a chunk after using |
Stage or unstage the chunk |
- (in visual select mode ( |
Stage or unstage just the selected lines. Perfect for making incremental commits. |
cc |
Commit, opening up a separate buffer in which to write the commit message |
dd (when over a file) |
Open the file in diff mode |
The following commands are built-in vim commands when in diff mode, but
are used heavily when working with :Gdiff
, so here is a reminder:
Working with diffs¶
command |
description |
---|---|
]c |
Go to the next diff |
[c |
Go to the previous diff |
do |
Use the [o]ther file’s contents for the current diff |
dp |
[P]ut the contents of this diff into the other file |
See also
vim-fugitive, gitsigns, vim.gv, and diffview.nvim are other complementary plugins for working with Git.
vim.gv
¶
Added in version 2021-02-14.
vim.gv provides an interface to easily view and browse git history.
command |
description |
---|---|
:GV in visual mode |
View commits affecting selection |
GV |
Open a commit browser, hit Enter on a commit to view |
See also
vim-fugitive, gitsigns, vim.gv, and diffview.nvim are other complementary plugins for working with Git.
vim-mergetool
¶
Added in version 2021-02-14.
vim-mergetool makes 3-way merge conflicts much easier to deal with by only focusing on what needs to be manually edited.
Makes it MUCH easier to work with 3-way diffs, while at the same time allowing enough flexibility in configuration to be able to reproduce default behaviors.
Note
You’ll need to set the following in your .gitconfig:
[merge]
conflictStyle = diff3
command |
description |
---|---|
:MergetoolStart |
Starts the tool |
:diffget |
Pulls “theirs” (that is, assume the remote is correct) |
do, dp |
Used as in vim diff mode |
Save and quit, or use :MergetoolStop.
vim-diff-enhanced
¶
Added in version 2019-02-27.
vim-diff-enhanced provides additional diff algorithms that work better on certain kinds of files. If your diffs are not looking right, try changing the algorithm with this plugin:
command |
description |
---|---|
:EnhancedDiff <algorithm> |
Configure the diff algorithm to use, see below table |
The following algorithms are available:
algorithm |
description |
---|---|
myers |
Default diff algorithm |
default |
alias for myers |
minimal |
Like myers, but tries harder to minimize the resulting diff |
patience |
Patience diff algorithm |
histogram |
Histogram is similar to patience but slightly faster |
vim-table-mode
¶
Added in version 2019-03-27.
vim-table-mode provides easy formatting of tables in Markdown and Restructured Text
Nice Markdown tables are a pain to format. This plugin makes it easy, by auto-padding table cells and adding the header lines as needed.
With table mode enabled, || on a new line to start the header.
Type the header, separated by |.
On a new line, use || to fill in the header underline.
On subsequent rows, delimit fields by |.
Complete the table with || on a new line.
command |
description |
---|---|
:TableModeEnable |
Enables table mode, which makes on-the-fly adjustments to table cells as they’re edited |
:TableModeDisable |
Disables table mode |
:Tableize |
Creates a markdown or restructured text table based on TSV or CSV text |
TableModeRealign |
Realigns an existing table, adding padding as necessary |
See the homepage for, e.g., using ||
to auto-create header lines.
leap.nvim
¶
Added in version 2022-12-27.
Deprecated since version 2024-03-31: Removed in favor of the flash plugin, which behaves similarly but also supports treesitter selections
flash
¶
Added in version 2024-03-31.
flash lets you jump around in a buffer with low mental effort.
command |
description |
---|---|
Ctrl-s when searching |
Toggle flash during search |
s in normal mode |
jump to match (see details) |
S in normal mode |
select this treesitter node (see details) |
When searching with / or ?, an additional suffix letter will be shown after each match. Typing this additional letter lets you jump right to that instance.
Or just hit Enter like normal to do a typical search.
Either way, n and N for next/prev hit work as normal.
With s, this changes the syntax highlighting to hide everything but the search hit and the suffix.
With S, if a treesitter parser is installed for this filetype, suffix letters will be shown at different levels of the syntax tree.
For example, S within an R for-loop within an RMarkdown chunk will show suffixes to type that will select the inner body of the for-loop, the entire for-loop, or the entire body of the chunk. If you wanted to select the backticks as well, you could use S when on the backticks.
vim-surround
¶
Added in version 2022-12-27.
vim-surround lets you easily change surrounding characters.
command |
description |
---|---|
cs"' |
change surrounding |
csw} |
add |
csw{ |
same, but include a space |
vis
¶
Added in version 2019-09-30.
vis provides better behavior on visual blocks.
By default in vim and neovim, when selecting things in visual block mode, operations (substitutions, sorting) operate on the entire line – not just the block, as you might expect. However sometimes you want to edit just the visual block selection, for example when editing TSV files.
command |
description |
---|---|
<C-v>, then use :B instead of : |
Operates on visual block selection only |
bufferline.nvim
¶
Added in version 2023-11-01.
bufferline.nvim provides the tabs along the top.
command |
description |
---|---|
<leader>b, then type highlighted letter in tab |
Switch to buffer |
diffview.nvim
¶
Added in version 2023-10-11.
diffview.nvim supports viewing diffs across multiple files. It also has a nice interface for browsing previous commits.
I’m still figuring out when it’s better to use this, fugitive, or gitsigns.
See also
vim-fugitive, gitsigns, vim.gv, and diffview.nvim are other complementary plugins for working with Git.
See the homepage for details.
command |
description |
|
Opens the viewer |
|
View diffs for this file throughout git history |
conform
¶
Added in version 2024-03-31.
conform runs style formatters on the current buffer.
For example, if black
is avaiable it will run that on the code, but in
a way that the changes can be undone (in contrast to running black
manually on the file, which overwrites it).
command |
description |
<leader>cf |
Run configured formatter on buffer (mnemonic: [c]ode [f]ormat) |
You can install formatters via mason.nvim; search
.config/nvim/lua/plugins.lua
for conform.nvim
to see the
configuration.
For example, for Python I have isort
and black
; for Lua, stylua
; for
bash, shfmt
.
lualine
¶
Added in version 2023-11-01.
lualine provides the status line along the bottom.
No additional commands configured.
indent-blankline
¶
Added in version 2023-10-15.
indent-blankline shows vertical lines where there is indentation, and highlights one of these vertical lines to indicate the current scope.
No additional commands configured.
vim-python-pep8-indent
¶
Added in version 2017.
vim-python-pep8-indent auto-indents Python using pep8 recommendations. This happens as you’re typing, or when you use gq on a selection to wrap.
No additional commands configured.
vim-rmarkdown
¶
Added in version 2019-02-27.
Deprecated since version 2023-11-14: Removed in favor of treesitter
Deprecation notes
vim-rmarkdown provides syntax
highlighting for R within RMarkdown code chunks. Requires both vim-pandoc
and vim-pandoc-syntax
, described below.
No additional commands configured.
vim-pandoc
¶
Added in version 2019-02-27.
Deprecated since version 2023-11-14: Removed in favor of treesitter
Deprecation notes
vim-pandoc Integration with pandoc. Uses vim-pandoc-syntax (see below) for syntax highlighting.
Includes folding and formatting. Lots of shortcuts are defined by this plugin,
see :help vim-pandoc
for much more.
No additional commands configured.
vim-pandoc-syntax
¶
Added in version 2019-02-27.
Deprecated since version 2023-11-14: Removed in favor of treesitter
Deprecation notes
vim-pandoc-syntax is used by vim-pandoc (above). It is a separate plugin because the authors found it easier to track bugs separately.
No additional commands configured.
vim-tmux-clipboard
¶
Added in version 2016.
vim-tmux-clipboard automatically copies yanked text from vim into the tmux clipboard. Similarly, anything copied in tmux makes it into the vim clipboard.
See this screencast for
usage details. Note that this also requires the vim-tmux-focus-events plugin. You’ll need
to make sure set -g focus-events on
is in your .tmux.conf
.
No additional commands configured.
zenburn.nvim
¶
Added in version 2023-11-01.
This uses my fork of https://github.com/phha/zenburn.nvim, which adds addtional support for plugins and tweaks some of the existing colors to work better.
No additional commands configured.
stickybuf.nvim
¶
Added in version 2024-04-27.
stickybuf.nvim prevents text buffers from opening up inside a terminal buffer.
No additional commands configured.
lsp-progress.nvim
¶
Added in version 2024-04-27.
lsp-progress.nvim adds a status/progress indicator to the lualine (at the bottom of a window) so you know when it’s running.
No additional commands configured.
Colorschemes¶
For years I’ve been using the venerable zenburn colorscheme. However, now with additional plugins and highlighting mechansims (especially treesitter), it became important to be able to configure more than what that colorscheme supported.
The zenburn.nvim repo was a reboot of this colorscheme, but there were some parts of it that I wanted to change, or at least have more control over. Hence my fork of the repo, which is used here. If you’re interested in tweaking your own colorschemes, I’ve hopefully documented that fork enough to give you an idea of how to modify on your own.