set nocompatible filetype off set runtimepath+=~/.vim/bundle/vundle/ call vundle#rc() Bundle 'L9' Bundle 'FuzzyFinder' Bundle 'surround.vim' Bundle 'kien/ctrlp.vim' Bundle 'sgur/ctrlp-extensions.vim' Bundle 'kana/vim-metarw' Bundle 'kana/vim-metarw-git' Bundle 'motemen/git-vim' Bundle 'motemen/vim-guess-abbrev' Bundle 'motemen/tap-vim' Bundle 'Lokaltog/vim-easymotion' Bundle 'wombat256.vim' Bundle 'desert-warm-256' Bundle 'vim-coffee-script' Bundle 'surround.vim' Bundle 'nginx.vim' Bundle 'scala.vim' Bundle 'smartchr' Bundle 'petdance/vim-perl' Bundle 'pangloss/vim-javascript' Bundle 'briancollins/vim-jst' Bundle 'groenewege/vim-less' Bundle 'slim-template/vim-slim' " Bundle 'Valloric/YouCompleteMe' " Bundle 'ervandew/supertab' Bundle 'VimClojure' Bundle 'closetag.vim' Bundle 'terryma/vim-expand-region' Bundle 'https://github.com/plasticboy/vim-markdown.git' Bundle 'kana/vim-textobj-user' Bundle 'kana/vim-textobj-syntax' Bundle 'kana/vim-textobj-lastpat' Bundle 'thinca/vim-textobj-function-perl' Bundle 'mjbrownie/html-textobjects' Bundle 'leafgarland/typescript-vim' Bundle 'motemen/vim-help-random' Bundle 'motemen/vim-syntax-dockerfile' Bundle 'gre/play2vim' " auto-pairs {{{ Bundle 'motemen/auto-pairs' let g:AutoPairsSkipToNextClosedPair = 0 let g:AutoPairsDisableJustBeforeChar = 1 let g:AutoPairsMapCR = 0 let g:AutoPairsMapSpace = 0 " }}} Bundle 'editorconfig/editorconfig-vim' Bundle 'thinca/vim-qfreplace' """ Go {{{ " if strlen($GOROOT) > 0 " set runtimepath+=$GOROOT/misc/vim " endif " " Bundle 'nsf/gocode', {'rtp': 'vim/'} Bundle 'fatih/vim-go' """ }}} " TypeScript {{{ Bundle 'clausreinke/typescript-tools' let g:TSS = [ expand('~/.vim/bundle/typescript-tools/bin/tss') ] " }}} Bundle 'junegunn/fzf' Bundle 'wellle/targets.vim' Bundle 'mattn/ctrlp-ghq' syntax on filetype plugin indent on if &term =~ 'screen' autocmd BufEnter * if bufname('') !~ '^\[A-Za-z0-9\]*://' | silent! exe '!echo -n "k+' . expand('%:t') . '\\"' | endif endif set tabstop=8 set shiftwidth=4 set softtabstop=4 set expandtab set autoindent set smartindent set listchars=tab:▸\ ,trail:$ set list set virtualedit=block set scrolloff=1 set isfname+=- set timeoutlen=400 set noequalalways set concealcursor=n set backspace=indent,eol,start set number set numberwidth=4 set nobackup "set backupcopy=no set hidden "set switchbuf=useopen,split set foldmethod=marker set tags=tags,TAGS set ignorecase set smartcase set incsearch set hlsearch set wrapscan set showmatch set nowarn set notagbsearch set updatetime=400 set path^=lib,modules/*/lib,templates set wildmode=list:longest,list:full set wildmenu set wildignore=*.o,*.hi,*.obj,*.sw?,blib*,cover_db* set complete-=i set completeopt=menu,longest set fileencodings=ucs-bom,utf-8,euc-jp,cp932 ",ucs-2le,utf-16 set fileformats=unix,dos set termencoding=utf-8 set encoding=utf-8 set ambiwidth=single set cmdheight=2 set showcmd set laststatus=2 set cpoptions+=F set statusline=[%n]%m\ %(%1*%{GitBranch()}%*\ %)%f\ %<%h%w%r%y[%{&fenc!=''?&fenc:&enc}][%{&ff}]%=[%{Cwd()}]\ %l,%c%V\ %4P set cedit= set history=1000 set shortmess+=A set splitright set grepprg=git\ grep\ -n set pastetoggle= nnoremap cd :lcd %:p:h nnoremap : vnoremap : iabbrev shfit shift iabbrev sfhit shift iabbrev sfhti shift iabbrev sfthi shift iabbrev sefl self iabbrev sned send iabbrev arsg args iabbrev lenght length iabbrev argumetns arguments nnoremap j gj nnoremap k gk vnoremap j gj vnoremap k gk nnoremap g :redraw!:redrawstatus! nnoremap g :execute 'normal' '^' . v:count . "\" nnoremap g :execute 'normal' '^' . v:count . "\" nnoremap gi :!gi nnoremap gI gi nnoremap z :pclose:cclose nnoremap zt inoremap u "inoremap u "inoremap u "inoremap u "inoremap u inoremap u inoremap inoremap inoremap :update inoremap pumvisible() ? "\" : smartchr#one_of('->', '=>') " inoremap pumvisible() ? "\" : "\" " inoremap pumvisible() ? "\" : "\" cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap b cnoremap f cnoremap cnoremap =expand('%:h').'/' cnoremap =getcmdtype()=='/'?'/0':'' :nohlsearch cnoremap getcmdline() == '' ? '!' : getcmdline() == '!' ? "\TmuxSplitRun " : "\" nnoremap gs0 :echo synIDattr(synID(line('.'), col('.'), 1), 'name') nnoremap gs1 :echo synIDattr(synID(line('.'), col('.'), 0), 'name') nnoremap gs nnoremap gt nnoremap gT nnoremap  gT nnoremap nnoremap ^ search('^\s*\%#\S', 'n') ? '0' : '^' " Q nnoremap gq q " QuickFix nnoremap . :cnext nnoremap , :cprev nnoremap u :update nnoremap m :update:make nnoremap nnoremap :set hlsearch! nnoremap / :set hlsearch/ nnoremap ? :set hlsearch? nnoremap * :set hlsearch* nnoremap qo :botright copen nnoremap qc :cclose nnoremap qn :cnext nnoremap qp :cprev nnoremap qq :cc nnoremap qf :cfile nnoremap q nnoremap Qo :lopen nnoremap Qn :lnext nnoremap Qp :lprev nnoremap Qc :lclose nnoremap QO :lopen nnoremap QN :lnext nnoremap QP :lprev nnoremap QC :lclose nnoremap QQ :ll nnoremap Q nnoremap Y y$ cnoremap "\grep" . (len(@/) ? ' ' . substitute(@/, '^\\<\(.*\)\\>', '-w \1', '') : '') nmap [Space] nmap [Space] let mapleader='0' " gabbrev {{{ inoremap gabbrev#i_start() let g:gabbrev#keyword_ch_pattern = '[[:alnum:]:]' " }}} " surround let g:surround_no_mappings = 1 nmap ds Dsurround " fuzzyfinder {{{ let g:fuf_autoPreview = 0 let g:fuf_previewHeight = 5 let g:fuf_smartBs = 0 let g:fuf_keyOpenTabpage = '' let g:fuf_keyPreview = '' let g:fuf_buffer_keyDelete = '' let g:fuf_enumeratingLimit = 300 let g:fuf_maxMenuWidth = 100 let g:fuf_splitPathMatching = 0 nnoremap :FufFile nnoremap :FufVCSAll nnoremap :FufVCSAll nnoremap g :FufFileWithCurrentBufferDir nnoremap m :FufMruFile nnoremap t :FufTab nnoremap ] :FufTag nnoremap q :FufQuickfix nnoremap :FufBuffer cnoremap getcmdtype() =~ '[/?]' ? ":FufLine! " . getcmdline() . "" : '' augroup vimrc-fuf autocmd! autocmd FileType fuf inoremap " autocmd FileType fuf inoremap :FufRenewCache autocmd FileType fuf inoremap :FufRenewCache autocmd FileType fuf inoremap =fuf#launch('coveragefile', '', '') ? '' : '' autocmd FileType fuf inoremap =fuf#file#renewCache() ? '' : '' augroup END if exists('*neocomplcache#disable') autocmd BufEnter \[fuf\] silent call neocomplcache#disable() endif if exists('*fuf#addMode') autocmd VimEnter * call fuf#addMode('tab') endif let g:fuf_modesDisable = ['mrucmd','coveragefile','bookmarkfile','bookmarkdir'] autocmd VimEnter * call fuf#addMode('vcsall') " }}} " tap.vim {{{ autocmd FileType tap-result nnoremap m :call tap#prove(b:tap_arg) " }}} noremap K nnoremap * *N nnoremap :update nnoremap nnoremap / :split/ command! -range=% Source silent split `=tempname()` | silent put=getbufline('#', , ) | silent write | source % | bwipeout """ Plugin settings """ " Git let git_highlight_blame = 1 let git_no_map_default = 1 nnoremap gd :GitDiff -M --no-prefix nnoremap gD :GitDiff -M --cached --no-prefix nnoremap gs :GitStatus nnoremap ga :GitAdd nnoremap gA :GitAdd -u nnoremap gc :GitCommit nnoremap gp :GitPullRebase " CtrlP let g:ctrlp_extensions = ['ghq', 'quickfix', 'cmdline', 'yankring', 'tag', 'perldoc'] let g:ctrlp_prompt_mappings = { \ 'PrtBS()': ['',''], \ 'PrtDelete()': [''], \ 'PrtDeleteWord()': [''], \ 'PrtClear()': [''], \ 'PrtSelectMove("j")': ['', ''], \ 'PrtSelectMove("k")': ['', ''], \ 'PrtHistory(-1)': [''], \ 'PrtHistory(1)': [''], \ 'AcceptSelection("e")': ['', '<2-LeftMouse>'], \ 'AcceptSelection("h")': ['', '', ''], \ 'AcceptSelection("t")': ['', ''], \ 'AcceptSelection("v")': ['', '', ''], \ 'ToggleFocus()': [''], \ 'ToggleRegex()': [''], \ 'ToggleByFname()': [''], \ 'ToggleType(1)': ['', '', ''], \ 'PrtExpandDir()': [''], \ 'PrtCurStart()': [''], \ 'PrtCurEnd()': [''], \ 'PrtCurLeft()': [''], \ 'PrtCurRight()': [''], \ 'PrtClearCache()': [''], \ 'PrtDeleteMRU()': [''], \ 'CreateNewFile()': [''], \ 'MarkToOpen()': [''], \ 'OpenMulti()': [''], \ 'PrtExit()': ['', '', ''], \ } let g:ctrlp_max_depth = 10 let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files'] let g:ctrlp_use_caching = 1 let g:ctrlp_clear_cache_on_exit = 1 let g:ctrlp_map = 'g' " lightline {{{ Bundle 'itchyny/lightline.vim' let g:lightline = {} let g:lightline.component = { 'filename': '%f' } let g:lightline.active = { \ 'left': [ [ 'mode', 'paste' ], \ [ 'bufnum', 'gitbranch' ], \ [ 'readonly', 'filename', 'modified' ] \ ], \ 'right': [ [ 'cwd' ], \ [ 'lineinfo' ], \ [ 'fileformat', 'fileencoding', 'filetype' ] \ ] \ } let g:lightline.inactive = { \ 'left': [ [ 'bufnum' ], [ 'filename' ] ] \ } let g:lightline.component_function = { \ 'cwd': 'Cwd', \ 'gitbranch': 'GitBranch' \ } " }}} " nnoremap  :let g:ctrlp_default_input = 0:CtrlPMixed " nnoremap  :let g:ctrlp_default_input = 0:CtrlPMixed " nnoremap t :let g:ctrlp_default_input = 0:CtrlPTag " nnoremap t :let g:ctrlp_default_input = 0:CtrlPTag " nnoremap p :call ctrlp#init(ctrlp#perldoc#id()) nnoremap p :call ctrlp#init(ctrlp#perldoc#id()) nnoremap g :call ctrlp#init(ctrlp#ghq#id()) " override runtime autoload/ctrlp.vim redir => sc_names silent scriptnames redir END let s:ctrlp_sid = matchstr(sc_names, '\zs[0-9]\+\ze: \S\+autoload/ctrlp\.vim') function! ctrlp#buffers(...) let ids = sort(filter(range(1, bufnr('$')), \ 'getbufvar(v:val, "&bl") && strlen(bufname(v:val))'), ''.s:ctrlp_sid.'_compmreb') retu a:0 && a:1 == 'id' ? ids : map(ids, 'fnamemodify(bufname(v:val), ":.")') endf " easymotion let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyz0123456789' let g:EasyMotion_grouping = 1 " syntax/sh.vim let g:is_bash = 1 " TOhtml let html_number_lines = 0 let html_use_css = 1 autocmd BufRead *.tt setfiletype html autocmd BufNewFile,BufReadPost *.t setlocal filetype=perl autocmd BufRead *.psgi setfiletype perl """ autocmds """ autocmd BufWritePost,FileWritePost {*.vim,*vimrc} if &autoread | source | endif autocmd Filetype html,xml,xsl,xhtml,markdown runtime plugin/closetag.vim | inoremap =GetCloseTag() autocmd QuickFixCmdPre * silent botright pedit \*preview\* | 99wincmd w | silent enew autocmd QuickFixCmdPost {make*,grep*,vim*,c*} if len(filter(getqflist(), 'v:val.bufnr')) | else | pclose | endif autocmd InsertLeave * set nopaste function! Cwd() if exists('b:Cwd') && exists('b:cwd') && b:cwd == getcwd() return b:Cwd endif if !exists('g:statusline_cwd_maxlen') let g:statusline_cwd_maxlen = winwidth(0) / 3 endif let delim = has('win32') ? '\' : '/' let b:cwd = fnamemodify(getcwd(), ':~') let components = split(b:cwd, '[\\/]', 1) let cwd = join(components, delim) let i = 0 while len(components) > i && len(cwd) > g:statusline_cwd_maxlen let cwd = join(map(components[0:i], 'v:val[0]') + components[i+1:], delim) let i += 1 endwhile let b:Cwd = substitute(cwd, '/*$', '', '') let t:cwd = b:cwd return b:Cwd endfunction command! -nargs=1 -complete=file Move file | silent write | call delete(expand('#')) augroup vimrc-cd-to-project-dir autocmd! autocmd BufEnter * if !exists('t:cwd') | call s:cd_to_project_dir() | endif nnoremap cD :call cd_to_project_dir() function! s:cd_to_project_dir() if len(&buftype) return endif let dir = system('cd "' . expand('%:p:h') . '"; git rev-parse --show-toplevel 2>/dev/null') let dir = substitute(dir, '\n', '', '') if v:shell_error == 0 && strlen(dir) && isdirectory(dir) execute 'lcd' fnameescape(dir) if exists('b:git_dir') unlet b:git_dir endif endif endfunction augroup END function! s:SpacesAsAbove() let [lnum, col] = getpos('.')[1:2] let line_above = getline(lnum - 1) if col >= len(line_above) return "\" endif let string_ahead = matchstr(line_above, '\%' . (col + 1) . 'c\S*\s*') let len = strlen(string_ahead) return repeat(' ', len + 1) endfunction inoremap pumvisible() ? "\" : SpacesAsAbove() augroup vimrc-auto-mkdir autocmd! autocmd BufWritePre * call s:auto_mkdir(expand(':p:h')) function! s:auto_mkdir(dir) if !isdirectory(a:dir) call mkdir(a:dir, 'p') endif endfunction augroup END " tmux "command! -nargs=* -complete=shellcmd TmuxSplitRun let _cmd = len() ? shellescape(substitute( . '; read' , '%', expand('%'), '')) : '' | let tmux_run_command = printf('tmux if-shell "tmux select-pane -t.1" "send-keys ^C" \; if-shell "tmux respawn-pane -t.1 %s" "select-window" "split-window -d -v -p 30 %s"', _cmd, _cmd) | ruby `#{VIM::evaluate('tmux_run_command')}` command! -nargs=* -complete=shellcmd -bang TmuxSplitRun \ let _cmd = len() ? shellescape(substitute( . '; read' , '%', expand('%'), '')) : '' | \ let tmux_cmd = printf('tmux if-shell "tmux select-pane -t.1" "send-keys ^C" \; if-shell "tmux respawn-pane -t.1 %s" "select-window" "split-window -d -v -p 30 %s"%s', _cmd, _cmd, len('') ? ' \; resize-pane -Z' : '') | \ call system(tmux_cmd) nnoremap ! :TmuxSplitRun nnoremap m :update:execute 'TmuxSplitRun' &makeprg augroup vimrc-add-highlights autocmd! autocmd ColorScheme * call s:add_highlights() function! s:add_highlights() highlight clear MatchParen highlight MatchParen term=bold gui=bold cterm=bold highlight CursorLine ctermbg=NONE highlight CursorColumn ctermbg=NONE highlight Pmenu ctermbg=grey ctermfg=236 highlight Pmenusel ctermbg=lightblue ctermfg=236 highlight Pmenuselbar ctermbg=grey highlight Folded ctermbg=240 ctermfg=252 cterm=NONE highlight TabLine cterm=underline ctermbg=NONE highlight Title cterm=underline highlight Search ctermbg=cyan ctermfg=black highlight Visual cterm=NONE ctermbg=yellow ctermfg=black highlight StatusLine ctermbg=236 highlight StatusLineNC ctermbg=236 highlight Normal ctermbg=none highlight User1 ctermbg=NONE ctermfg=2 highlight SpecialKey ctermfg=DarkGray endfunction augroup END colorscheme desert-warm-256 command! -nargs=1 -complete=custom,PerlModules Perldoc new | :call Perldoc() command! -nargs=* -range GitBrowseRemote !git browse-remote --rev -L, -- % " nnoremap :call UpdateCtags():normal! \ function! UpdateCtags() if stridx(expand('%:p'), getcwd()) != 0 return 0 end for tagfile in tagfiles() if getftime(tagfile) > getftime(expand('%')) return 0 endif endfor !ctags -R $(git ls-tree --name-only HEAD) endfunction function! PerlModules(arg_lead, cmd_line, cursor_ops) return system('pm-packages.pl --local') endfunction function! Perldoc(args) if !&modifiable || &modified || bufname('%') != '' throw 'Perldoc: cannot use this buffer' endif let bufname = '[perldoc ' . a:args . ']' if bufexists(bufname) execute 'buffer' bufnr(fnameescape(bufname)) return endif enew let perldoc = 'perldoc' if isdirectory('local/lib/perl5') let perldoc = 'PERL5OPT=-Ilocal/lib/perl5 ' . perldoc end setlocal buftype=nofile silent execute '0read!' . perldoc . ' -otext -T' a:args if v:shell_error let message = getline(1) bwipeout echohl Error echo message echohl None else let b:perldoc_args = a:args file `=bufname` setlocal noswapfile nomodifiable setfiletype man nnoremap s :edit `=system('perldoc -l ' . b:perldoc_args)` 0 endif endfunction augroup pm-autoinsert-package autocmd! autocmd BufNewFile *.pm call append(0, [ \ 'package ' . fnamemodify(expand('%'), ':r:s.^lib/..:gs./.::.') . ';', \ 'use strict;', 'use warnings;' \ ]) \ | call append(line('$'), '1;') \ | set modified augroup END augroup gemfile-autoinsert-source autocmd! autocmd BufNewFile Gemfile call append(0, "source 'https://rubygems.org'") | set modified augroup END finish