Skip to content

Instantly share code, notes, and snippets.

@leonlee
Created November 23, 2016 09:50
Show Gist options
  • Save leonlee/ca97bf5be202558b8e9d6fec7af4fa65 to your computer and use it in GitHub Desktop.
Save leonlee/ca97bf5be202558b8e9d6fec7af4fa65 to your computer and use it in GitHub Desktop.
"vundle pre-config
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"vundle bundles & plugins
Plugin 'VundleVim/Vundle.vim'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-git'
Bundle 'tpope/vim-surround'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'kien/ctrlp.vim'
Plugin 'flazz/vim-colorschemes'
Plugin 'easymotion/vim-easymotion'
Plugin 'fatih/vim-go'
Plugin 'zenorocha/dracula-theme', {'rtp': 'vim/'}
Plugin 'derekwyatt/vim-scala'
Plugin 'terryma/vim-expand-region'
Plugin 'vim-scripts/gitignore'
Plugin 'bling/vim-airline'
Plugin 'Valloric/YouCompleteMe'
Plugin 'rking/ag.vim'
Plugin 'majutsushi/tagbar'
Plugin 'scrooloose/nerdcommenter'
Plugin 'vim-scripts/vim-auto-save'
Plugin 'JessicaKMcIntosh/Vim'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'airblade/vim-gitgutter'
Plugin 'mikelue/vim-maven-plugin'
Plugin 'airblade/vim-rooter'
Plugin 'alvan/vim-closetag'
Plugin 'IN3D/vim-raml'
"vundle post-config
filetype plugin indent on
filetype indent on
call vundle#end()
"color solarized
"color monokai-chris
color badwolf
syntax on
set cursorline
set expandtab
set modelines=0
set shiftwidth=4
set clipboard=unnamed
set synmaxcol=128
set ttyscroll=10
set encoding=utf-8
set tabstop=2
set softtabstop=2
set expandtab
set nowrap
set number
set nowritebackup
set noswapfile
set nobackup
set incsearch
set hlsearch
set ignorecase
set smartcase
set showcmd
set wildmenu " visual autocomplete for command menu
set lazyredraw " redraw only when we need to.
set showmatch " highlight matching [{()}]
let mapleader = "\<Space>"
nnoremap <Leader>w :w<CR>
" Copy & paste to system clipboard with <Space>p and <Space>y:
" vmap <Leader>y "+y
"vmap <Leader>d "+d
"nmap <Leader>p "+p
"nmap <Leader>P "+P
"vmap <Leader>p "+p
"vmap <Leader>P "+P
" edit vimrc/zshrc and load vimrc bindings
nnoremap <leader>ev :vsp $MYVIMRC<CR>
nnoremap <leader>ez :vsp ~/.zshrc<CR>
" save session
nnoremap <leader>s :mksession! ~/.session.vim<CR>
"terryma/vim-expand-region
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
" Automatic formatting
autocmd BufWritePre *.rb :%s/\s\+$//e
autocmd BufWritePre *.go :%s/\s\+$//e
autocmd BufWritePre *.haml :%s/\s\+$//e
autocmd BufWritePre *.html :%s/\s\+$//e
autocmd BufWritePre *.scss :%s/\s\+$//e
autocmd BufWritePre *.slim :%s/\s\+$//e
" au BufNewFile * set noeol
au BufRead,BufNewFile *.go set filetype=go
au BufRead,BufNewFile *.raml set filetype=yaml
" No show command
autocmd VimEnter * set nosc
" Quick ESC
imap jj <ESC>
" Jump to the next row on long lines
map <Down> gj
map <Up> gk
nnoremap j gj
nnoremap k gk
" format the entire file
nmap <leader>fef ggVG=
" tagbar
nmap <leader>ft :TagbarToggle<CR>
" GoDef
nmap <leader>gd :GoDef<CR>
nmap <leader>gf :GoDef
nmap <leader>gr :GoReferrers<CR>
"commenter
" Open new buffers
nmap <leader>s<left> :leftabove vnew<cr>
nmap <leader>s<right> :rightbelow vnew<cr>
nmap <leader>s<up> :leftabove new<cr>
nmap <leader>s<down> :rightbelow new<cr>
" Tab between buffers
"noremap <tab> <c-w><c-w>
" Switch between last two buffers
" nnoremap <leader><leader> <C-^>
" NERDTree
nmap <leader>n :NERDTreeToggle<CR>
nmap <leader><leader>m :NERDTreeFind<CR>
let NERDTreeHighlightCursorline=1
let NERDTreeIgnore = ['tmp', '.yardoc', 'pkg']
" CtrlP
nnoremap <Leader>o :CtrlP<CR>
"nnoremap <silent> t :CtrlP<cr>
nnoremap <leader> t :CtrlPMRUFiles<cr>
map <leader>b :CtrlPBuffer<cr>
let g:ctrlp_by_filename = 1
let g:ctrlp_max_files = 0
let g:ctrlp_max_depth = 10
"let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
"let g:ctrlp_match_window = 'bottom,order:ttb'
"let g:ctrlp_switch_buffer = 1
let g:ctrlp_working_path_mode = 0
"let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll)$',
\ }
"\ 'link': 'some_bad_symbolic_links',
" Quit with :Q
"command -nargs=0 Quit :qa!
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_command = "goimports"
" search & replace
"
" I search things usual way using /something
" I hit cs, replace first match, and hit <Esc>
" I hit n.n.n.n.n. reviewing and replacing all matches
"
vnoremap <silent> s //e<C-r>=&selection=='exclusive'?'+1':''<CR><CR>
\:<C-u>call histdel('search',-1)<Bar>let @/=histget('search',-1)<CR>gv
omap s :normal vs<CR>
"set backup
"set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
"set backupskip=/tmp/*,/private/tmp/*
"set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
"set writebackup
" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
let g:auto_save = 0 " enable AutoSave on Vim startup
let g:auto_save_no_updatetime = 1 " do not change the 'updatetime' option
let g:auto_save_in_insert_mode = 0 " do not save while in insert mode
"let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:gitgutter_avoid_cmd_prompt_on_windows = 0
" If you want :UltiSnipsEdit to split your window.
"let g:UltiSnipsEditSplit="vertical"
" <Ctrl-l> redraws the screen and removes any search highlighting.
"nnoremap <leader> :noh<return><esc>
nnoremap <silent> <C-l> :nohl<CR><C-l>
"mvn
nnoremap <Leader><Leader>c :Mvn compile<CR>
" using Source Code Pro
set anti enc=utf-8
"set guifont="Source\ Code\ Pro\ 11"
" filenames like *.xml, *.html, *.xhtml, ...
let g:closetag_filenames = "*.xml,*.html,*.xhtml,*.phtml"
set backspace=2 " make backspace work like most other apps
set laststatus=2 " always show status bar
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<,space:^ " show hidden chars
"set list
set colorcolumn=80
set relativenumber
set textwidth=80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment