Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Last active August 16, 2016 22:08
Show Gist options
  • Save rafaelrinaldi/033d0057a328a918d8a99e699a4a6231 to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/033d0057a328a918d8a99e699a4a6231 to your computer and use it in GitHub Desktop.
"###############################################################################
"# Bootstrap
"###############################################################################
" Vim doesn't like fish
set shell=/bin/bash
" be iMproved, required
set nocompatible
" UTF-8 all the things
set encoding=utf-8
set fileencoding=utf-8
" Remove automatic plugin identation (required by Vundle)
filetype off
"###############################################################################
"# Vundle
"###############################################################################
" Set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
" Startup Vundle
call vundle#begin()
"###############################################################################
"# Plugins
"###############################################################################
Plugin 'VundleVim/Vundle.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'ap/vim-css-color'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'othree/yajs.vim'
Plugin 'pangloss/vim-javascript'
Plugin 'pbrisbin/vim-mkdir'
Plugin 'rking/ag.vim'
Plugin 'sheerun/vim-polyglot'
Plugin 'tpope/vim-abolish'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-unimpaired'
Plugin 'wakatime/vim-wakatime'
"###############################################################################
"# General settings
"###############################################################################
" Close Vundle
call vundle#end()
" Automatic plugin indent
filetype plugin indent on
" Show line numbers
set number
" Numbers are relative to cursor
set relativenumber
" Set the title at top of tab to be the filename
set title
" Automatic syntax
syntax enable
" Tab
set tabstop=2 shiftwidth=2 expandtab
" Backspace
set backspace=2
" Display hidden whitespace
set listchars=tab:▸\ ,eol:¬,trail:·,nbsp:·
set showbreak=↪\
" Display hidden characters by default
set list
" Highlight current line
set cursorline
" Highlight column 80
set colorcolumn=80
set linebreak
" Give one virtual space at end of line
set virtualedit=onemore
" Complete files like a shell
set wildmenu wildmode=full
" Specify files to ignore on wildmenu
set wildignore+=.git,.svn
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg
set wildignore+=*.sw?
set wildignore+=.DS_Store
set wildignore+=node_modules,bower_components,elm-stuff
" Ignore patterns for netrw
let g:netrw_list_hide='.*\.git,.*\.DS_Store$'
" Set highlight for search
set hlsearch
" Case-insensitive searching
set ignorecase
" But case-sensitive if expression contains a capital letter
set smartcase
" Display status bar
set laststatus=2
" Backups are annoying, let file versioning handles this
set nobackup
set nowritebackup
" Stop being bothered by Vim swap files
set noswapfile
" Enable mouse in all modes because why not
set mouse=a
" Change the position where panes are opened
set splitbelow
set splitright
" Enable tree folding
set foldenable
set foldnestmax=10
set foldlevelstart=10
set foldmethod=indent
" Show ruler at all times
set ruler
"###############################################################################
"# Key mapping
"###############################################################################
" Remap the space key to toggle current fold
nnoremap <tab> za
" Clear the search buffer when hitting return
:nnoremap <CR> :nohlsearch<cr>
"###############################################################################
"# File-type specific
"###############################################################################
function! s:setupWrapping()
set wrap
set wrapmargin=2
set textwidth=80
endfunction
" Make sure all markdown files have the correct filetype set and setup wrapping
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt} setf markdown | call s:setupWrapping()
" Fix folding on JSON and CSS files
autocmd Filetype json,css,scss setlocal foldmethod=syntax
" Limits the body of Git commit messages to 72 characters
autocmd Filetype gitcommit setlocal textwidth=72
" Enable spell checking on certain file types
autocmd BufRead,BufNewFile *.md,gitcommit setlocal spell complete+=kspell
" Auto save files when focus is lost
au FocusLost * silent! wa
" Some file types use real tabs
au FileType {make,gitconfig} setl noexpandtab
"###############################################################################
"# Theming
"###############################################################################
" Define color scheme
colorscheme solarized
" Enable italic text
highlight Comment cterm=italic
" Display current line number in bold text
highlight CursorLineNr cterm=bold
" Set hidden characters colors to light gray
highlight NonText ctermfg=187
highlight SpecialKey ctermfg=187
"###############################################################################
"# Plugin specific
"###############################################################################
" Use Git's `ls-files` and properly ignore hidden files
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" Remap most used CtrlP commands
nnoremap <leader>f :CtrlP<CR>
nnoremap <leader>b :CtrlPBuffer<CR>
" Split snippet edit panels vertically by default
let g:UltiSnipsEditSplit='vertical'
" Disable JavaScript on Polyglot due to conflicts with yajs
let g:polyglot_disabled = ['javascript']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment