Skip to content

Instantly share code, notes, and snippets.

@wkf
Created January 21, 2014 14:01
Show Gist options
  • Save wkf/8540609 to your computer and use it in GitHub Desktop.
Save wkf/8540609 to your computer and use it in GitHub Desktop.
set nocompatible " be iMproved
set shell=/bin/bash
set backspace=indent,eol,start
if $TERM == "xterm-256color" || $TERM == "screen-256color" || $COLORTERM == "gnome-terminal"
set t_Co=256
endif
set list
set listchars=tab:>-,trail:.,extends:#,nbsp:.
set hidden
set history=100 " Default history is only 20
set undolevels=100 " Use more levels of undo
set expandtab
set tabstop=2 " a tab is 2 spaces
set softtabstop=2 " tab size when insterting/pasting
set shiftwidth=2 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set nofoldenable " dont fold by default
set foldmethod=indent " fold based on indentation
set foldnestmax=10 " deepest fold is 10 levels
set foldlevel=1
set fillchars+=vert:│
set clipboard=unnamed
set cursorline
set ruler " Ruler on
set nu " Line numbers on
set nobackup " dont use backupfile
set noswapfile
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp " store swap files here
syntax on " Enable syntax highlighting
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
set incsearch " show search matches as you type
set ignorecase " case insensitive search
set smartcase " If a capital letter is included in search, make it case-sensitive
set nohlsearch " dont highlight search results
set background=dark
set scrolloff=2
set visualbell " dont beep
set noerrorbells " dont beep
set laststatus=2
set autoread " Auto read when a file is changed on disk
set nowrap
noremap \ ,
let mapleader=","
runtime ./theme/Tomorrow-Night-Eighties.vim
hi Normal ctermbg=NONE
hi nonText ctermbg=NONE
cmap w!! w !sudo tee % >/dev/null " allow saving a sudo file if forgot to open as sudo
autocmd! BufWrite * mark ' | silent! %s/\s\+$// | norm ''
autocmd BufRead,BufNewFile *.md setlocal spell spelllang=en_us
autocmd FileType gitcommit setlocal spell spelllang=en_us
autocmd BufRead,BufNewFile *.md setlocal textwidth=80
autocmd FileType gitcommit setlocal textwidth=80
filetype off " required!
set runtimepath+=~/Dropbox/Shared/Vim/bundle/neobundle.vim/
call neobundle#rc(expand('~/Dropbox/Shared/Vim/bundle/'))
" Let NeoBundle manage NeoBundle
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'windows' : 'make -f make_mingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
NeoBundle 'Valloric/YouCompleteMe' , {
\ 'build' : {
\ 'mac' : './install.sh --clang-completer',
\ 'unix' : './install.sh --clang-completer --system-libclang',
\ },
\ }
NeoBundle 'bling/vim-airline'
NeoBundle 'Shougo/unite.vim'
NeoBundle 'Kocha/vim-unite-tig'
NeoBundle 'pangloss/vim-javascript'
NeoBundle 'kchmck/vim-coffee-script'
NeoBundle 'jnwhiteh/vim-golang'
NeoBundle 'groenewege/vim-less'
NeoBundle 'othree/html5.vim'
NeoBundle 'plasticboy/vim-markdown'
NeoBundle 'puppetlabs/puppet-syntax-vim'
NeoBundle 'vim-scripts/scons.vim'
NeoBundle 'wavded/vim-stylus'
NeoBundle 'digitaltoad/vim-jade'
NeoBundle 'vim-ruby/vim-ruby'
NeoBundle 'dag/vim-fish'
NeoBundle 'elzr/vim-json'
NeoBundle 'lukerandall/haskellmode-vim'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'airblade/vim-gitgutter'
"NeoBundle 'sjl/gundo.vim'
"NeoBundle 'scrooloose/syntastic'
NeoBundle 'terryma/vim-multiple-cursors'
"NeoBundle 'Lokaltog/vim-easymotion'
NeoBundle 'crooloose/nerdcommenter'
NeoBundle 'mattn/webapi-vim'
NeoBundle 'mattn/gist-vim'
NeoBundle 'vim-scripts/sudo.vim'
NeoBundle 'vim-scripts/scratch.vim'
NeoBundle 'benmills/vimux'
NeoBundleCheck
"let g:airline_powerline_fonts = 1
let g:airline_theme_patch_func = 'AirlineThemePatch'
function! AirlineThemePatch(palette)
if g:airline_theme == 'tomorrow'
let a:palette.normal.airline_a[2] = '235'
let a:palette.normal.airline_z[2] = '235'
let a:palette.insert.airline_a[2] = '235'
let a:palette.insert.airline_z[2] = '235'
let a:palette.insert.airline_b[2] = '251'
let a:palette.insert.airline_b[3] = '238'
let a:palette.insert.airline_y[2] = '251'
let a:palette.insert.airline_y[3] = '238'
let a:palette.replace.airline_a[2] = '235'
let a:palette.replace.airline_z[2] = '235'
let a:palette.visual.airline_a[2] = '235'
let a:palette.visual.airline_z[2] = '235'
let a:palette.visual.airline_b[2] = '251'
let a:palette.visual.airline_b[3] = '238'
let a:palette.visual.airline_y[2] = '251'
let a:palette.visual.airline_y[3] = '238'
endif
endfunction
map <leader>p :VimuxPromptCommand<cr>
map <leader>. :VimuxRunLastCommand<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Unite
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:unite_source_history_yank_enable = 1
let g:unite_data_directory='~/.vim/.cache/unite'
let g:unite_source_rec_max_cache_files=5000
let g:unite_enable_start_insert = 1
"let g:unite_split_rule = "botright"
let g:unite_force_overwrite_statusline = 0
"let g:unite_winheight = 10
" Use ag for search
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts = '--nocolor --nogroup'
let g:unite_source_grep_recursive_opt = ''
let g:unite_source_rec_async_command='ag --nocolor --nogroup -g ""'
endif
" Use the fuzzy matcher for everything
call unite#filters#matcher_default#use(['matcher_fuzzy'])
" Use the rank sorter for everything
call unite#filters#sorter_default#use(['sorter_rank'])
nnoremap <leader>/ :Unite -buffer-name=grep -no-split grep:.<cr>
nnoremap <leader>y :Unite -buffer-name=yank -no-split history/yank<cr>
nnoremap <leader>t :Unite -buffer-name=file -no-split file_rec/async:!<cr>
nnoremap <leader>b :Unite -buffer-name=buffer -no-split buffer<cr>
nnoremap <leader>m :Unite -buffer-name=mru -no-split file_mru<cr>
nnoremap <leader>f :Unite -buffer-name=folder -no-split file file/new directory/new<cr>
nnoremap <leader>u :Unite -buffer-name=undo -no-split undo<cr>
autocmd FileType unite call s:unite_settings()
function! s:unite_settings()
"let b:SuperTabDisabled=1
imap <buffer> <C-j> <Plug>(unite_select_next_line)
imap <buffer> <C-k> <Plug>(unite_select_previous_line)
imap <silent><buffer><expr> <C-h> unite#do_action('split')
imap <silent><buffer><expr> <C-v> unite#do_action('vsplit')
imap <silent><buffer><expr> <C-t> unite#do_action('tabopen')
imap <silent><buffer><expr> <C-v> unite#do_action('preview')
nmap <buffer> <ESC>OA k
nmap <buffer> <ESC>OB j
nmap <buffer> <ESC>OC l
nmap <buffer> <ESC>OD h
nmap <buffer> <ESC> <Plug>(unite_exit)
endfunction
autocmd VimEnter * call s:on_vim_enter()
function! s:on_vim_enter()
let l:dir = expand("<amatch>")
if l:dir == ''
Unite -buffer-name=mru -no-split file_mru
elseif isdirectory(l:dir)
cd %:p:h
bd
Unite -buffer-name=folder -no-split file file/new directory/new
endif
endfunction
autocmd BufWritePre * :%s#\($\n\s*\)\+\%$##e
if exists('$TMUX')
function! TmuxOrSplitSwitch(wincmd, tmuxdir)
let previous_winnr = winnr()
silent! execute "wincmd " . a:wincmd
if previous_winnr == winnr()
call system("tmux select-pane -" . a:tmuxdir)
redraw!
endif
endfunction
let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', '', '')
let &t_ti = "\<Esc>]2;vim\<Esc>\\" . &t_ti
let &t_te = "\<Esc>]2;". previous_title . "\<Esc>\\" . &t_te
nnoremap <silent> <C-h> :call TmuxOrSplitSwitch('h', 'L')<cr>
nnoremap <silent> <C-j> :call TmuxOrSplitSwitch('j', 'D')<cr>
nnoremap <silent> <C-k> :call TmuxOrSplitSwitch('k', 'U')<cr>
nnoremap <silent> <C-l> :call TmuxOrSplitSwitch('l', 'R')<cr>
else
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
endif
filetype plugin indent on " required!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment