1
0
Fork 0
dotfiles/vim/vimrc

364 lines
9.0 KiB
VimL
Raw Permalink Normal View History

2013-06-23 09:06:21 +00:00
set shell=/bin/bash
2014-08-08 11:03:07 +00:00
cd ~/Code
2013-07-20 06:11:49 +00:00
2013-05-21 06:57:41 +00:00
" ####################
" ### Vundle setup ###
" ####################
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
2013-07-20 06:11:49 +00:00
2013-05-21 06:57:41 +00:00
" ##############
" ### Colors ###
" ##############
2013-06-23 09:06:21 +00:00
Bundle "daylerees/colour-schemes", { "rtp": "vim-themes/" }
Bundle "chriskempson/tomorrow-theme", { "rtp": "vim/" }
2014-08-08 11:03:07 +00:00
Bundle "altercation/solarized", { "rtp": "vim-colors-solarized/" }
let g:solarized_termcolors=256
let g:solarized_termtrans=0
let g:solarized_degrade=0
let g:solarized_bold=0
let g:solarized_underline=0
let g:solarized_italic=0
let g:solarized_contrast="normal" " low | normal | high
let g:solarized_visibility="normal" " low | normal | high
2013-07-20 06:11:49 +00:00
Bundle "thinkpixellab/flatland", { "rtp": "Vim/" }
Bundle "sjl/badwolf"
Bundle "tomasr/molokai"
Bundle "nanotech/jellybeans.vim"
Bundle "chriskempson/base16-vim"
2013-07-30 08:58:56 +00:00
Bundle "jelera/vim-gummybears-colorscheme"
Bundle "tpope/vim-vividchalk"
2014-08-08 11:03:07 +00:00
Bundle "yuratomo/neon.vim"
2013-06-23 09:06:21 +00:00
syntax on
2013-06-23 09:06:21 +00:00
filetype plugin on
filetype indent on
2013-07-20 06:11:49 +00:00
function! SetRandomColorScheme()
let schemes ='peacock grunge freshcut molokai badwolf flatland jellybeans Tomorrow-Night Tomorrow-Night-Eighties '
2014-08-08 11:03:07 +00:00
let schemes.='base16-eighties vividchalk gummybears solarized neon2'
2013-07-20 06:11:49 +00:00
let seconds=str2nr(strftime('%S'))
let scheme=split(schemes)[seconds%10]
set background=dark
execute 'colorscheme '.scheme
redraw
echo 'Color scheme is now set to "'.scheme.'"'
endfunction
" call SetRandomColorScheme()
2014-08-08 11:03:07 +00:00
set background=dark
colorscheme solarized
2013-07-20 06:11:49 +00:00
nmap <Leader>cs :call SetRandomColorScheme()<CR>
2013-05-21 06:57:41 +00:00
" #################
" ### Powerline ###
" #################
2014-08-08 11:03:07 +00:00
" Bundle 'Lokaltog/vim-powerline'
Bundle 'bling/vim-airline'
2013-05-21 06:57:41 +00:00
set laststatus=2
2013-06-23 09:06:21 +00:00
set noshowmode
2014-08-08 11:03:07 +00:00
" let g:Powerline_symbols = 'compatible' " (compatible, unicode, fancy)
let g:airline_left_sep='' " Remove left arrow separator
let g:airline_right_sep='' " Remove right arrow separator
2013-05-21 06:57:41 +00:00
2013-07-20 06:11:49 +00:00
2013-06-23 09:06:21 +00:00
" #################
" ### Nerd Tree ###
" #################
2013-05-21 06:57:41 +00:00
Bundle 'scrooloose/nerdtree'
2013-07-20 06:11:49 +00:00
nmap <silent> <C-n> :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.DS_Store$', '\.swp$', '\.git$', '\.bundle$', '\.pyc$', '\.sass-cache']
2013-06-23 09:06:21 +00:00
let NERDTreeHighlightCursorline=1
let NERDTreeShowHidden=1
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=1
let NERDChristmasTree=1
let NERDTreeChDirMode=2
let NERDTreeQuitOnOpen=1
2013-07-20 06:11:49 +00:00
let g:NERDTreeWinSize=40
2013-06-23 09:06:21 +00:00
" ######################
" ### Nerd Commenter ###
" ######################
Bundle 'scrooloose/nerdcommenter'
let g:NERDCreateDefaultMappings=0
let g:NERDCompactSexyComs=1
let g:NERDSpaceDelims=1
2013-07-30 08:58:56 +00:00
nmap <silent> <Leader>cl <plug>NERDCommenterToggle
vmap <silent> <Leader>cl <plug>NERDCommenterToggle
2014-08-08 11:03:07 +00:00
nmap <D-/> <plug>NERDCommenterToggle
vmap <D-/> <plug>NERDCommenterToggle
smap <D-/> <plug>NERDCommenterToggle
imap <D-/> <esc>\cl<space>
2013-07-20 06:11:49 +00:00
2013-05-21 06:57:41 +00:00
2013-06-23 09:06:21 +00:00
" #########################
" ### Fuzzy File Search ###
" #########################
2013-05-21 06:57:41 +00:00
Bundle 'kien/ctrlp.vim'
2013-07-20 06:11:49 +00:00
let g:ctrlp_match_window_bottom=1
let g:ctrlp_match_window_reversed=1
2013-06-23 09:06:21 +00:00
2013-07-20 06:11:49 +00:00
" ######################
" ### Syntax Support ###
" ######################
2013-05-21 06:57:41 +00:00
2013-07-20 06:11:49 +00:00
Bundle 'tpope/vim-markdown'
2013-07-30 08:58:56 +00:00
Bundle 'vim-scripts/nginx.vim'
2014-08-08 11:03:07 +00:00
Bundle 'dag/vim-fish'
2013-07-20 06:11:49 +00:00
2014-08-08 11:03:07 +00:00
Bundle 'vim-ruby/vim-ruby'
2013-07-20 06:11:49 +00:00
Bundle 'wavded/vim-stylus'
Bundle 'kchmck/vim-coffee-script'
Bundle 'slim-template/vim-slim'
2013-06-23 09:06:21 +00:00
2014-08-08 11:03:07 +00:00
Bundle 'jnwhiteh/vim-golang'
2013-06-23 09:06:21 +00:00
" ###################
" ### Rails Tools ###
" ###################
2013-05-21 06:57:41 +00:00
Bundle 'tpope/vim-rails'
2013-07-20 06:11:49 +00:00
" Usage
" :Rmodel, :Rcontroller, :Rspec
2013-05-21 06:57:41 +00:00
2013-06-23 09:06:21 +00:00
" ###########################
" ### Magic Code Aligning ###
" ###########################
Bundle 'godlygeek/tabular'
2013-07-20 06:11:49 +00:00
" Usage
" :Tabularize /=
nmap <silent> <Leader>t :Tabularize /
2013-06-23 09:06:21 +00:00
" ###################
" ### Git Wrapper ###
" ###################
Bundle 'tpope/vim-fugitive'
2013-07-20 06:11:49 +00:00
" Usage
" :Gblame, :Gdiff, :Gcommit etc.
" ###########################
" ### The Silver Searcher ###
" ###########################
Bundle 'rking/ag.vim'
2014-08-08 11:03:07 +00:00
" ############
" ### Misc ###
" ############
Bundle 'gmarik/sudo-gui.vim'
Bundle 'nginx.vim'
Bundle 'tpope/vim-endwise'
" Bundle 'vim-scripts/AutoComplPop'
" Bundle 'ervandew/supertab'
2013-06-23 09:06:21 +00:00
" ###################
" ### Preferences ###
" ###################
set encoding=utf-8 " Because
set showmatch " Show matching brackets
set backspace=indent,eol,start " Better backspace support
set history=1000 " Save 1000 commands in history
set undolevels=1000 " Save 1000 commands for undo
set completeopt=longest,menuone " Completion preferences
set complete=.,w,b,kspell,ss " current buffer, other windows' buffers, dictionary, spelling
set relativenumber " Show line numbers (relative)
set cursorline " Highlight the current line
set tabstop=2 " Tab size
set shiftwidth=2 " Must be the same
set softtabstop=2 " Must be the same
set expandtab " Upaces instead of tabs
set nowrap " Wrap lines
set nolinebreak " Break lines softly
set wrapscan " Wrap search
set incsearch " Incremental search
set ignorecase " Ignore case when searching
set nohlsearch " Don't fucking highlight search
set smartcase " Overrides ignore case in case pattern contains upper case char
set nolist " Don't show sick characters
set textwidth=120 " Text width before wrap
set t_Co=256 " Number of terminal colors
set mousehide " Hide mouse when typing
set guioptions-=L " Disable scrollbars
set guioptions-=r " Disable scrollbars
set wildignore+=*/tmp/* " Index ignoresa
2014-08-08 11:03:07 +00:00
" set guifont=saxMono:h17 " Set font family and size
set guifont=Source\ Code\ Pro:h15 " Set font family and size
set linespace=4 " Set line padding
2013-07-20 06:11:49 +00:00
set hidden " Allow switching unsaved buffers
2014-08-08 11:03:07 +00:00
set synmaxcol=160 " Limits syntax highlighting to first 120 symbols; long lines bug fix
set number " Show the fucking line numbers already
2013-07-20 06:11:49 +00:00
" Sexy highlighting colors
highlight Search cterm=none ctermbg=198 ctermfg=7
2013-06-23 09:06:21 +00:00
" ########################
" ### MacVim Specific ###
" ########################
if has("gui_macvim")
" Use Mac option key as meta key
set macmeta
2013-07-20 06:11:49 +00:00
2013-06-23 09:06:21 +00:00
" MacVIM shift+arrow-keys behavior (required in .vimrc)
let macvim_hig_shift_movement=1
endif
2013-07-20 06:11:49 +00:00
2014-08-08 11:03:07 +00:00
" #############
" ### UTF-8 ###
" #############
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8
setglobal fileencoding=utf-8
" set global bomb
set fileencodings=ucs-bom,utf-8,latin1
endif
2013-06-23 09:06:21 +00:00
" ################
" ### Triggers ###
" ################
if has("autocmd")
2014-08-08 11:03:07 +00:00
" Code style
2013-06-23 09:06:21 +00:00
autocmd FileType ruby,eruby,yaml set ai sw=2 sts=2 et
autocmd FileType ruby,eruby,yaml setlocal foldmethod=manual
autocmd User Rails set tabstop=2 shiftwidth=2 softtabstop=2 expandtab
2014-08-08 11:03:07 +00:00
autocmd FileType c,python,python3 set tabstop=4 shiftwidth=4 softtabstop=4 expandtab
2013-06-23 09:06:21 +00:00
" When vimrc is edited, reload it
autocmd! BufWritePost $MYVIMRC source $MYVIMRC
2014-08-08 11:03:07 +00:00
" File type recognition
2013-07-20 06:11:49 +00:00
autocmd BufNewFile,BufRead *.styl set syntax=stylus
autocmd BufNewFile,BufRead *.slim set syntax=slim
autocmd BufNewFile,BufRead *.coffee set syntax=coffee
autocmd BufNewFile,BufRead *.md set syntax=markdown
2013-07-30 08:58:56 +00:00
autocmd BufNewFile,BufRead *.conf set syntax=nginx
2014-08-08 11:03:07 +00:00
autocmd BufNewFile,BufRead Capfile,Gemfile set syntax=ruby
2013-06-23 09:06:21 +00:00
endif
2013-05-21 06:57:41 +00:00
" ##########################
" ### Follow Your Leader ###
" ##########################
2013-06-23 09:06:21 +00:00
" Set the Leader key to comma instead of backslash
2013-07-30 08:58:56 +00:00
" let mapleader = ","
2013-05-21 06:57:41 +00:00
2013-06-23 09:06:21 +00:00
nmap <Leader>v :e $MYVIMRC<CR>
2014-08-08 11:03:07 +00:00
nmap <Leader>e :e
2013-06-23 09:06:21 +00:00
2013-07-30 08:58:56 +00:00
" Buffers
2014-08-08 11:03:07 +00:00
nmap <Leader>bd :bd<CR>
2013-07-30 08:58:56 +00:00
nmap <Leader>bb :ls<CR>:b
nmap <Leader>ss :w<CR>
2013-06-23 09:06:21 +00:00
nmap <Leader>rr :source $MYVIMRC<CR>
2013-07-20 06:11:49 +00:00
" Search for the word under cursor
nmap <Leader>d /<C-r><C-w><CR>zz
2013-06-23 09:06:21 +00:00
" Toggle search highlight
nmap <Leader>h :set hlsearch!<CR>
2014-08-08 11:03:07 +00:00
nmap <Leader>hc :let @/=""<CR>
2013-06-23 09:06:21 +00:00
nmap <Leader>o :set paste!<CR>
" Toggle wrap
nmap <Leader>w :set wrap! list! linebreak!<CR>
" Center line with the find occurance
nmap n nzz
nmap N Nzz
" Siblings
nmap <Leader>ew :e <C-R>=expand("%:p:h")."/"<CR>
nmap <Leader>es :sp <C-R>=expand("%:p:h")."/"<CR>
nmap <Leader>ev :vsp <C-R>=expand("%:p:h")."/"<CR>
nmap <Leader>et :tabedit <C-R>=expand("%:p:h")."/"<CR>
" Convert Ruby 1.8 hash syntax to 1.9
2013-07-20 06:11:49 +00:00
nmap <Leader>r18 :%s/:\(\w\+\)\(\s\+\)=>\s\+/\1:\2/ge<CR>
2014-08-08 11:03:07 +00:00
nmap <Leader>cws :call PreservePosition('%s/\s\+$//e')<CR>
2013-06-23 09:06:21 +00:00
" #######################
" ### Visual Mappings ###
" #######################
" Indentation TextMate style
2013-07-30 08:58:56 +00:00
nmap <M-{> <<
vmap <M-}> >>
2013-06-23 09:06:21 +00:00
" Sudo to write
cmap w!! w !sudo tee % >/dev/null
" Move 10 lines with Option key
2013-07-30 08:58:56 +00:00
nmap <M-j> 10j
nmap <M-k> 10k
2013-06-23 09:06:21 +00:00
" Insert blank lines without entering insert mode
2013-07-30 08:58:56 +00:00
nnoremap <S-M-j> m`o<Esc>``
nnoremap <S-M-k> m`O<Esc>``
nmap m @a
2013-06-23 09:06:21 +00:00
2014-08-08 11:03:07 +00:00
nnoremap <C-o> <Esc>:e<space>
2013-05-21 06:57:41 +00:00
2013-06-23 09:06:21 +00:00
function! PreservePosition(command)
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
2013-05-21 06:57:41 +00:00
2013-06-23 09:06:21 +00:00
" Do the business:
execute a:command
2013-05-21 06:57:41 +00:00
2013-06-23 09:06:21 +00:00
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction