" Basic settings {{{ let mapleader = "\" let g:yankround_max_history = 50 set bs=start,indent,eol set whichwrap+=h,l,<,>,[,],b,s " encode set encoding=utf-8 set swapfile " clipbord set clipboard+=unnamed " save nnoremap w :w " save and close nnoremap x :x " quick not save nnoremap q :q " search highlight clear nnoremap :noh " search set incsearch set ignorecase set smartcase set wrapscan " }}} " Edit settings {{{ " remove trailing whitespace autocmd BufWritePre * :%s/\s\+$//ge " }}} " Display settings {{{ syntax enable " folding set foldmethod=marker set foldcolumn=2 set foldlevel=0 " tabline set expandtab set laststatus=2 set tabstop=2 set shiftwidth=2 set softtabstop=2 " listchars set list set listchars=tab:>.,trail:_,extends:>,precedes:< " linenumber set number " cursorline line set cursorline " search highlight set hlsearch " title set title " markdown autocmd BufRead,BufNew *.md set filetype=markdown " color {{{ set background=dark colorscheme solarized let g:solarized_termtrans=1 if &term =~ "xterm-256color" || "screen-256color" let g:solarized_termcolors=256 set t_Co=256 else let g:solarized_termcolors=16 set t_Co=16 endif " }}} " }}} " NeoBundle {{{ if has("vim_starting") set runtimepath+=~/.vim/bundle/neobundle.vim/ endif call neobundle#begin(expand('~/.vim/bundle/')) " color scheme NeoBundle "altercation/vim-colors-solarized" " unite NeoBundle 'Shougo/unite.vim' NeoBundle 'Shougo/neomru.vim' NeoBundle 'basyura/unite-rails' " ctag NeoBundle 'szw/vim-tags' NeoBundle 'tsukkee/unite-tag' " syntax NeoBundle 'mxw/vim-jsx' NeoBundle 'tpope/vim-haml' NeoBundle 'kchmck/vim-coffee-script' NeoBundle 'slim-template/vim-slim' NeoBundle 'plasticboy/vim-markdown' NeoBundle 'elixir-lang/vim-elixir' " git NeoBundle 'cohama/agit.vim' NeoBundle 'tpope/vim-fugitive' NeoBundle 'airblade/vim-gitgutter' " development NeoBundle 'tpope/vim-rbenv' NeoBundle 'tpope/vim-bundler' NeoBundle 'vim-ruby/vim-ruby' NeoBundle 'thoughtbot/vim-rspec' NeoBundle 't9md/vim-ruby-xmpfilter' NeoBundle 'tpope/vim-rails' NeoBundle 'pangloss/vim-javascript' NeoBundle 'wakatime/vim-wakatime' " operation NeoBundle 'kien/ctrlp.vim' NeoBundle 'matze/vim-move' NeoBundle 'kana/vim-submode' NeoBundle 'tpope/vim-endwise' NeoBundle 'ervandew/supertab' NeoBundle 'kana/vim-smartinput' NeoBundle 'osyo-manga/vim-over' NeoBundle 'Yggdroot/indentLine' NeoBundle 'junegunn/vim-easy-align' NeoBundle 'scrooloose/nerdcommenter' NeoBundle 'tpope/vim-surround' " syntax check NeoBundle 'scrooloose/syntastic' " preview NeoBundle 'kannokanno/previm' NeoBundle 'tyru/open-browser.vim' NeoBundle 'itchyny/lightline.vim' NeoBundle 'tpope/vim-dispatch' NeoBundle 'tpope/vim-pathogen' NeoBundle 'Shougo/vimproc.vim', { \ 'build' : { \ 'windows' : 'tools\\update-dll-mingw', \ 'cygwin' : 'make -f make_cygwin.mak', \ 'mac' : 'make -f make_mac.mak', \ 'linux' : 'make', \ 'unix' : 'gmake', \ }, \ } call neobundle#end() filetype plugin indent on NeoBundleCheck " }}} " Setting for plugin {{{ " unite let g:unite_enable_start_insert=1 let g:unite_source_history_yank_enable =1 nnoremap [unite] nmap f [unite] nnoremap [unite]f :Unite file nnoremap [unite]b :Unite buffer nnoremap [unite]r :Unite register nnoremap [unite]h :Unite history/yank nnoremap [unite]d :Unite directory_mru nnoremap [unite]m :Unite buffer file_mru nnoremap [unite]a :UniteWithBufferDir -buffer-name=files file au FileType unite nnoremap unite#do_action('split') au FileType unite inoremap unite#do_action('split') au FileType unite nnoremap unite#do_action('vsplit') au FileType unite inoremap unite#do_action('vsplit') " unite-grep nnoremap [unite]r :UniteResume search-buffer nnoremap [unite]g :Unite grep:. -buffer-name=search-buffer nnoremap [unite]cg :Unite grep:. -buffer-name=search-buffer if executable('ag') let g:unite_source_grep_command = 'ag' let g:unite_source_grep_default_opts = '--nogroup --nocolor --column' let g:unite_source_grep_recursive_opt = '' endif " unite-tag nnoremap t autocmd BufEnter * \ if empty(&buftype) \| nnoremap tt :UniteWithCursorWord -immediately tag \| nnoremap tk :Unite jump \| endif " unite-rails noremap [unite]rc :Unite rails/controller noremap [unite]rcf :Unite rails/config noremap [unite]rm :Unite rails/model noremap [unite]rv :Unite rails/view noremap [unite]rh :Unite rails/helper noremap [unite]rs :Unite rails/stylesheet noremap [unite]rj :Unite rails/javascript noremap [unite]rr :Unite rails/route noremap [unite]rg :Unite rails/gemfile noremap [unite]rt :Unite rails/spec noremap [unite]rl :Unite rails/lib " vim-tags let g:vim_tags_auto_generate = 0 let g:vim_tags_ignore_files = ['.gitignore', '.svnignore', '.cvsignore', '*.js'] " over-vim nnoremap e :OverCommandLine %s/ vnoremap e :OverCommandLine s/ " nerdcommenter let NERDSpaceDelims = 1 vmap NERDCommenterToggle " vim-move let g:move_key_modifier = 'C' " indentLine let g:indentLine_color_term = 239 let g:indentLine_char = '¦' " vim-easy-align vmap (EasyAlign) nmap ga (EasyAlign) " bundle noremap bi :Dispatch bundle install " vim-ruby-xmpfilter autocmd FileType ruby nmap (xmpfilter-mark) autocmd FileType ruby xmap (xmpfilter-mark) autocmd FileType ruby imap (xmpfilter-mark) autocmd FileType ruby nmap (xmpfilter-run) autocmd FileType ruby xmap (xmpfilter-run) autocmd FileType ruby imap (xmpfilter-run) " vim-gitgutter let g:gitgutter_sign_added = '✚' let g:gitgutter_sign_modified = '➜' let g:gitgutter_sign_removed = '✘' " vim-fugitive nnoremap [git] nmap g [git] nnoremap [git]b :Gblame nnoremap [git]s :Gstatus nnoremap [git]d :Gdiff nnoremap [git]c :Gcommit nnoremap [git]C :Gcommit -v " syntastic let g:syntastic_mode_map = { 'mode': 'passive' } augroup AutoSyntastic autocmd! autocmd BufWritePost * call s:syntastic() augroup END function! s:syntastic() SyntasticCheck call lightline#update() endfunction " markdown syntax autocmd BufNewFile,BufRead *.{md,mdwn,mkd,mkdn,mark*} set filetype=markdown let g:previm_open_cmd = '' nnoremap [previm] nmap p [previm] nnoremap [previm]o :PrevimOpen nnoremap [previm]r :call previm#refresh() " light-line let g:lightline = { \ 'colorscheme': 'solarized', \ 'mode_map': { 'c': 'NORMAL' }, \ 'active': { \ 'left': [ \ ['mode', 'paste'], \ ['fugitive', 'gitgutter', 'filename'], \ ], \ 'right': [ \ [ 'syntastic', 'lineinfo' ], \ [ 'percent' ], \ [ 'fileformat', 'fileencoding', 'filetype' ], \ ] \ }, \ 'component_expand': { \ 'syntastic': 'SyntasticStatuslineFlag', \ }, \ 'component_type': { \ 'syntastic': 'error', \ }, \ 'component_function': { \ 'modified': 'MyModified', \ 'readonly': 'MyReadonly', \ 'fugitive': 'MyFugitive', \ 'filename': 'MyFilename', \ 'fileformat': 'MyFileformat', \ 'filetype': 'MyFiletype', \ 'fileencoding': 'MyFileencoding', \ 'gitgutter': 'MyGitGutter', \ 'mode': 'MyMode', \ }, \ 'separator': { 'left': '⮀', 'right': '⮂' }, \ 'subseparator': { 'left': '⮁', 'right': '⮃' } \ } function! MyModified() return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-' endfunction function! MyReadonly() return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? '⭤' : '' endfunction function! MyFilename() return ('' != MyReadonly() ? MyReadonly() . ' ' : '') . \ (&ft == 'vimfiler' ? vimfiler#get_status_string() : \ &ft == 'unite' ? unite#get_status_string() : \ &ft == 'vimshell' ? vimshell#get_status_string() : \ '' != expand('%:t') ? expand('%:t') : '[No Name]') . \ ('' != MyModified() ? ' ' . MyModified() : '') endfunction function! MyFugitive() if &ft !~? 'vimfiler\|gundo' && exists("*fugitive#head") let _ = fugitive#head() return strlen(_) ? '⭠ '._ : '' endif return '' endfunction function! MyGitGutter() if ! exists('*GitGutterGetHunkSummary') \ || ! get(g:, 'gitgutter_enabled', 0) \ || winwidth('.') <= 90 return '' endif let symbols = [ \ g:gitgutter_sign_added . ' ', \ g:gitgutter_sign_modified . ' ', \ g:gitgutter_sign_removed . ' ' \ ] let hunks = GitGutterGetHunkSummary() let ret = [] for i in [0, 1, 2] if hunks[i] > 0 call add(ret, symbols[i] . hunks[i]) endif endfor return join(ret, ' ') endfunction function! MyFileformat() return winwidth(0) > 70 ? &fileformat : '' endfunction function! MyFiletype() return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : '' endfunction function! MyFileencoding() return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : '' endfunction function! MyMode() return winwidth(0) > 60 ? lightline#mode() : '' endfunction " }}} " Window settings {{{ " split nnoremap ss :sp nnoremap sv :vs " move nnoremap sj j nnoremap sk k nnoremap sl l nnoremap sh h nnoremap sJ J nnoremap sK K nnoremap sL L nnoremap sH H " size nnoremap s= = call submode#map('bufmove', 'n', '', '>', '>') call submode#map('bufmove', 'n', '', '<', '<') call submode#map('bufmove', 'n', '', '+', '+') call submode#map('bufmove', 'n', '', '-', '-') call submode#enter_with('bufmove', 'n', '', 's>', '>') call submode#enter_with('bufmove', 'n', '', 's<', '<') call submode#enter_with('bufmove', 'n', '', 's+', '+') call submode#enter_with('bufmove', 'n', '', 's-', '-') " }}}