Skip to content

My personal (Neo)Vim configuration

Notifications You must be signed in to change notification settings

muellercodes/vimfiles

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vimfiles

This is a fully-fledged Neovim configuration, ready to go for Ruby, Rails, JavaScript, and JSX, as well as other languages such as Elm, Haskell, and Clojure.

What's inside

Handy plugins

This configuration comes with a boatload of plugins for various use cases and languages, but here are the most important ones:

  • VimPlug — a fast plugin manager
  • NERDTree — a simple file tree
  • Ctrl-P — a fuzzy file finder for quickly jumping to files
  • Ack + Ag — a way to search across a project lightning quick
  • NERDCommenter — an easy way to comment and uncomment lines
  • SuperTab — an autocompleter that stays out of your way
  • Ale — an asychronous code linter that works with a bunch of languages (and can also autoformat files in languages that support it)
  • AutoPairs — adds matching parentheses, braces, brackets, and quotes as you type them (but can be toggled on/off as needed)
  • endwise — like AutoPairs but for Ruby blocks
  • indentLine — adds vertical lines at regular indentation levels so that you can quickly tell if a line is misindented
  • surround — a way to quickly surround text with quotes, parentheses, braces, etc.
  • togglecursor — makes insert and command modes more obvious by switching the cursor when switching modes
  • FastFold — makes it actually possible to use foldmethod=syntax in Ruby files without slowing Vim down to a halt

Sensible defaults

  • Lines in files of most filetypes are hard-wrapped to 80 characters
  • The system clipboard is used for copying/pasting
  • Incremental search provides more feedback than the default search behavior
  • Rakefile, Gemfile, and *.gemspec files are highlighted as Ruby files
  • .jshintrc and .eslintrc are highlighted as JSON files

Sensible mappings

  • , is the leader key (so no finger gymnastics)
  • Ctrl-{H,J,K,L} lets you navigate to windows in Vim and to panes in tmux
  • j and k always place the cursor one line below or above, regardless of whether lines are being wrapped
  • % bounces between the start and end of blocks (in languages that make it possible to do so)
  • < and > no longer lose drop the selection when indenting a selected block of text
  • Q lets you reformat paragraphs

Making this your own

Prerequisites

Want this configuration for yourself? There are a few things you'll need first.

Neovim

First, this configuration assumes you're using Neovim. You can install this using Homebrew:

brew install neovim

If you're using my dotfiles, you're good to go here. Otherwise, you'll want to keep in mind that you can use nvim to start Neovim. Since this is non-standard, it's recommended you add a couple of aliases to your shell:

alias vim="nvim"
alias vi="nvim"

iTerm

Next, you'll need to install iTerm if you don't already have it. Once you have it, you'll want to drop into Preferences and make three changes:

Color scheme

In this configuration, Vim uses Solarized as its color scheme. Solarized is a lovely color scheme as it has been finely crafted with science (okay, light/perception theory) so that the difference between its dark and light modes are only a few colors. In order to prevent your colors in Vim from looking off, you'll need to configure iTerm to use Solarized as well.

To do this, first, download the color scheme files here. Look for a directory that corresponds to iTerm, then double-click on the color scheme files (dark and light).

This will install the color scheme files, but now we need to apply them. The best way to do this is to click on the Profiles tab and create two new iTerm profiles, one called Solarized Light, the other called Solarized Dark. Now you can go into each profile, click on the Colors tab, and select a color preset.

iTerm preferences

Font

Now that you have two profiles, go into each one and configure them to use Fira Code as the font. Fira Code is a font where combinations of symbols that are frequently used in code (->, ..., and |>, just to name a few) are implemented as ligatures. This means that they appear as one character instead of multiple characters, thereby making it easier to scan code. Fira Code also works perfectly with Powerline/Airline, so you don't have to bother with any modified fonts such as these.

Ag (aka the Silver Searcher)

Vim is configured to use Ag for fuzzy file finding, so you'll also need this as well. You can install it with Homebrew:

brew install ag

If you already have Ag, make sure you're on a recent version. You can upgrade by saying:

brew upgrade ag

Ruby support

Neovim no longer includes Ruby support, so you'll need to install it. You can do that with:

gem install neovim

Python support

Neovim no longer includes Python support. You can install this with:

pip install neovim

NOTE: This assumes you have pip installed. As new Macs do not include pip, you will want to do that first.

Linters

If you plan on writing Ruby, JavaScript, or VimScript, you'll want some linters. Ale will run these automatically if the appropriate configuration files are present in your project.

For Ruby, you'll want Rubocop:

gem install rubocop

For JavaScript, you'll want ESLint and Prettier:

npm install -g eslint prettier

For VimScript, you'll want vint (note: you'll want to install Python and pip before doing this):

pip install vint

Running the install script

Now that you have the prerequisites out of the way, you can get started using this configuration.

First, you need to get these files onto your computer somehow. Rather than merely cloning this repo and then modifying the files therein, the goal of this configuration is to get you on a path to creating your own vimfiles. Therefore, you'll want to fork this repo so that you can push changes up to it later. Once you've done this, you can then clone your fork in a convenient place you'll remember, such as the same place you store code:

cd ~/your-code-directory
git clone [email protected]:yourusername/vimfiles.git

If you already installed Vim at some point in the past, then you'll want to make sure to move the existing configuration files out of the way first. At a minimum, you'll want to run:

mv ~/.vim ~/.vim.old
mv ~/.vimrc ~/.vimrc.old

Next, run the install script that comes bundled with this repo. Since you forked the repo, it's best that you install all of the files here as symlinks. This will allow you to edit them through your forked repo location.

script/install --link

Post-installation

You're almost there! Now you're ready to install plugins. You can do that by opening vim and by running:

:PlugInstall

(You may see errors that a plugin failed to be cloned or installed, but if you press R to restart the installation then it should report a success.)

Now close Vim and re-open it, and you should be good to go!

What next?

Once you've installed these files onto your own machine, it's up to you to figure out how you want to customize it! Admittedly, this may seem daunting, given how much is available here. With that in mind, here are some things to focus on:

  • Configuration. A lot of the configuration is broken out into separate files within src/config/nvim/config. Here you can learn where the leader key is set to ,, why Ctrl-{H,J,K,L} lets you bounce between panes, how text width gets wrapped at 80 characters except in git commit message windows, and much more. Feel free to modify these files as you see fit. (You can learn more about a particular setting through :help. For instance, try :help textwidth or :help colorcolumn.) You can add any files you want to this folder, as long as you load them in src/config/nvim/init.vim.
  • Plugins. The list of plugins loaded by this configuration are kept in src/config/nvim/plugins.vim, and the settings for these plugins are located at src/config/nvim/config/plugins, which are loaded in src/config/nvim/config/plugin-config.vim. There is a lot here, but don't panic! First, it's probably a good idea to read up on the most frequently used plugins mentioned at the beginning of this README. Learn what they do and how you can make use of them. If you don't feel like you need a plugin, feel free to disable it! You can do this by commenting it out in plugins.vim, and if it has a corresponding loader line in plugin-config.vim, comment that out, too. Then exit Vim, run :PlugClean, and reload Vim again.

About

My personal (Neo)Vim configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Vim Script 96.1%
  • Ruby 3.9%