Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Last active October 10, 2016 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelrinaldi/ef86a57b487fd3aa22451c0719bbd44f to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/ef86a57b487fd3aa22451c0719bbd44f 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
"###############################################################################
"# Plugins
"###############################################################################
call plug#begin()
Plug 'SirVer/ultisnips'
Plug 'altercation/vim-colors-solarized'
Plug 'ap/vim-css-color'
Plug 'chriskempson/base16-vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'pbrisbin/vim-mkdir'
Plug 'rking/ag.vim'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-vinegar'
Plug 'wakatime/vim-wakatime'
Plug 'haya14busa/incsearch.vim'
if has('nvim')
Plug 'Shougo/deoplete.nvim'
Plug 'othree/jspc.vim'
endif
call plug#end()
"###############################################################################
"# General settings
"###############################################################################
" 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
" Vim backup files
set undofile
set backupdir=~/.vim/tmp
set directory=~/.vim/tmp
set undodir=~/.vim/tmp
" 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
"###############################################################################
"# 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
let base16colorspace=256
colorscheme base16-grayscale-light
" 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` to actually 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'
" Let incsearch handle `noh`
let g:incsearch#auto_nohlsearch=1
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment