A modular (Neo)Vim configuration!
Nearly every (Neo)Vim configuration you find online is composed of a single,
giant vimrc file. But this one is different: it's modular, relying on
(Neo)Vim's behavior of loading all plugin/**/*.vim files on startup to
cleanly partition your settings, mappings, packages, and other configuration
into separate files that each focus on a single topic and do one thing well.
-
Modularity of packages, filetypes, colorschemes, and Vim settings.
-
Lazy loading of filetype-specific packages to start Vim up quickly.
-
Parallel installation and updating of packages from Git repositories.
-
Easy upgrades with intelligent and automated Git conflict resolution.
-
Shell scripts for package management: insert, delete, rename, and more.
- Branches
- Scripts
- Packages
- Configs
- Dependencies
- Installation
- Usage
- Shortcuts
- Manuals
- References
- License
-
The origin branch is a "bare bones" template for anyone to start with.
-
The basics branch is a rudimentary configuration of the Standard Vim.
-
The qwerty branch is an enhanced configuration meant for QWERTY typists.
-
The dvorak branch is an optimized configuration meant for Dvorak typists --- those who type in Dvorak.
-
The engram branch is an optimized configuration meant for Engram typists --- those who type in Arno's Engram keyboard layout.
-
The master branch is the frontier, where I experiment with new plugins.
bin/*scripts automate common tasks. See below for their usage manuals.
-
**/*.getfiles specify URLs of Git repositories to clone for your packages. -
**/*.setfiles specify branch names or commit SHAs to check out from Git. -
**/*.runfiles specify shell commands to run after updating your packages. -
pack/*/start/*/directories are packages that Vim eagerly loads on start. -
pack/*/opt/*=*/directories are lazily loaded, filetype-specific packages.
-
plugin/**/*.vimconfigure Vim before it finishes starting up. -
pack/*/*/*.vimconfigure your packages before they are loaded. -
ftplugin/{*,/*}.vimconfigure your filetypes when they are loaded. -
after/colors/*.vimconfigure your colorschemes after they are applied. -
after/plugin/**/*.vimconfigure Vim after all of the above is finished.
-
Git 1.5+
-
POSIX environment (Linux, BSD, MacOSX, etc.)
Special note to Microsoft Windows users: simply
- replace
~/.vimwith%USERPROFILE%\vimfiles - replace
~/.vimrcwith%USERPROFILE%\_vimrc
in all commands listed throughout this document.
- replace
-
xargs with support for the
-rcommand-line option:Do not run the command if there are no arguments. Normally the command is executed at least once even if there are no arguments.
Backup your configuration:
mv ~/.vim ~/.vim.bak
mv ~/.config/nvim ~/.config/nvim.bak # for NeoVim
Install this configuration:
git clone https://github.com/sunaku/.vim.git ~/.vim
ln -s ~/.vim ~/.config/nvim # for NeoVim
cd ~/.vim
bin/setup
Select a Git branch to use:
bin/setup origin # template
bin/setup basics # template + basics
bin/setup qwerty # template + basics + my flair
bin/setup dvorak # template + basics + my flair + dvorak
bin/setup engram # template + basics + my flair + engram
bin/setup master # template + basics + my flair + engram + new stuff
See usage information:
bin/usage
See usage information for provided SCRIPT:
bin/usage SCRIPT
Add package from URL or Github USER/REPO under CATEGORY:
bin/insert URL CATEGORY
bin/insert USER/REPO CATEGORY
Add package from URL or Github USER/REPO under CATEGORY with PACKAGE_NAME:
bin/insert URL CATEGORY/PACKAGE_NAME
bin/insert USER/REPO CATEGORY/PACKAGE_NAME
Add ftpackage from URL or Github USER/REPO for FILETYPE:
bin/insert URL FILETYPE=
bin/insert USER/REPO FILETYPE=
Add ftpackage from URL or Github USER/REPO for FILETYPE with PACKAGE_NAME:
bin/insert URL FILETYPE=PACKAGE_NAME
bin/insert USER/REPO FILETYPE=PACKAGE_NAME
Rename packages with names matching PACKAGE_NAME regular expression:
bin/rename PACKAGE_NAME
Rename any/all packages flexibly from the comfort of Vim:
bin/rename-editor PACKAGE_NAME
Rename a *.get file from its current name to a new one:
bin/rename-fromto CURRENT_GET_FILE NEW_GET_FILE
Delete packages with names matching PACKAGE_NAME regular expression:
bin/delete PACKAGE_NAME
Lists untracked *.get files and packages lacking *.get files:
bin/orphans
Deletes untracked *.get files and packages lacking *.get files:
bin/clean # asks you for confirmation
bin/clean -f # no confirmation; force it
Update installed packages:
bin/update
Update this Vim configuration framework:
bin/rebase # asks to confirm bin/clean
bin/rebase -f # no confirmation; force it
Do all that periodically via crontab(1):
@daily cd ~/.vim && bin/rebase -f && bin/update
Track a certain Git BRANCH by creating a *.set file for your PACKAGE:
echo BRANCH > PACKAGE.set
Remove BRANCH tracking for your PACKAGE by deleting its *.set file:
rm PACKAGE.set
Lock a PACKAGE to a certain Git COMMITISH to prevent it from being updated:
cd PACKAGE
git checkout COMMITISH
Unlock a locked PACKAGE, so it can be updated, by checking out its master:
cd PACKAGE
git checkout master
This branch of the Vim configuration defines the following shortcuts.
-
Run
stty -ixonbefore starting Vim to use<C-S>and<C-Q>keys. -
<C-L>clears search highlighting; recalculates hunks when diffing.
gVvisually selects the most recently pasted text.gnselects the nearest search result after the cursor.gNselects the nearest search result before the cursor.
Yyanks from cursor to end of line, like Vim's nativeCandDkeys.
The usage manual for each script is reproduced here, for your convenience.
Deletes untracked *.get files and packages lacking *.get files.
If a REGEX is provided, it will filter the candidates for deletion.
Usage: bin/clean [-f] [OPTIONS_FOR_GREP...] [REGEX]
Usage: bin/clean # asks you for confirmation
Usage: bin/clean -f # no confirmation; force it
Deletes existing packages whose names match the given regular expression.
Usage: bin/delete [OPTIONS_FOR_GREP...] PACKAGE_NAME_REGEXP
Inserts a new package, optionally named PACKAGE_NAME, into the given CATEGORY. You can specify USER/REPO in place of URL to insert from GitHub repositories.
Usage: bin/insert [URL|USER/REPO] CATEGORY/[FILETYPE=][PACKAGE_NAME]
Finds all known and untracked '*.get' files.
Usage: bin/manifest [OPTIONAL_FILTER_REGEXP]
Lists untracked *.get files and packages lacking *.get files.
Usage: bin/orphans
Replays local commits on top of the newest changes from upstream.
Usage: bin/rebase # asks to confirm bin/clean
Usage: bin/rebase -f # no confirmation; force it
Usage: git-rebase-autocon [TARGET] [ARGUMENTS_FOR_GIT_REBASE...]
Rebases the given TARGET while automatically resolving conflicts by substituting empty-tree commits labeled "fixup!" that log all conflicting hunks in their commit messages in git-diff(1) format.
If TARGET is not specified, the upstream tracking branch is used. Optional ARGUMENTS_FOR_GIT_REBASE... are passed to git-rebase(1).
Documented at https://sunaku.github.io/git-rebase-autocon.html
Rebases the main branches, going from conventional to divergent.
Renames existing packages whose names match the given regular expression.
Usage: bin/rename [OPTIONS_FOR_GREP...] PACKAGE_NAME_REGEXP
At the prompt, edit the package location and press ENTER to rename it so. If you no longer wish to rename the package, just press ENTER to skip it. If you made a mistake and want to abort the rename, press Control and C.
Lets you rename all *.get files in one fell swoop, from the comfort of Vim.
Usage: bin/rename-editor
The editor will present you with 3 split windows (left, middle, and right):
- The left window lists the current names for your reference (read-only)
- The middle window lists the current names for you to rename (writable)
- The right window lists the default names for your reference (read-only)
Edit the names in the middle window and then save the file before exiting. To cancel or avoid performing any renames, exit the editor without saving.
Note: DO NOT change the order or amount of lines presented in the editor!
Renames the given *.get file and all associated files to the new name.
Usage: bin/rename-fromto CURRENT_GET_FILE NEW_GET_FILE
Activates the given BRANCH and installs any bundles it defines.
Usage: bin/setup [BRANCH]
Usage: bin/setup origin # template
Usage: bin/setup basics # template + basics
Usage: bin/setup qwerty # template + basics + my flair
Usage: bin/setup dvorak # template + basics + my flair + dvorak
Usage: bin/setup engram # template + basics + my flair + engram
Usage: bin/setup master # template + basics + my flair + engram + new stuff
Lists all shortcuts available in this Vim configuration.
Usage: bin/update [BUNDLE_NAME|DIRECTORY|GET_FILE]...
Usage: env UPDATE_BUNDLES_SEQUENTIALLY=1 bin/update
Clones or updates the Git repositories specified in ./**/*.get files:
optionally matching the given BUNDLE_NAME, DIRECTORY, or GET_FILE path,
starting from the most recently modified file down to the earliest one,
checking out the branch or commit named in related ./**/*.set files.
After that, it runs corresponding ./**/*.run scripts for those repos.
This is done in parallel, at up to half of the maximum process limit,
unless the UPDATE_BUNDLES_SEQUENTIALLY environment variable is set.
Displays help and usage information for this and fellow scripts.
Usage: bin/usage [SCRIPT]
Formats usage information from all scripts for injection into README.
- Plugin Layout in the Dark Ages by Steve Losh.
- Configuring Vim right by Stephen Bach.
Like my work? 👍 Please spare a life today as thanks! 🐄🐖🐑🐔🐣🐟✨🙊✌
Why? For 💕 ethics, the 🌎 environment, and 💪 health; see link above. 🙇
(the ISC license)
Copyright 2009 Suraj N. Kurapati https://github.com/sunaku
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.