" Initialize " # runtimepath {{{ if has('win32') " INFO: .vimrc unifies vimrc " .vim unifies vimfiles set runtimepath^=$HOME/.vim set runtimepath+=$HOME/.vim/after endif " }}} " # encoding {{{ " Note: Kaoriya MacVim is needless encoding. if !has('gui_macvim') || !has('kaoriya') " INFO: If encode is fixed, :e ++enc = {encoding-name} set encoding=utf-8 set fileencodings=utf-8,shiftjis,euc-jp,iso-2022-jp endif if has('win32') set encoding=utf-8 set termencoding=&encoding set fileencodings=utf-8,cp932,shiftjis,euc-jp,iso-2022-jp endif " }}} " # Basic "{{{ "filetype plugin indent on set nocompatible " Use Vim defaults (much better!) set showcmd " Highliting bracket set. set hidden " Enable open new file, when while editing other file. set autoread set history=255 set viminfo='20,\"50 " Read/write a .viminfo file, don't store more than 50 lines of registers set backspace=indent,eol,start " Allow backspacing over everything in insert mode set ambiwidth=double set virtualedit+=block " Block-select to the end of the line for blockwise Visual mode. set shortmess+=filmnrxoOtT " Avoid all the hit-enter prompts set title set completeopt=menuone " チラツキ防止 set helplang=ja,en nnoremap :help let mapleader = " " " }}} " Local Dependency set nobackup noswapfile let g:my_config_use_plugin = get(g:, 'my_config_use_plugin', 0) let $MYVIMRC_LOCAL = $HOME . '/.vimrc.local' if filereadable(expand($MYVIMRC_LOCAL)) set backup swapfile " INFO: Read more .vimrc.local.dist source $MYVIMRC_LOCAL let $MYVIMRC = g:local_config['dotfiles_dir'] . '/.vimrc' " Quick start my vimrc nnoremap e. :edit $MYVIMRC nnoremap eS :source $MYVIMRC " Use weekly buffer for GTD. nnoremap :call weekly_buffer#open() " Load settings for each location {{{ augroup load_local_config autocmd! autocmd BufNewFile,BufReadPost * call s:load_rc_local(expand(':p:h')) augroup END function! s:load_rc_local(loc) let files = findfile('.vimrc.local', escape(a:loc, ' ') . ';', -1) for i in reverse(filter(files, 'filereadable(v:val)')) source `=i` endfor endfunction " }}} " Bundle {{{ if g:my_config_use_plugin && !exists('g:loaded_neobundle') source $HOME/.vim/bundle.vim let s:bundle_dir = $HOME . '/.vim/bundle' endif " }}} endif let s:tmpdir = exists('g:local_config["tmp_dir"]') \ ? g:local_config['tmp_dir'] \ : $HOME " # Switch ; <-> : {{{ " Warning: Don't use ':remap' as possible (for Unaffected). nnoremap ; : nnoremap : ; vnoremap ; : vnoremap : ; nnoremap q; q: vnoremap q; q: " }}} " # Syntax {{{ if has('syntax') syntax enable set synmaxcol=1500 set nospell "scriptencoding utf-8 set list " - tab: タブ文字, trail: 行末スペース, eol: 改行文字, extends: 行末短縮, precedes: 行頭短縮, nbsp: 空白文字 set listchars=tab:»-,extends:>,precedes:<,eol:↲,nbsp:%,trail:-,nbsp:> augroup ZenSpace autocmd! autocmd ColorScheme * highlight ZenSpace cterm=reverse ctermfg=DarkMagenta gui=reverse guifg=DarkMagenta autocmd WinEnter,BufNew,BufReadPost,ColorScheme * \ if &filetype !~ 'unite\|vimshell\|vimfiler\|git\|rst' \ | match ZenSpace / \|\s\+$/ | \ endif augroup END if v:version >= 703 set relativenumber endif set number set numberwidth=4 endif " }}} " # Indent {{{ set autoindent set expandtab " replaced Tab with Indent setlocal tabstop=4 setlocal shiftwidth=4 setlocal softtabstop=0 :let g:vim_indent_cont = 2 " }}} " # Filetype Detect {{{ " Moved ~/.vim/filetype.vim let g:sql_type_default = 'mysql' " SQL " }}} " # Color Scheme {{{ set t_Co=256 if !has('gui_runnig') || !g:my_config_use_plugin || !exists('g:colors_name') let g:colors_name = 'desert' set background=dark endif let g:solarized_termcolors = 256 " CASE: g:colors_name is solarized " Add cursorline at the current window. augroup cch autocmd! autocmd WinLeave * set nocursorline autocmd WinEnter,BufRead * set cursorline augroup END let g:apache_version = '2.0' " apache highliting " highlighting target of long line. if exists('&colorcolumn') set colorcolumn=+1 "nnoremap l :setspell!list!colorcolumn=-1 nnoremap l :setlist!colorcolumn=-1 endif "# HIGHLIGHT_CURRENT_LINE nnoremap hs :HighlightCurrentLine Search nnoremap hd :HighlightCurrentLine DiffAdd nnoremap he :HighlightCurrentLine Error nnoremap H :UnHighlightCurrentLine command! -nargs=1 HighlightCurrentLine execute 'match /%'.line('.').'l/' command! -nargs=0 UnHighlightCurrentLine match " }}} " # Console {{{ " By Sir.thinca http://d.hatena.ne.jp/thinca/20101215/1292340358 if has('unix') && !has('gui_running') " Use meta keys in console. function! s:use_meta_keys() " {{{2 for i in map( \ range(char2nr('a'), char2nr('z')) \ + range(char2nr('A'), char2nr('Z')) \ + range(char2nr('0'), char2nr('9')) \ , 'nr2char(v:val)') " O do not map because used by arrow keys. if i != 'O' execute 'nmap ' . i '' endif endfor endfunction " }}}2 call s:use_meta_keys() map map! " stopped job nnoremap gZZ :set t_te = t_ti = :quit:set t_te& t_ti& nnoremap gsh :set t_te = t_ti = :st:set t_te& t_ti& nnoremap gst :set t_te = t_ti = :st:set t_te& t_ti& endif " }}} " # Status Bar {{{ set ruler set showcmd set showmode set cmdheight=1 set wildmenu set wildmode=list:longest,full set laststatus=2 set statusline=%<%f\ #%n%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%y%=%l,%c%V%8P "set statusline=[%{winnr('$')>1?.winnr().'/'.winnr('$'):}]\ %<\ %f\ %m%r%h%w%y%{'['.(&fenc!=''?&fenc:&enc).'\|'.&ff.']'}%=%l/%L\ (%P) " }}} " # {{{ set showtabline=2 " :h tabline nnoremap tn :tabnew nnoremap :tabnext nnoremap :tabprevious " }}} " # Search {{{ set hlsearch " Highlight search option set incsearch " Typed so far, matches set ignorecase " Ignoring case in a pattern set smartcase " Override ignorecase option (search contains upper case). set nowrapscan " Searches nowrap around. nnoremap * *N nnoremap # #N " regex pattern nnoremap \ /^ " }}} " # Copy & Paste {{{ "set paste " When you're setting paste, can't use inoremap extend ;-< if has('clipboard') set clipboard=unnamed,autoselect " For Ubuntu "+y not * (;h clipboard) " Copy vnoremap "+y " Paste vnoremap d"+P cnoremap + inoremap "+pa " source $VIMRUNTIME/mswin.vim endif " }}} " # Insert {{{ inoremap { {} inoremap [ [] inoremap ( () inoremap \| \|\| inoremap " "" inoremap ' '' inoremap ` `` inoremap \|\| \| inoremap "" " inoremap '' ' inoremap `` ` inoremap cnoremap { {} cnoremap [ [] cnoremap ( () cnoremap \| \|\| cnoremap "" "" cnoremap '' '' cnoremap `` `` cnoremap \|\| \|\| " Support Input Date inoremap ,df strftime('%Y-%m-%d %H:%M') inoremap ,dd strftime('%Y-%m-%d') inoremap ,dt strftime('%H:%M:%S') " Input vertical serial number nnoremap co :ContinuousNumber vnoremap co :ContinuousNumber command! -count -nargs=1 ContinuousNumber \ let c = col('.') \ | for n in range(1, ?-line('.'):1) \ | exec 'normal! j' . n . \ | call cursor('.', c) \ | endfor " }}} " # Yank {{{ " Like nmap 'D' and 'C' nnoremap Y y$ " カーソル位置の単語をヤンクした単語に置換 nnoremap cy ciw0:let@/=@1:noh nnoremap ciy ce0:let@/=@1:noh " }}} " # IME Control {{{ " insert mode, IME off set noimdisable set iminsert=0 imsearch=0 set noimcmdline inoremap :set iminsert=0 inoremap :set iminsert=0 inoremap :set iminsert=0 if has('multi_byte_ime') augroup MutibyteIMEStrategy autocmd! autocmd ColorScheme * highlight Cursor guifg=#000d18 guibg=#8faf9f gui=bold autocmd ColorScheme * highlight CursorIM guifg=NONE guibg=#ecbcbc augroup END endif augroup InsModeAu autocmd! autocmd InsertEnter,CmdwinEnter * set noimdisable autocmd InsertLeave,CmdwinLeave * set imdisable augroup END " }}} " # Moving Cursole {{{ augroup MovementPreviousSaveLine autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") \ | exe "normal g`\"" | \ endif augroup END " for snippet complete nnoremap j gj onoremap j gj xnoremap j gj nnoremap k gk onoremap k gk xnoremap k gk nnoremap gj j nnoremap gk k nnoremap nnoremap " .bash like " but up-down mapped j-k inoremap 0 inoremap $ inoremap inoremap inoremap inoremap inoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap nnoremap cw ciw nnoremap dw diw inoremap ciw " selected at last editting text. "" ちなみにVisualModeで最後に選択したテキストのに戻るはgv nnoremap gc '[v'] vnoremap gc :normal gc onoremap gc :normal gc " vim-users.jp Hack #214 nnoremap ) f) nnoremap ( f( onoremap ) f) onoremap ( f( vnoremap ) f) vnoremap ( f( " Only do this part, when compiled with support for autocommands augroup RedHatEnterpriseNantoka "{{{2 " When editing a file, always jump to the last cursor position autocmd BufReadPost * \ if line("'\"") > 0 && line ("'\"") <= line("$") \ | exe "normal! g'\"" | \ endif augroup END "}}} " }}} " # Window {{{ " FIXME: When setted winmin(height|width), errored unite-outline "set winminheight=8 "set winminwidth=20 "set winfixheight "set winfixwidth set splitright " Default vsplit, left set splitbelow " Default split, top " vim-users.jp Hack #42 "nnoremap h h:call good_width() "nnoremap l l:call good_width() "nnoremap H H:call good_width() "nnoremap L L:call good_width() function! s:good_width() "{{{2 if winwidth(0) < 84 && &ft != 'taglist' && &ft != 'quickrun' vertical resize 84 endif endfunction "}}}2 set noequalalways " Minimize Window Size " }}} " # Buffer {{{ " Inspaired @taku-o's Kwdb.vim :com! Kwbd let kwbd_bn= bufnr("%")|enew|exe "bdel ".kwbd_bn|unlet kwbd_bn nnoremap d ::Kwbd " }}} " # Fold, View {{{ nnoremap f za set foldcolumn=4 " INFO: foldlevel moved to each fplugin "set foldlevel=0 set fillchars+=fold:- " Don't save options. set viewoptions-=options if has('win32') set viewoptions+=unix endif augroup MkviewAccessor " Save fold settings. Vim-user.jp Hack #84 autocmd! autocmd BufWritePost * \ if expand('%') !~ 'vim\|php\|ruby' \ | exe "mkview" | \ endif autocmd BufRead * \ if expand('%') !~ 'vim\|php\|ruby' \ | exe "silent loadview" | \ endif augroup END " }}} " # Directory {{{ " disabled autochdir depends to Vimshell "set autochdir augroup AutoChDir autocmd! au BufEnter * execute ":silent! lcd " . escape(expand("%:p:h"), ' ') augroup END " Change directory. vim-users.jp Hack #69 nnoremap CD :CD nnoremap gu :GU " nmap `gh` is using vim-rooter nnoremap gH :GH command! -nargs=? -complete=dir -bang CD call s:ChangeCurrentDir('', '') command! -nargs=? -complete=dir -bang GU call s:ChangeCurrentDir('../', '') command! -nargs=? -complete=dir -bang GH call s:ChangeCurrentDir('$HOME', '') function! s:ChangeCurrentDir(directory, bang) "{{{2 if a:directory == '' lcd %:p:h else execute 'lcd' . a:directory endif if a:bang == '' pwd endif endfunction "}}} " }}} " # Dictionary {{{ set dictionary=$HOME/.vim/dict/default.dict "inoremap " FIXME: duplicate mapping " }}} " # Ctags {{{ if has('path_extra') && &filetype !~ 'zsh\|conf' setlocal tags=~/tags setlocal tags+=. if filereadable("tags") setlocal tags+=tags endif if filereadable("tags-ja") setlocal tags+=tags-ja endif set showfulltag set notagbsearch endif " }}} " # Cscope {{{ "if has("cscope") && filereadable("/usr/bin/cscope") " set csprg=/usr/bin/cscope " set csto=0 " set cst " set nocsverb " " add any database in current directory " if filereadable("cscope.out") " cs add cscope.out " " else add database pointed to by environment " elseif $CSCOPE_DB != "" " cs add $CSCOPE_DB " endif " set csverb "endif " }}} " # Migemo {{{ " Howto: g/, g? if has('migemo') set migemo endif " }}} " # Omni complete {{{ " omni_complete, completed each ftplugin inoremap " }}} " # Undo persistence {{{ if has('persistent_undo') augroup UndoPersistence autocmd! autocmd BufReadPost * call ReadUndo() autocmd BufWritePost * call WriteUndo() augroup END function! ReadUndo() "{{{2 let undo_file = substitute(expand('%:p'), '\/\|\\', '\_', 'g') if filereadable(&undodir .'/'. undo_file) execute 'rundo' &undodir.'/'.undo_file endif endfunction "}}} function! WriteUndo() "{{{2 if !isdirectory(&undodir) call mkdir(&undodir) endif let undo_file = substitute(expand('%:p'), '\/\|\\', '\_', 'g') execute 'wundo' &undodir.'/'.undo_file endfunction "}}} endif " }}} " Plugin if !g:my_config_use_plugin echo "INFO: g:my_config_use_plugin is 0 or not defined. and no reading plugin settings" finish " ここまで読んだらお前は死ぬ endif " Plugin: vimproc {{{ "let g:vimproc_dll_path = s:bundle_dir . '/vimproc/autoload' " }}} " Plugin: vim-airline {{{ let g:airline_theme = 'badwolf' "let g:airline_left_sep = '»' let g:airline_left_sep = '▶' "let g:airline_right_sep = '«' let g:airline_right_sep = '◀' let g:airline_linecolumn_prefix = '␊ ' let g:airline_linecolumn_prefix = '␤ ' let g:airline_linecolumn_prefix = '¶ ' let g:airline_branch_prefix = '⎇ ' let g:airline_paste_symbol = 'ρ' let g:airline_paste_symbol = 'Þ' let g:airline_paste_symbol = '∥' let g:airline_enable_branch = 1 let g:airline_enable_syntastic = 1 let g:airline_detect_modified = 1 let g:airline_detect_paste = 1 let g:airline_powerline_fonts = 0 " }}} " Plugin: vim-powerline {{{ "let g:Powerline_cache_file = s:tmpdir . '/Powerline.cache' "let g:Powerline_symbols = 'fancy' "let g:Powerline_theme = 'solarized256' "let g:Powerline_colorscheme = 'solarized256' " }}} " Plugin: calendar.vim {{{ let g:calendar_wruler = '日 月 火 水 木 金 土 ' let g:calendar_weeknm = 1 " WK01 " }}} " Plugin: taglist.vim {{{ if has('path_extra') nnoremap tl :Tlist let g:Tlist_Exit_OnlyWindow = 1 " Closable When last window is taglist let g:Tlist_WinWidth = 40 let g:Tlist_Enable_Fold_Column = 2 "let g:Tlist_Process_File_Always = 1 "let g:Tlist_Show_One_File = 1 endif " }}} " Plugin: submode.vim {{{ " Reside window call submode#enter_with('winsize', 'n', '', '>', '>') call submode#enter_with('winsize', 'n', '', '<', '<') call submode#enter_with('winsize', 'n', '', '+', '-') call submode#enter_with('winsize', 'n', '', '-', '+') call submode#map('winsize', 'n', '', '>', '>') call submode#map('winsize', 'n', '', '<', '<') call submode#map('winsize', 'n', '', '+', '-') call submode#map('winsize', 'n', '', '-', '+') " }}} " Plugin: context_filetype.vim {{{ let g:context_filetype#filetypes = { \ 'perl6' : [{ \ 'start' : 'Q:PIR\s*{', \ 'end' : '}', \ 'filetype' : 'pir', \ }], \ 'vim' : [{ \ 'start' : '^\s*python <<\s*\(\h\w*\)', \ 'end' : '^\1', \ 'filetype' : 'python', \ }], \ 'markdown': [{ \ 'start' : '^\s*```\s*\(\h\w*\)', \ 'end' : '^\s*```$', \ 'filetype' : '\1', \ }], \} " }}} " Plugin: indent-guides {{{ " INFO: auto highlight indent-space. let g:indent_guides_color_change_percent = 30 let g:indent_guides_guide_size = 1 let g:indent_guides_enable_on_vim_startup = 1 " }}} " Plugin: matchit.vim {{{ " INFO: Extended % command. "if filereadable($HOME . '/macros/matchit.vim') if filereadable(s:bundle_dir . '/matchit.zip/plugin/matchit.vim') runtime macros/matchit.vim let b:match_words = 'if:endif' let b:match_ignorecase = 1 endif " }}} " Plugin: vim-textmanip {{{ xmap (Textmanip.move_selection_down) xmap (Textmanip.move_selection_up) xmap (Textmanip.move_selection_left) xmap (Textmanip.move_selection_right) " copy selected text-object. vmap (Textmanip.duplicate_selection_v) "}}} " Plugin: visualstar.vim {{{ " search extended plugin. if exists('g:loaded_visualstar') map * (visualstar-*)N map # (visualstar-#)N endif " }}} " Plugin: alignta {{{ vnoremap > :Alignta => " @todo add json type " ex.) 'hoge': jojo " 'jojolion': jojo let g:unite_source_alignta_preset_arguments = [ \ ["Align at '='", '=>\='], \ ["Align at ':'", '01 :'], \ ["Align at '|'", '|' ], \ ["Align at ')'", '0 )' ], \ ["Align at ']'", '0 ]' ], \ ["Align at '}'", '}' ], \] let s:comment_leadings = '^\s*\("\|#\|/\*\|//\|'], \ ["Margin 0:0", '0' ], \ ["Margin 0:1", '01' ], \ ["Margin 1:0", '10' ], \ ["Margin 1:1", '1' ], \ \ 'v/' . s:comment_leadings, \ 'g/' . s:comment_leadings, \] unlet s:comment_leadings " }}} " Plugin: QuickRun, Quicklaunch & xUnit {{{ let g:quickrun_config = get(g:, 'quickrun_config', {}) "nnoremap r :QuickRun -runner vimproc:90 -split 'rightbelow 50vsp' nnoremap r :QuickRun -runner vimproc:updatetime=10 -split 'rightbelow 50vsp' if has('clientserver') "if has('clientserver') && !empty(v:servername) let b:quickrun_config = { \ 'runner/vimproc' : 90, \ 'runner/vimproc/updatetime' : 90, \ } let g:quickrun_config = { \ '_' : { \ 'runner/vimproc' : 90, \ 'runner/vimproc/updatetime' : 90, \ 'outputter' : 'buffer', \ 'splist' : '{"rigitbelow 50vsp"}', \ }, \ 'run/vimproc' : { \ 'exec' : '%s:p:r %a', \ 'runner' : 'vimproc', \ 'outputter' : 'buffer', \ }, \ 'ruby' : { \ 'command' : 'irb', \ 'cmdopt' : '--simple-prompt', \ 'runner' : 'process_manager', \ 'runner/process_manager/load' : "load '%s'", \ 'runner/process_manager/prompt' : '>> ', \ }, \ 'ruby.rspec' : { \ 'command' : "rspec -l {line('.')", \ }, \ 'php.phpunit' : { \ 'command' : 'phpunit', \ }, \ 'phpunit.php' : { \ 'command' : 'phpunit', \ }, \ 'javascript' : { \ 'command' : 'phantomjs', \ }, \ } if exists('g:sphinx_build_bin') let g:quickrun_config['rst'] = { \ 'command': g:sphinx_build_bin, \ 'hook/sphinx/enable' : 1, \ 'cmdopt': '-b html', \ 'splist' : '{"rigitbelow 65vsp"}', \ } endif endif if has('mac') " TODO: Sikuli 起動は引数渡さねば?? "let g:quickrun_config['python.sikuli'] = { " \ 'command': '/Applications/Sikuli-IDE.app/sikuli-ide.sh', " \ } elseif has('win32') else " Linux let g:quickrun_config['php.phpunit'] = { 'command' : 'phpunit' } endif " TODO: Add QuickRun's syntax for xUnit family "autocmd BufAdd,BufNew,BufNewFile,BufRead [quickrun output] set syntax=xUnit " }}} " Plugin: TweetVim {{{ let g:tweetvim_config_dir = s:tmpdir . '/tweetvim' let g:tweetvim_include_rts = 1 " }}} " Plugin: jscomplatete.vim {{{ let g:jscomplete_use = ['dom'] " }}} " Plugin: dbext.vim {{{ let g:dbext_default_history_file = s:tmpdir . '/dbext_sql_history.sql' " }}} " Plugin: Emmet.vim (Replaced from zenconding.vim) {{{ let g:user_emmet_mode = 'a' let g:user_emmet_leader_key = '' let g:use_emmet_complete_tag = 1 let g:user_emmet_settings = { \ 'lang' : 'ja', \ 'html' : { \ 'filters' : 'html', \ 'indentation' : ' ' \ }, \ 'perl' : { \ 'indentation' : ' ', \ 'aliases' : { \ 'req' : "require '|'" \ }, \ 'snippets' : { \ 'use' : "use strict\nuse warnings\n\n", \ 'w' : "warn \"${cursor}\";", \ }, \ }, \ 'php' : { \ 'extends' : 'html', \ 'filters' : 'html,c', \ }, \ 'css' : { \ 'filters' : 'fc', \ }, \ 'javascript' : { \ 'snippets' : { \ 'jq' : "$(function() {\n\t${cursor}${child}\n});", \ 'jq:each' : "$.each(arr, function(index, item)\n\t${child}\n});", \ 'fn' : "(function() {\n\t${cursor}\n})();", \ 'tm' : "setTimeout(function() {\n\t${cursor}\n}, 100);", \ }, \ }, \ 'haml': { \ 'extends': 'html', \ } \ } "}}} " Plugin: neocomplete {{{ let g:neocomplete#enable_at_startup = 1 let g:neocomplete#max_list = 30 let g:neocomplete#max_keyword_width = 20 let g:neocomplete#auto_completion_start_length = 3 let g:neocomplete#manual_completion_start_length = 3 let g:neocomplete#min_keyword_length = 5 "let g:neocomplete#enable_ignore_case = 'ignorecase' let g:neocomplete#enable_smart_case = 'infercase' let g:neocomplete#enable_insert_char_pre = 1 " Really?? let g:neocomplete#enable_auto_select = 1 let g:neocomplete#data_directory = s:tmpdir . '/neocomplete' let g:neocomplete#use_vimproc = 1 "if !exists('g:neocomplete#same_filetypes') "let g:neocomplete#same_filetypes = {} "endif "let g:neocomplete#same_filetypes.twig = 'twig' " : close popup and save indent. inoremap =my_cr_function() function! s:my_cr_function() "return neocomplete#smart_close_popup() . "\" " For no inserting key. return pumvisible() ? neocomplete#close_popup() : "\" endfunction " }}} " Plugin: neosnippet {{{ let g:neosnippet#snippets_directory = \ s:bundle_dir . 'neocomplcache-snippets-complete/autoload/neocomplcache/sources/snippets_complete' \ .','. $HOME . '/.vim/snippets' " TODO: Update phpunit snippet for neosnippet "\ .','. s:bundle_dir . '/vim-phpunit-snippets/snippets' "\ .','. s:bundle_dir . '/neocomplcache-phpunit-snippet/autoload/neocomplcache/sources/snippets_complete' nmap (neosnippet_expand_or_jump) imap (neosnippet_expand_or_jump) smap (neosnippet_expand_or_jump) "imap (neocomplcache_start_unite_complete) imap (neosnippet_start_unite_snippet) " For snippet_complete marker. if has('conceal') set conceallevel=2 concealcursor=i endif " Onetime :p nnoremap ns :NeoSnippetEdit " For snippet_complete marker. if has('conceal') set conceallevel=2 concealcursor=i endif " }}} " Plugin: vim-rooter {{{ silent! nmap gh RooterChangeToRootDirectory let g:rooter_manual_only = 1 let g:rooter_use_lcd = 1 let g:rooter_patterns = [ \ '.git/', '.hg/', \ 'Gemfile', 'Rakefile', 'Guardfile', \ 'Vagrantfile', \ 'composer.json', \ 'build.xml', \ 'build.gradle', \ ] let g:rooter_change_directory_for_non_project_files = 0 " }}} " Plugin: vim-vcs {{{ let g:vcs#config_log_file = s:tmpdir . '/vcs' " }}} " Plugin: vim-fugitive {{{ " Gstatus " * Gstatus上の変更のあったファイルにカーソルを合わせた状態で " Dで:Gdiff起動(差分表示) " -でstageとunstageの切り替え " pでパッチを表示 " Enterでファイル表示 " Cでcommit " * :help Gstatus nnoremap gb :Gblame nnoremap gd :Gdiff nnoremap gD :Gdiff --cached nnoremap gs :Gstatus nnoremap ga :Gwrite nnoremap gA :Gwrite nnoremap gc :Gcommit "}}} " Plugin: vimfiler {{{ let s:bundle = neobundle#get('vimfiler') function! s:bundle.hooks.on_source(bundle) let g:vimfiler_as_default_explorer = 1 let g:vimfiler_split_action = 'left' "let g:vimfiler_execute_file_list = 'vim' let g:vimfiler_ignore_pattern = '^.*\%(.git\|.DS_Store\|.idea\|.iml\)$' let g:vimfiler_edit_action = 'open' let g:vimfiler_sort_type = 'filename' let g:vimfiler_time_format = "%y-%m-%d %H:%M" " Note: This variable works in file source. "let g:vimfiler_enable_auto_cd = 1 let g:vimfiler_data_directory = s:tmpdir . '/vimfiler' let g:vimfiler_time_format = "%y-%m-%d %H:%M" " Enable file operation commands. "let g:vimfiler_safe_mode_by_default = 0 " Like Textmate icons. let g:vimfiler_tree_leaf_icon = ' ' let g:vimfiler_tree_opened_icon = '▾' let g:vimfiler_tree_closed_icon = '▸' let g:vimfiler_file_icon = '-' let g:vimfiler_marked_file_icon = '*' if has('win32') let g:unite_kind_file_use_trashbox = s:tmpdir . '/vimfiler_trashbox' endif "augroup StartupWithVimFiler " {{{ " autocmd! " autocmd VimEnter * VimFiler " \ -buffer-name=explorer -split -simple -winwidth=40 -toggle -no-quit " \ -auto-cd=1 "augroup END " }}} endfunction nnoremap : :VimFilerSplit -winwidth=45 augroup VimFilerUniteAction " {{{ autocmd! autocmd FileType vimfiler call unite#custom_default_action('directory', 'lcd') augroup END " }}} " }}} " Plugin: vimshell {{{ "let s:bundle = neobundle#get('vimshell') "function! s:bundle.hooks.on_source(bundle) let g:vimshell_temporary_directory = s:tmpdir . '/.vimshell' "let g:vimshell_right_prompt = 'vcs#info("(%s)-[%b]", \\"(%s)-[%b|%a]")' let g:vimshell_enable_smart_case = 1 let g:vimshell_enable_auto_slash = 1 let g:vimshell_max_command_history = 200 let g:vimshell_max_list = 15 let g:vimshell_split_height = 22 let g:vimshell_split_command = 'split' " almost paste from vimshll-examples " Initialize execute file list. let g:vimshell_execute_file_list = {} "call vimshell#set_execute_file('txt,vim,c,h,cpp,d,xml,java', 'vim') let g:vimshell_execute_file_list['rb'] = 'ruby' let g:vimshell_execute_file_list['pl'] = 'perl' let g:vimshell_execute_file_list['py'] = 'python' let g:vimshell_execute_file_list['php'] = 'php' let g:vimshell_execute_file_list['git'] = 'git' "call vimshell#set_execute_file('html,xhtml', 'gexe firefox') "let g:vimshell_user_prompt = 'fnamemodify(getcwd(), \\":~")' "let g:vimshell_right_prompt = 'vcs#info("(%s)-[%b]", \\"(%s)-[%b|%a]")' let g:my_host_prompt = stridx(hostname(), '.') > 0 \ ? hostname()[ : stridx(hostname(), '.') - 1] \ : hostname() if has('win32') || has('win64') " Display user name on Windows. "let g:vimshell_prompt = $USERNAME." % " let g:vimshell_user_prompt = printf( \ '"%s\n┌[" .$USERNAME."@".%s. "]" ." - ". "[" .%s. "]"' \ , '"☁ ". fnamemodify(getcwd(), ":p:h")' \ , 'g:my_host_prompt' \ , 'fnamemodify(getcwd(), ":~")' \ ) else " Display user name on Linux. " TODO: $USER . hostname() の省略系を表示できるようにする let g:vimshell_user_prompt = printf( \ '"┌[" .$USER."@".%s. "]" ." - ". "[" .%s. "]"' \ , 'g:my_host_prompt' \ , 'fnamemodify(getcwd(), ":~")' \ ) "call vimshell#set_execute_file('bmp,jpg,png,gif', 'gexe eog') call vimshell#set_execute_file('mp3,m4a,ogg', 'gexe amarok') let g:vimshell_execute_file_list['zip'] = 'zipinfo' call vimshell#set_execute_file('tgz,gz', 'gzcat') call vimshell#set_execute_file('tbz,bz2', 'bzcat') endif let g:vimshell_prompt = '└[☁ ] ' "let g:vimshell_right_prompt = 'fnamemodify(getcwd(), ":p:h")' augroup VimshellFileTypeDetect autocmd! autocmd FileType vimshell \ call vimshell#altercmd#define('g', 'git') \| call vimshell#altercmd#define('h', 'hg') \| call vimshell#altercmd#define('i', 'iexe') \| call vimshell#altercmd#define('l', 'll') \| call vimshell#altercmd#define('a', 'ls -al') \| call vimshell#altercmd#define('ll', 'ls -l') \| call vimshell#altercmd#define('la', 'ls -al') \| call vimshell#altercmd#define('cl', 'clear') \| call vimshell#hook#add('chpwd', 'my_chpwd', 'g:my_chpwd') augroup END function! g:my_chpwd(args, context) call vimshell#execute('ls') endfunction "endfunction " }}} " Plugin: unite.vim {{{ let g:unite_data_directory = \ get(g:, 'local_unite_data_directory', s:tmpdir . '/unite') let g:unite_enable_start_insert = 1 " Save session automatically. " For unite-session. " Load session automatically. let g:unite_source_session_enable_auto_save = 1 "autocmd VimEnter * UniteSessionLoad " window options let g:unite_winheight = 12 let g:unite_split_rule = 'below' let g:unite_source_file_mru_limit = 120 let g:unite_update_time = 256 " mru options let g:unite_source_file_mru_filename_format = '' let g:unite_source_file_mru_limit = 200 " history options let g:unite_source_history_yank_enable = 1 let g:unite_source_history_yank_limit = 100 " color options let g:unite_cursor_line_highlight = 'PmenuSel' "let g:unite_abbr_highlight = 'TabLine' " aliases let g:unite_source_alias_aliases = get(g:, 'unite_source_alias_aliases', {}) let g:unite_source_alias_aliases.workspace = { \ 'source': 'file', \ 'args': '~/workspace', \ } let g:unite_source_alias_aliases.workspace_rec = { \ 'source': 'file_rec', \ 'args': '~/workspace', \ } " source menus let g:unite_source_menu_menus = get(g:, 'unite_source_menu_menus', {}) let g:unite_source_menu_menus.shortcut = \ { \ 'description' : '', \ 'command_candidates' : [ \ ['edit vimrc', 'edit $MYVIMRC'], \ ['edit vimrc.local', 'edit $MYVIMRC_LOCAL'], \ ['edit gvimrc', 'edit $MYGVIMRC'], \ ['edit gvimrc.local', 'edit $MYGVIMRC_LOCAL'], \ ], \ } let g:unite_source_menu_menus.interactive_chan = \ { \ 'description': '', \ 'command_candidates': [ \ ['ruby', 'VimShellInteractive ruby'], \ ['python', 'VimShellInteractive python'], \ ], \ } " ignore match patterns (Default: autoload/unite/source/file.vim) let g:unite_source_file_ignore_pattern = \ '^\%(/\|\a\+:/\)$\|\%(^\|/\)\.\.\?$\|\~$\|\.\%(o|exe|dll|bak|sw[po]|vimundo|app|\)$' let g:unite_source_directory_mru_ignore_pattern = \ '\%(^\|/\)\.\%(hg\|git\|bzr\|svn\|vimundo\)\%($\|/\)\|^\%(\\\\\|/mnt/\|/media/\|/Volumes/\)' let g:unite_source_file_rec_ignore_pattern = \ '\%(^\|/\)\.$\|\~$\|\.\%(o\|exe\|dll\|bak\|sw[po]\|vimundo\)$\|\%(^\|/\)\.\%(hg\|git\|bzr\|svn\)\%($\|/\)' "call unite#set_substitute_pattern('file', '\$\w\+', '\=eval(submatch(0))', 200) "call unite#set_substitute_pattern('file', '[^~.]\zs/', '*/*', 20) "call unite#set_substitute_pattern('file', '/\ze[^*]', '/*', 10) "call unite#set_substitute_pattern('file', '^@@', '\=fnamemodify(expand("#"), ":p:h")."/*"', 2) "call unite#set_substitute_pattern('file', '^@', '\=getcwd()."/*"', 1) "call unite#set_substitute_pattern('file', '^\\', '~/*') "call unite#set_substitute_pattern('file', '^;v', '~/.vim/*') "call unite#set_substitute_pattern('file', '^;r', '\=$VIMRUNTIME."/*"') "call unite#set_substitute_pattern('file', '\*\*\+', '*', -1) "call unite#set_substitute_pattern('file', '^\~', escape($HOME, '\'), -2) "call unite#set_substitute_pattern('file', '\\\@ :Unite file_mru nnoremap :Unite buffer_tab "nnoremap :UniteBookmarkAdd " }}} " Plugin: unite-tag {{{ let g:unite_tig_default_line_count = 80 "nnoremap :Unite -immediately -no-start-insert tags:=expand('') autocmd BufEnter * \ if empty(&buftype) \ | nnoremap :UniteWithCursorWord -immediately tag | \ endif " }}} " Plugin: unite-sf2 {{{ " NOTE: unite-sf2 avairables is depends local environment. "let g:unite_source_sf2_root_dir = $HOME . '/workspace/sandbox/Studies/symfony-standard' "let g:unite_source_sf2_bundles = get(g:, 'unite_source_sf2_bundles', {}) " }}} " Plugin: unite-grep {{{ let g:unite_source_grep_default_opts = '-Hn' " By the default let g:unite_source_grep_recursive_opt = '-R' " By the default " }}} " Plugin: vim-ref & ref-unite {{{ let g:ref_cache_dir = s:tmpdir . '/ref_cache' " TODO: Pydocも日本語の使えるようにしなくては nnoremap :Ref if exists('g:local_config["ref_phpmanual_path"]') let g:ref_phpmanual_path = g:local_config['ref_phpmanual_path'] else let g:ref_phpmanual_cmd = 'w3m -dump %s' endif if exists('g:local_config["ref_jquery_path"]') let g:ref_jquery_path = g:local_config['ref_jquery_path'] else let g:ref_jquery_cmd = 'w3m -dump %s' endif if has('mac') let g:ref_alc_cmd = 'lynx -dump -display_charset=' . &encoding . ' -nonumbers %s' endif "let g:ref_refe_cmd = '/usr/bin/refe' " webdict let g:ref_source_webdict_sites = { \ 'weblio': { \ 'url': 'http://ejje.weblio.jp/content/%s', \ 'keyword_encoding': 'utf-8', \ 'cache': 1, \ }, \ 'wikipedia:ja': 'http://ja.wikipedia.org/wiki/%s', \ } " 出力に対するフィルタ。最初の数行を削除している。 function! g:ref_source_webdict_sites.weblio.filter(output) return join(split(a:output, "\n")[18 :], "\n") endfunction let g:ref_source_webdict_sites.default = 'weblio' " My ref filetype mapping let g:ref_cmd_filetype_map = { \ 'python': 'pydoc', \ 'perl': 'perldoc', \ 'php': 'php', \ } " \ 'php.phpunit' : 'phpunit', " }}} " Forked Plugin: vim-php-cs-fixer {{{ let g:php_cs_fixer_default_mapping = 1 " Enable the mapping by default (pcd) let g:php_cs_fixer_path = "/usr/sbin/php-cs-fixer/php-cs-fixer" " define the path to the php-cs-fixer.phar let g:php_cs_fixer_level = "all" " which level ? let g:php_cs_fixer_config = "default" " configuration "let g:php_cs_fixer_php_path = "php" " Path to PHP let g:php_cs_fixer_fixers_list = "" " List of fixers let g:php_cs_fixer_dry_run = 0 " Call command with dry-run option let g:php_cs_fixer_use_sudo = 1 " Call command with dry-run option " }}} " My Plugin: vim-multiple-switcher {{{ "let g:multiple_switcher_no_default_key_maps = 1 nnoremap ,p :call multiple_switcher#switch('paste') nnoremap ,e :call multiple_switcher#switch('expandtab') nnoremap ,w :call multiple_switcher#switch('wrap') vnoremap ,n :call multiple_switcher#switch('number') " }}} " My Plugin: vim-sunday {{{ let g:sunday_pairs = [ \ ['light', 'dark'], \ ['extends', 'implements'], \ ['assert', 'depends', 'dataProvider', 'expectedException', 'group', 'test'], \ ['pick', 'squash', 'edit', 'reword', 'fixup', 'exec'], \ ] " }}} " # [unite] Mappings "{{{ " The prefix key. nnoremap [unite] xnoremap [unite] nmap e [unite] xmap e [unite] nnoremap [unite]f :UniteWithCurrentDir \ -buffer-name=files buffer bookmark file "nnoremap [unite]f :Unite file nnoremap [unite]F :Unite file_rec nnoremap [unite]w :Unite workspace \ -buffer-name=files buffer bookmark file nnoremap [unite]W :Unite workspace_rec \ -buffer-name=files buffer bookmark file -input=!vendor nnoremap [unite]a :Unite alignta:options xnoremap [unite]a :Unite alignta:arguments nnoremap [unite]m :Unite mark nnoremap [unite]M :Unite menu nnoremap [unite]b :Unite buffer nnoremap [unite]B :Unite bookmark -default-action=vimshell nnoremap [unite]u :Unite resume source nnoremap [unite]o :Unite outline nnoremap [unite]t :Unite tig -no-start-insert -no-quit -no-split "nnoremap [unite]t :Unite tig -no-start-insert -no-quit -winheight=12 nnoremap [unite]T :Unite -buffer-name=search line \ -winheight=10 -no-quit \ todo\\|fixme\\|warn\\|hackme " for current buffer nnoremap [unite]g :Unite grep:%:-iR: " for all buffer nnoremap [unite]G :Unite grep:$:-iR: nnoremap [unite]l :Unite line -no-split -winheight=20 nnoremap [unite]c :Unite colorscheme -auto-preview nnoremap [unite]h :Unite history/command nnoremap [unite]p :Unite process -no-split nnoremap [unite]y :Unite history/yank nnoremap [unite]s :Unite snippet nnoremap [unite]n :Unite neobundle/install:! -no-start-insert -auto-quit nnoremap [unite]N :Unite neobundle/install -no-start-insert -auto-quit " NOTE: @ftplugin, r is :Unite ref/$filetype " if @ftplugin is nothing, default map is :Unite ref/ "nnoremap [unite]r :Uniteref/ nmap [unite]r (ref_filetype_complete) nnoremap ? :Unite -buffer-name=search line -winheight=10 -no-quit "nnoremap S :Unitesf2/ "nnoremap sb :Unite sf2/bundles "nnoremap sc :Unite sf2/app/config "}}} " # Mappings "{{{ nnoremap f " change just before buffer nnoremap a :b# nnoremap ,b :b# " open-browser.vim nmap o (openbrowser-smart-search) " vimshell nnoremap s :VimShell nnoremap vs :VimShell nnoremap vS :VimShellPop " vimfiler nnoremap vf :VimFiler -buffer-name=explorer -split -simple -winwidth=35 -toggle -no-quit " Quickhl nmap m (quickhl-toggle) xmap m (quickhl-toggle) nmap M (quickhl-reset) xmap M (quickhl-reset) nmap j (quickhl-match) " TweetVim nnoremap t :TweetVimHomeTimeline nnoremap tl :TweetVimHomeTimeline nnoremap ts :TweetVimSay " }}} " vim:set fdm=marker ts=2 sw=2 sts=0 expandtab filetype=vim: