Instantly share code, notes, and snippets.

Embed
What would you like to do?
" #############################################################################
" Here is my vim configuration with lots of comments to try and explain
" everything that I have done.
" #############################################################################
" Load plug.vim, put all plugins in the right folder
call plug#begin('~/.config/nvim/bundle')
" Language file for elm
Plug 'ElmCast/elm-vim', { 'for': 'elm' }
" This plugin puts modified `-/+` flags in the gutter if the hunk is modified
" in git. Also adds fancy bindings to jump to modified code.
Plug 'airblade/vim-gitgutter'
" Plugin that supports universal settings for line endings and tabstops
Plug 'editorconfig/editorconfig-vim'
" I like elixir. It's fun.
Plug 'elixir-lang/vim-elixir', { 'for': 'elixir' }
" Extended css3 syntax file
Plug 'hail2u/vim-css3-syntax', { 'for': 'css' }
" Lightweight statusline plpugin, just shows me the branch I'm in and a few
" other things. Slightly faster than airline.
Plug 'itchyny/lightline.vim'
" A plugin that opens the current buffer in Marked 2.app, a markdown preview
" application.
Plug 'itspriddle/vim-marked', { 'for': 'markdown,vimwiki' }
" Auto closes delimiters. I can turn it on and off, 90% of the time I want it
" on.
Plug 'jiangmiao/auto-pairs'
" FZF is the best fuzzy finder interface available. I use it with ripgrep for
" extra speed.
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install --all' }
Plug 'junegunn/fzf.vim'
" goyo and limelight together allow me to create a minimal writing environment
" for writing prose and code.
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' }
Plug 'junegunn/limelight.vim', { 'on': 'Limelight' }
" Easy-align gives an interactive interface for aligning text. Very powerful.
Plug 'junegunn/vim-easy-align'
" Vim plug updates and maintains plugins
Plug 'junegunn/vim-plug'
" I forgot why this is here, I think it's to support some other plugin.
Plug 'kopischke/vim-fetch'
" Snippets engine for generating HTML. I've just been using it for a long
" time, so I'm used to it.
Plug 'mattn/emmet-vim', { 'for': 'html,erb,eruby,markdown' }
" Super handy plugin that lets you create and maintain gists... pretty sure
" I'll use this plugin in a minute to post this config. :)
Plug 'mattn/gist-vim'
" Plugin to support gist.vim
Plug 'mattn/webapi-vim'
" Plugin for searching for code across a project/folder. Absolutely a must
" have. I use ripgrep for extra speed here, see below.
Plug 'mileszs/ack.vim'
" My favorite colorscheme. I can't quit it.
Plug 'morhetz/gruvbox'
" I can ride my bike with no handlebars. Or I use this for working with
" javascript templates.
Plug 'mustache/vim-mustache-handlebars', { 'for': 'javascript,handlebars' }
" Hmmm... I have two completion plugins for css... this one is the the
" omnicomplete function for vim
Plug 'othree/csscomplete.vim', { 'for': 'css' }
" Syntax file for javascript. Necessary evil.
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
" Colorscheme for my minimal writing mode.
Plug 'pbrisbin/vim-colors-off'
" Elixir = wonderful.
Plug 'slashmili/alchemist.vim', { 'for': 'elixir' }
" Now begins the tpopery. The Vimvatican?
" abolish is for fancy find/replace including weird plurals
Plug 'tpope/vim-abolish'
" universal operator for commenting in every language
Plug 'tpope/vim-commentary'
" completes ruby/elixir ends
Plug 'tpope/vim-endwise'
" useful unix/file stuff... mostly I use this for moving deleting files in
" buffers I have open.
Plug 'tpope/vim-eunuch'
" 🌟 the most useful git plugin known to man.
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-git'
" markdown syntax file
Plug 'tpope/vim-markdown'
" useful mappings for those who work in HTML/XML derived languages.
" `<CTRL-X>=` is a lifesaver
Plug 'tpope/vim-ragtag'
" I work on rails. I need this. If you work on rails, you do too.
Plug 'tpope/vim-rails', {'for': 'ruby,erb,yaml,ru,haml'}
" *Amazing* plugin that extends the repeat operator to do more useful things
" across vim.
Plug 'tpope/vim-repeat'
" fugitive + github = `:Gbrowse` opens github urls.
Plug 'tpope/vim-rhubarb'
" I rarely use this, but it adds some operators to adjust dates, and it's
" very handy when I need it
Plug 'tpope/vim-speeddating'
" Adds more capability to the `s` motion. Highly recommended.
Plug 'tpope/vim-surround'
" Useful bindings... pretty much a shortcut for everything I'd ever make a
" shortcut for in Vim. (Pretty sure there's a pastemode toggle in here that
" makes my later binding invalid)
Plug 'tpope/vim-unimpaired'
" Nice dressing for `:netrw`.
Plug 'tpope/vim-vinegar'
" I work with ruby.
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
" I can't have org-mode from emacs, so I have this. I like it a lot, and its
" getting better.
Plug 'vimwiki/vimwiki'
" The best syntax/linting plugin available at the moment.
Plug 'w0rp/ale'
" Adds more targets to your vim motions, making your editing better.
Plug 'wellle/targets.vim'
call plug#end()
" Load plugins, use intent settings
filetype plugin indent on
"=============================================
" Options
"=============================================
" Turn on color in vim. Shiny things.
set termguicolors
syntax on
" if you don't have caps in a search, ignore caps
set ignorecase
" if you do have caps in a search, pay attention to caps
set smartcase
" Tab completion
" I forgot what all this does.
set wildmode=list:longest,full
set wildignore=*.swp,*.o,*.so,*.exe,*.dll
" Start scrolling before the cursor reaches the top or bottom of the screen
set scrolloff=3
" Tab settings
set ts=2
set sw=2
set expandtab
" show the cursor position in the statusline
set ruler
" show line numbers
set number
" don't wrap long lines
set nowrap
" settings for the character for splits and such
set fillchars=vert:\│
" put a colored column to show when you should make a new line
set colorcolumn=80
" allow unsaved buffers to not be shown
set hidden
" set backup directories
set backupdir=~/.config/nvim/backups,.
set directory=~/.config/nvim/swaps,.
if exists('&undodir')
set undodir=~/.config/nvim/undo,.
endif
"=============================================
" Remaps
"=============================================
" make the leader the same key, and make it close
let mapleader=','
let maplocalleader=','
" No arrow keys, because @tmiller
map <Left> :echo "ಠ_ಠ"<cr>
map <Right> :echo "ಠ_ಠ"<cr>
map <Up> :echo "ಠ_ಠ"<cr>
map <Down> :echo "ಠ_ಠ"<cr>
" swap the jump to mark keys so that the easier to reach one is the more
" accurate one.
nnoremap ` '
nnoremap ' `
" quickly change panes without a weird prefix
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Turn off search highlight
nnoremap <localleader>/ :nohlsearch<CR>
" Trim trailing whitespace
nnoremap <localleader>tw m`:%s/\s\+$//e<CR>``
"=============================================
" Other Settings
"=============================================
" Use relative line numbers. I can't live without this now... I used to not
" like it and now I can't do otherwise. Makes small vertical jumps a breeze.
set relativenumber
" Toggle paste mode
set pastetoggle=<leader>z
" Fancy tag lookup for ctags
set tags=./tags;/,tags;/
" Fancy macros: in Normal mode if you hit `Q` it runs the macro in register
" `"q`. Just a convenience for temporary macros. I stole this idea from
" someone.
nnoremap Q @q
vnoremap Q :norm @q<cr>
" make trailing whitespace visible and pretty.
set listchars=tab:»·,trail:·
set list
" Soft-wrap for prose mode
command! -nargs=* Wrap set wrap linebreak nolist spell
let &showbreak=''
"=============================================
" Package Settings
"=============================================
" junegunn/fzf
"
" I use ripgrep to speed up fzf. It makes even searching from my home
" directory possible and fast.
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
let g:fzf_action = {
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit'
\ }
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
nnoremap <c-p> :FZF<cr>
nnoremap <localleader><space> :Buffers<cr>
" junegunn/limelight.vim
"
" All this limelight/goyo stuff is for a minimalist writing mode like
" writeroom or byword.
let g:limelight_conceal_ctermfg = 'gray'
let g:limelight_conceal_ctermfg = 240
function! GoyoBefore()
silent !tmux set status off
set tw=78
Limelight
color off
endfunction
function! GoyoAfter()
silent !tmux set status on
set tw=0
Limelight!
color gruvbox
endfunction
let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')]
nnoremap <Leader>m :Goyo<CR>
" junegunn/vim-easy-align
"
" defaults for easy align
vmap <Enter> <Plug>(EasyAlign)
nmap <Leader>a <Plug>(EasyAlign)
" mileszs/ack.vim
"
" use ripgrep `rg` to power ack for speeeeeed
let g:ackprg = 'rg --vimgrep --no-heading'
" morhetz/gruvbox
let g:gruvbox_italic=1
let g:gruvbox_improved_strings=1
let g:gruvbox_improved_warnings=1
let g:gruvbox_guisp_fallback='fg'
let g:gruvbox_contrast_light='hard'
let g:gruvbox_contrast_dark='medium'
set background=dark
colorscheme gruvbox
" tpope/vim-markdown
let g:markdown_fenced_languages = ['css', 'erb=eruby', 'javascript', 'js=javascript', 'json=javascript', 'ruby', 'sass', 'xml', 'html']
" itchyny/lightline.vim
let g:lightline = {
\ 'colorscheme': 'gruvbox',
\ }
" vimwiki/vimwiki
"
" I've removed the location of my wiki for security reasons 🔐
let g:vimwiki_list = []
let g:vimwiki_global_ext = 0
" w0rp/ale
let g:ale_lint_delay = 5000
let g:ale_javascript_eslint_use_global = 1
let g:ale_linters = {'javascript': ['eslint']}
" itspriddle/vim-marked
nnoremap <Leader>M :MarkedOpen<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment