333 lines
8.0 KiB
VimL
333 lines
8.0 KiB
VimL
set nocompatible " vi improved
|
|
filetype off " do not load Filetype file
|
|
set shell=/bin/bash
|
|
|
|
|
|
|
|
" ####################
|
|
" ### Vundle setup ###
|
|
" ####################
|
|
|
|
set rtp+=~/.vim/bundle/vundle/
|
|
call vundle#rc()
|
|
Bundle 'gmarik/vundle'
|
|
|
|
|
|
|
|
" ##############
|
|
" ### Colors ###
|
|
" ##############
|
|
|
|
Bundle "daylerees/colour-schemes", { "rtp": "vim-themes/" }
|
|
Bundle "chriskempson/tomorrow-theme", { "rtp": "vim/" }
|
|
" Bundle "altercation/solarized", { "rtp": "vim-colors-solarized/" }
|
|
Bundle "thinkpixellab/flatland", { "rtp": "Vim/" }
|
|
Bundle "sjl/badwolf"
|
|
Bundle "tomasr/molokai"
|
|
Bundle "nanotech/jellybeans.vim"
|
|
Bundle "chriskempson/base16-vim"
|
|
Bundle "jelera/vim-gummybears-colorscheme"
|
|
Bundle "tpope/vim-vividchalk"
|
|
|
|
syntax on
|
|
filetype plugin on
|
|
filetype indent on
|
|
|
|
function! SetRandomColorScheme()
|
|
let schemes ='peacock grunge freshcut molokai badwolf flatland jellybeans Tomorrow-Night Tomorrow-Night-Eighties '
|
|
let schemes.='base16-eighties vividchalk gummybears'
|
|
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()
|
|
colorscheme vividchalk
|
|
nmap <Leader>cs :call SetRandomColorScheme()<CR>
|
|
|
|
|
|
|
|
" #################
|
|
" ### Powerline ###
|
|
" #################
|
|
|
|
Bundle 'Lokaltog/vim-powerline'
|
|
let g:Powerline_symbols = 'compatible' " (compatible, unicode, fancy)
|
|
set laststatus=2
|
|
set noshowmode
|
|
|
|
|
|
|
|
" #################
|
|
" ### Nerd Tree ###
|
|
" #################
|
|
|
|
Bundle 'scrooloose/nerdtree'
|
|
nmap <silent> <C-n> :NERDTreeToggle<CR>
|
|
let NERDTreeIgnore=['\.DS_Store$', '\.swp$', '\.git$', '\.bundle$', '\.pyc$', '\.sass-cache']
|
|
let NERDTreeHighlightCursorline=1
|
|
let NERDTreeShowHidden=1
|
|
let NERDTreeMinimalUI=1
|
|
let NERDTreeDirArrows=1
|
|
let NERDChristmasTree=1
|
|
let NERDTreeChDirMode=2
|
|
let NERDTreeQuitOnOpen=1
|
|
let g:NERDTreeWinSize=40
|
|
|
|
|
|
|
|
" ######################
|
|
" ### Nerd Commenter ###
|
|
" ######################
|
|
|
|
Bundle 'scrooloose/nerdcommenter'
|
|
let g:NERDCreateDefaultMappings=0
|
|
let g:NERDCompactSexyComs=1
|
|
let g:NERDSpaceDelims=1
|
|
nmap <silent> <Leader>cl <plug>NERDCommenterToggle
|
|
vmap <silent> <Leader>cl <plug>NERDCommenterToggle
|
|
|
|
|
|
|
|
" #########################
|
|
" ### Fuzzy File Search ###
|
|
" #########################
|
|
|
|
Bundle 'kien/ctrlp.vim'
|
|
let g:ctrlp_match_window_bottom=1
|
|
let g:ctrlp_match_window_reversed=1
|
|
|
|
|
|
|
|
" ######################
|
|
" ### Syntax Support ###
|
|
" ######################
|
|
|
|
Bundle 'vim-ruby/vim-ruby'
|
|
Bundle 'tpope/vim-markdown'
|
|
Bundle 'vim-scripts/nginx.vim'
|
|
|
|
" Sugar
|
|
Bundle 'wavded/vim-stylus'
|
|
Bundle 'kchmck/vim-coffee-script'
|
|
Bundle 'slim-template/vim-slim'
|
|
|
|
" ###################
|
|
" ### Rails Tools ###
|
|
" ###################
|
|
|
|
Bundle 'tpope/vim-rails'
|
|
" Usage
|
|
" :Rmodel, :Rcontroller, :Rspec
|
|
|
|
|
|
|
|
" ###########################
|
|
" ### Magic Code Aligning ###
|
|
" ###########################
|
|
|
|
Bundle 'godlygeek/tabular'
|
|
" Usage
|
|
" :Tabularize /=
|
|
|
|
nmap <silent> <Leader>t :Tabularize /
|
|
|
|
|
|
|
|
" ###################
|
|
" ### Git Wrapper ###
|
|
" ###################
|
|
|
|
Bundle 'tpope/vim-fugitive'
|
|
" Usage
|
|
" :Gblame, :Gdiff, :Gcommit etc.
|
|
|
|
|
|
|
|
" ###########################
|
|
" ### The Silver Searcher ###
|
|
" ###########################
|
|
|
|
Bundle 'rking/ag.vim'
|
|
|
|
|
|
|
|
" ###################
|
|
" ### 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
|
|
set gfn=Inconsolata:h18 " Set font family and size
|
|
set hidden " Allow switching unsaved buffers
|
|
|
|
" Sexy highlighting colors
|
|
highlight Search cterm=none ctermbg=198 ctermfg=7
|
|
|
|
|
|
|
|
" ########################
|
|
" ### MacVim Specific ###
|
|
" ########################
|
|
|
|
if has("gui_macvim")
|
|
" Use Mac option key as meta key
|
|
set macmeta
|
|
|
|
" MacVIM shift+arrow-keys behavior (required in .vimrc)
|
|
let macvim_hig_shift_movement=1
|
|
endif
|
|
|
|
|
|
|
|
" ################
|
|
" ### Triggers ###
|
|
" ################
|
|
|
|
if has("autocmd")
|
|
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
|
|
|
|
" When vimrc is edited, reload it
|
|
autocmd! BufWritePost $MYVIMRC source $MYVIMRC
|
|
|
|
" Cleanup trailing whitespaces before save
|
|
autocmd BufWritePre * :call PreservePosition('%s/\s\+$//e')
|
|
|
|
" Line number (relative/absolute) magic
|
|
autocmd FocusLost * :set number
|
|
autocmd FocusGained * :set relativenumber
|
|
autocmd InsertEnter * :set number
|
|
autocmd InsertLeave * :set relativenumber
|
|
|
|
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
|
|
autocmd BufNewFile,BufRead *.conf set syntax=nginx
|
|
endif
|
|
|
|
|
|
|
|
" ##########################
|
|
" ### Follow Your Leader ###
|
|
" ##########################
|
|
|
|
" Set the Leader key to comma instead of backslash
|
|
" let mapleader = ","
|
|
|
|
nmap <Leader>v :e $MYVIMRC<CR>
|
|
|
|
" Buffers
|
|
nmap <Leader>bx :q!<CR>
|
|
nmap <Leader>bc :bd<CR>
|
|
nmap <Leader>bb :ls<CR>:b
|
|
|
|
nmap <Leader>ss :w<CR>
|
|
nmap <Leader>rr :source $MYVIMRC<CR>
|
|
|
|
" Search for the word under cursor
|
|
nmap <Leader>d /<C-r><C-w><CR>zz
|
|
|
|
" Toggle search highlight
|
|
nmap <Leader>h :set hlsearch!<CR>
|
|
nmap <Leader>hh :let @/=""<CR>
|
|
nmap <Leader>o :set paste!<CR>
|
|
|
|
" Toggle wrap
|
|
nmap <Leader>w :set wrap! list! linebreak!<CR>
|
|
|
|
" Rails helpers
|
|
nmap <Leader>rm :Rmodel
|
|
nmap <Leader>rc :Rcontroller
|
|
nmap <Leader>rs :Rspec
|
|
|
|
" 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
|
|
nmap <Leader>r18 :%s/:\(\w\+\)\(\s\+\)=>\s\+/\1:\2/ge<CR>
|
|
|
|
|
|
" #######################
|
|
" ### Visual Mappings ###
|
|
" #######################
|
|
|
|
" Indentation TextMate style
|
|
nmap <M-{> <<
|
|
vmap <M-}> >>
|
|
|
|
" Sudo to write
|
|
cmap w!! w !sudo tee % >/dev/null
|
|
|
|
" Move 10 lines with Option key
|
|
nmap <M-j> 10j
|
|
nmap <M-k> 10k
|
|
|
|
" Insert blank lines without entering insert mode
|
|
nnoremap <S-M-j> m`o<Esc>``
|
|
nnoremap <S-M-k> m`O<Esc>``
|
|
|
|
nmap m @a
|
|
|
|
function! ToggleLineNumbers()
|
|
if (&relativenumber == 1)
|
|
set number
|
|
else
|
|
set relativenumber
|
|
endif
|
|
endfunc
|
|
|
|
function! PreservePosition(command)
|
|
" Preparation: save last search, and cursor position.
|
|
let _s=@/
|
|
let l = line(".")
|
|
let c = col(".")
|
|
|
|
" Do the business:
|
|
execute a:command
|
|
|
|
" Clean up: restore previous search history, and cursor position
|
|
let @/=_s
|
|
call cursor(l, c)
|
|
endfunction
|
|
|
|
nnoremap <silent> <Leader>n :call ToggleLineNumbers()<CR>
|