Skip to content

Instantly share code, notes, and snippets.

@jin
Created July 23, 2015 06:45
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 jin/69a4c762292f7b46bff8 to your computer and use it in GitHub Desktop.
Save jin/69a4c762292f7b46bff8 to your computer and use it in GitHub Desktop.
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive'
Plug 'Raimondi/delimitMate'
Plug 'tpope/vim-ragtag'
" Runs code through external parser to check for syntatic errors
Plug 'scrooloose/syntastic'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
Plug 'honza/vim-snippets'
" file browser
Plug 'scrooloose/nerdtree'
" pretty themes
Plug 'vim-scripts/Colour-Sampler-Pack'
" easy commenting with gc
Plug 'tpope/vim-commentary'
" buffer to list tags
Plug 'majutsushi/tagbar'
" status bar
Plug 'Lokaltog/vim-powerline'
" syntax highlighting/indentation etc for Rust lang
Plug 'wting/rust.vim'
" fuzzy file finder
Plug 'kien/ctrlp.vim'
" for ruby on rails
Plug 'tpope/vim-rails'
" for bundler
Plug 'tpope/vim-bundler'
" for ruby handling and autocompletion
Plug 'vim-ruby/vim-ruby'
" autocompletion
" Plug "vim-scripts/AutoComplPop"
" Plug "ervandew/supertab"
" Plug "Valloric/YouCompleteMe"
Plug 'Shougo/neocomplete.vim'
" for ruby
Plug 'tpope/vim-endwise'
" for coffeescript
Plug 'kchmck/vim-coffee-script'
" less syntax highlighting
" Plug 'genoma/vim-less'
" for rubymotion
Plug 'rcyrus/snipmate-snippets-rubymotion'
" rake
Plug 'tpope/vim-rake'
" Easy grepping
Plug 'vim-scripts/EasyGrep'
" Making NERDTree and Tabs work together
" Plug 'jistr/vim-nerdtree-tabs'
" let g:nerdtree_tabs_open_on_console_startup=1
" Haskell syntax highlight
" Plug 'travitch/hasksyn'
" gruvbox colorscheme
" Plug 'morhetz/gruvbox'
" emmet / HTML
" Plug 'mattn/emmet-vim'
" for netrw
" Plug 'eiginn/netrw'
" slim syntax highlighting
Plug 'slim-template/vim-slim'
" Pretty JSON
Plug 'elzr/vim-json'
" Exchange regions of words with cx
" Plug 'tommcdo/vim-exchange'
" Inline Ruby evaluation
Plug 't9md/vim-ruby-xmpfilter'
" Swift
" Plug 'Keithbsmiley/swift.vim'
" Readline keybindings
" Plug 'tpope/vim-rsi'
" align
" Plug 'godlygeek/tabular'
" Plug 'junegunn/vim-easy-align'
" jsx and js
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'justinj/vim-react-snippets'
Plug 'trusktr/seti.vim'
Plug 'fatih/vim-go'
Plug 'evanmiller/nginx-vim-syntax'
call plug#end()
set nocompatible
set number relativenumber
set encoding=utf-8
set laststatus=2 "Needed for Powerline
set mouse=a
" Suppress default message at launch
set shortmess+=I
" Increase performance when dealing with long strings
set lazyredraw
" set nobackup
" no viminfo files
set viminfo=
set backupdir=/tmp
set directory=/tmp
"" Whitespace stuff
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab " Insert spaces instead of tab when tab is pressed
set smarttab " Indent start of lines with shiftwidth, not tabstop
"" Nicer autocomplete in command mode
set wildmode=longest,list
" Allow backspace to work everywhere
set backspace=indent,eol,start
"" Enable vim omnicompletion
set omnifunc=syntaxcomplete#Complete
"" Soft wrap long lines
set wrap
"" Searching stuff
set hlsearch
set incsearch
set ignorecase
set smartcase
"" Highlight trailing whitespaces
"set list
"set listchars=tab:>.,trail:.,extends:#,nbsp:.
"" ..but don't do that in html and xml files
autocmd filetype html,xml set listchars-=tab:>.
"" Use system clipboard
set clipboard=unnamed
"" Persistent undo
set undofile
set undodir=/tmp
"" MacVim default font and size
set guifont=Inconsolata-dz:h12
"" No error and visual bells
set noerrorbells
set visualbell t_vb=
"" Keep at least 5 lines around cursor
set scrolloff=5
"" Set vsp and sp to open a new pane to the right and below by default
set splitbelow
set splitright
"" Show recommended max row length
" set colorcolumn=80
highlight ColorColumn ctermbg=magenta
call matchadd('ColorColumn', '\%81v', 100)
"""""""""""""""""""
""""Keymappings""""
"""""""""""""""""""
"" Set <leader> to ','
let mapleader = ","
"" Remap ESC
" imap kj <Esc>
"" Maintain selection after indentation
vmap > >gv
vmap < <gv
"" Moves cursor to the midscreen while going through search terms
nnoremap N Nzz
nnoremap n nzz
"" Quicker window switching
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
"" Split windows specified explicitly
nnoremap <C-w>s :sp<cr>
"" Set ':' to ';'
nnoremap ; :
"" 'j' and 'k' as they should be
nnoremap j gj
nnoremap k gk
" Hardcore mode
" map <up> <nop>
" map <down> <nop>
" map <left> <nop>
" map <right> <nop>
"" Remove all trialing whitespaces from file
nnoremap <leader>W :%s/\s\+$//<CR>:let @/=''<CR>
"" Turn off highlighting after search
map <leader><space> :noh<CR>
"" Execute script
nnoremap <F8><F8> :!./%<CR>
"" Sudo write a file
cmap w!! w !sudo tee % >/dev/null
"" Go to previous file
map <Leader>p <C-^>
"" Yank whole file
map yA :%y+<CR>
"" For rcodetools/xmpfilter ruby inline evaluation
nmap <buffer> <Leader>r <Plug>(xmpfilter-run)
xmap <buffer> <Leader>r <Plug>(xmpfilter-run)
imap <buffer> <Leader>r <Plug>(xmpfilter-run)
nmap <buffer> <Leader>m <Plug>(xmpfilter-mark)
xmap <buffer> <Leader>m <Plug>(xmpfilter-mark)
imap <buffer> <Leader>m <Plug>(xmpfilter-mark)
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType go set et ts=2 sw=2
"""""""""""""
"""Plugins"""
"""""""""""""
"" CtrlP
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git'
let g:neocomplete#enable_at_startup = 1
let g:syntastic_javascript_checkers = ['jsxhint']
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_autosave = 0
au FileType go nmap <Leader>ds <Plug>(go-def-split)
au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>s <Plug>(go-implements)
au FileType go nmap <Leader>i <Plug>(go-info)
colorscheme seti
syntax on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment