Plugin for cleaning up the default key mappings and plugins in Neovim leaving only the bare essentials to build upon.
It provides only 2 functions:
clean_plugins()
: disables most nonessential builtin Neovim providers and plugins, such as, netrw, zipPlugin, matchit, etc. (see the full list in the code)clean_keymap()
: maps most of Neovim builtin keymaps to<Nop>
leaving (subjectively) only essential functionality:- any text typed in insert/cmdline modes
- char movements
hjkl
, as well as word movementswebWEB
- line movements
^$
, as well as topgg
and bottomG
movements - visual mode enter
vV<C-v>
, as well as Ex command mode:
- insert mode enter
aioAIO
and exit<Esc>
- buffer search
/
with next/previous jumpsnN
- yank
yY
(together with line yankyy
) and pastepP
- char deletions
xX
, text deletionsdD
(together with line deletedd
) - text changes
cC
(together with line changecc
), as well as char replacer
and text replaceR
- undo
u
and redo<C-r>
, as well as next/previous jumplist movements<C-o><C-i>
Neovim is a powerful text editor with a lot of functionality - the index consists of several hundred of commands. This plugin narrows it down to a few dozen most used commands, which may be beneficial for the following reasons:
- avoids unpredictable results after accidental clicks, like
q:
instead of:q
- avoids accidental clashes for keymaps defined only in certain filetypes/buffers
- allows you to have a dedicated keymap file in dotfiles containing the self-picked functionality, which provides a better overview
- makes you think about how you use the editor, choose keymaps that are natural for you
- some builtin functionality is simply too specific and should probably be extracted into a plugin in the future (Rot13 encoding? Hebrew language support?)
- disables builtin plugins that you don't use and saves on startup time and completion clutter
- some people simply prefer a bottom-up approach
Load 'clean.nvim' as any other Neovim plugin using your favourite package manager.
The plugin provides only 2 functions, which can called together towards the start of your init file (in order not to overwrite any previous keymaps or global options):
require('clean').clean_keymap()
require('clean').clean_plugins()
In order to re-enable a command either delete the keymap or map it to something else (including itself) explicitly:
vim.keymap.del('', 'f')
vim.keymap.set('', 't', 't')
Note, that re-enabling multi-key commands may require re-enabling their prefixes as well, i.e., to use zz
you should have:
vim.keymap.del('n', 'z')
vim.keymap.del('n', 'zz')
In order to re-enable a plugin simply reset the corresponding variable to nil
afterwards, for example,
vim.g.editorconfig = nil