" Kanari Sugoi .vimrc " Rules {{{ " Mapping {{{ " " * Emacs-like mapping " - If the command is not countable or motion, " it should be mapped with "" or "" prefixed binding " - The command for global scene should be mapped with "" prefix, " but the command which depends on buftype or filetype should be mapped with " "" prefix. " - Separating global and buffer/file local mapping is very important to use " mappings efficiency. " " }}} " NeoBundle {{{ " " * Managing " - Options for "NeoBundleLazy" should be only "build", "depends", and other " options which are only related of installing, building, and updating. " - Other options such as "autoload" and plugin's own settings should be " set in their each "neobundle#tap()" sections. " - Separating plugins' list and their configuration sections is very " important. " " }}} " }}} " Basic {{{ " Absolute {{{ " Use VIM features instead of vi " It canses many side effects, so you need to write the top of the ".vimrc". set nocompatible " Reset Autocmd group augroup MyAutoCmd autocmd! augroup END " To use camel_case. let g:My = {} let s:my = g:My " Echo startup time on start if has('vim_starting') && has('reltime') let g:startuptime = reltime() augroup MyAutoCmd autocmd! VimEnter * let g:startuptime = reltime(g:startuptime) | redraw \ | echomsg 'startuptime: ' . reltimestr(g:startuptime) augroup END endif " .vim folder " Maybe I will never use other os than OS X... if has('unix') let $VIM_DOTVIM_DIR=expand('~/.vim') else let $VIM_DOTVIM_DIR=expand('~/.vim') endif let $MYVIMRC = resolve(expand('~/.vimrc')) let $VIM_REMOTE_BUNDLE_DIR = $VIM_DOTVIM_DIR . '/bundle' let $VIM_LOCAL_BUNDLE_DIR = $VIM_DOTVIM_DIR . '/local_bundle' let $VIM_NEOBUNDLE_DIR = $VIM_REMOTE_BUNDLE_DIR . '/neobundle.vim' let $VIM_SWAP_DIR = $VIM_DOTVIM_DIR . '/tmp/swap' let $VIM_BACKUP_DIR = $VIM_DOTVIM_DIR . '/tmp/backup' let $VIM_UNDO_DIR = $VIM_DOTVIM_DIR . '/tmp/undo' " }}} " Encoding {{{ " let &termencoding = &encoding set encoding=utf-8 set fileencoding=utf-8 set fileencodings=ucs-bom,utf-8,iso-2022-jp-3,iso-2022-jp,eucjp-ms,euc-jisx0213,euc-jp,sjis,cp932 set fileformats=unix,dos,mac " }}} " Functions {{{ function! s:set(variable, value) " {{{ execute printf("let &%s = a:value", a:variable) endfunction " }}} function! s:path_separator() " {{{ if has('win32') || has('win64') return ';' else return ':' endif endfunction " }}} function! s:prepend_path(current, path) " {{{ return a:current == '' ? \ a:path : a:path . s:path_separator() . a:current endfunction " }}} function! s:append_path(current, path) " {{{ return a:current == '' ? \ a:path : ( a:current . s:path_separator() . a:path ) endfunction " }}} function! s:dirname(path) " {{{ return fnamemodify(a:path, ':h') endfunction " }}} function! s:get_list(scope, name) " {{{ return get(a:scope, a:name, []) endfunction " }}} function! s:add_to_uniq_list(list, element) " {{{ return index(a:list, a:element) == -1 ? \ add(a:list, a:element) : \ a:list endfunction " }}} function! SelectInteractive(question, candidates) " {{{ try let a:candidates[0] = toupper(a:candidates[0]) let l:select = 0 while index(a:candidates, l:select, 0, 1) == -1 let l:select = input(a:question . ' [' . join(a:candidates, '/') . '] ') if l:select == '' let l:select = a:candidates[0] endif endwhile return tolower(l:select) finally redraw! endtry endfunction " }}} function! BufferWipeoutInteractive() " {{{ if &modified == 1 let l:selected = SelectInteractive('Buffer is unsaved. Force quit?', ['n', 'w', 'y']) if l:selected == 'w' write bwipeout elseif l:selected == 'y' bwipeout! endif else bwipeout endif endfunction " }}} function! s:colorscheme_exists(name) " {{{ return index( \ map( \ split(globpath(&rtp, "colors/*.vim"), "\n"), \ 'matchstr(v:val, ''.*[\/]\zs.*\ze\.vim'')' \ ), a:name \ ) != -1 endfunction " }}} function! s:apply_colorscheme(names) " {{{ for name in a:names if s:colorscheme_exists(name) execute 'colorscheme ' . name break endif endfor endfunction " }}} function! s:queue_funccall(funcname, ...) " {{{ let s:queued_funccalls = get(s:, 'queued_funccalls', []) call add(s:queued_funccalls, { 'func': function(a:funcname), 'args': a:000 }) endfunction " }}} function! s:apply_queued_funccalls() " {{{ if exists('s:queued_funccalls') for dict in s:queued_funccalls call call(dict.func, dict.args, dict) endfor endif let s:queued_funccalls = [] endfunction " }}} " }}} " Environment Variables {{{ let $PATH = s:append_path($PATH, '~/bin') let $PATH = s:prepend_path($PATH, '/usr/local/bin') let $PATH = s:append_path($PATH, '/usr/local/wine/bin') let $PATH = s:append_path($PATH, '/Applications/MacVim.app/Contents/MacOS') let $PATH = s:append_path($PATH, '/Applications/Octave.app/Contents/Resources/bin') " Automatic detect current ruby's bin directory. " Including "gem", "rails", and others. let $PATH = s:append_path($PATH, s:dirname(resolve('/usr/local/bin/ruby'))) " Gnuterm let $GNUTERM = 'x11' " WINE let $WINE_CDRIVE = expand('~/.wine/drive_c/') " MetaTrader let $METALANG = '/usr/local/bin/metalang.exe' " Drip the JVM process manager if executable('drip') let $JAVACMD = '/usr/local/bin/drip' let $DRIP_INIT_CLASS = 'org.jruby.main.DripMain' let $JRUBY_OPTS = '-J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -Xverify:nine' " let $JAVA_OPTS = '-d32 -client' endif " Java {{{ " It's necessary to show Japanese messages from JDK let $LANG = 'ja_JP.UTF-8' " Set JAVA_HOME to select your favorite JDK version. let $JAVA_HOME = '/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home' let $CLASSPATH = s:append_path($CLASSPATH, '.') " The directory which contains `jfxrt.jar`. " Note that in JDK8, `jfxrt.jar` is in ext folder if match($JAVA_HOME, 'jdk1.8') != -1 let $JFX_DIR = $JAVA_HOME . '/jre/lib/ext/' else let $JFX_DIR = $JAVA_HOME . '/jre/lib/' endif " }}} " }}} " Appearance UI {{{ " Don't ring a bell and flash set vb t_vb= " Show line number set number " Always show tab set showtabline=2 " Show invisible chars set list " When input close bracket, show start bracket set showmatch " Fix zenkaku chars' width set ambiwidth=double " }}} " Appearance Font {{{ set gfn=セプテンバーM-等幅:h14 set gfw=セプテンバーM-等幅:h14 " }}} " Appearance Color theme {{{ " delay funccall for colorschemes managed by NeoBundle call s:queue_funccall('s:apply_colorscheme', [ 'railscasts', 'desert']) " }}} " Syntax {{{ syntax on " }}} " Backup {{{ call s:set('directory', $VIM_SWAP_DIR) call s:set('backupdir', $VIM_BACKUP_DIR) call s:set('undodir', $VIM_UNDO_DIR) if has('persistent_undo') set undodir=./.vimundo,$VIM_UNDO_DIR autocmd MyAutoCmd BufReadPre ~/* setlocal undofile endif " }}} " History {{{ " Command history set history=10000 " }}} " Restore{{{ " Restore last cursor position when open a file autocmd MyAutoCmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif " }}} " }}} " Edit {{{ " Indent {{{ " Use Space instead of Tab to make indent set expandtab " TODO: Width of tab? " TODO: Ato de yoku shiraberu. set tabstop=2 " Hoe many spaces to each indent level set shiftwidth=2 " Automatically adjust indent set autoindent " Automatically indent when insert a new line set smartindent " Insert an indent when keydown in indent spaces set smarttab " Symbols to use indent or other " NOTE: kakkoii unicode moji " - http://unicode-table.com/en/sections/dingbats/ " - http://unicode-table.com/en/sections/spacing-modifier-letters/ " test set listchars=tab:❯\ ,trail:˼,extends:»,precedes:«,nbsp:% " }}} " Movement {{{ " BS can delete newline or indent set backspace=indent,eol,start " Can move at eol, bol set whichwrap=b,s,h,l,<,>,[,] " }}} " Folding {{{ " Use marker to fold " e.g. {{{kanari_sugoi_code}}} " TODO: [Problem] When I input close marker which is "}" three times, " the all foldings after that will be opened... Kanari fuben. set foldmethod=marker " Open folding when move in to one " set foldopen=all " Close folding when move out of one " set foldclose=all " }}} " Search {{{ " incremental search set incsearch " Match words with ignore upper-lower case set ignorecase " Don't think upper-lower case until upper-case input set smartcase " Highlight searched words set hlsearch " }}} " Buffer Handling {{{ " Can change buffer in window no matter buffer is unsaved set hidden " }}} " Spelling {{{ " Enable spell checker for English words " set spell spelllang=en_us " }}} " TODO: Input Method {{{ " TODO: Disable Japanese input mode when exit from the insert mode " }}} " Basic Key Mapping {{{ " [Emacs] Increment, Decrement by -, + " Because I want to use for Emacs-like mapping " For test: [1, 6] nnoremap + nnoremap - " [Emacs] k to close buffer completely " nnoremap k :bw nnoremap k :call BufferWipeoutInteractive() " [Emacs] to end of line nnoremap $ " [Emacs] to delete a line nnoremap dd " Toggle 0 and ^ nnoremap 0 col('.') == 1 ? '^' : '0' nnoremap ^ col('.') == 1 ? '^' : '0' " : without nnoremap ; : vnoremap ; : " _ : Quick horizontal splits nnoremap _ :sp " | : Quick vertical splits nnoremap :vsp " N: Find next occurrence backward nnoremap N Nzzzv nnoremap n nzzzv " Backspace: Act like normal backspace " TODO: Mac OS X doesn't have . have delete key. nnoremap X " cmdwin nnoremap : q:i " TODO: Move those settings to right section autocmd MyAutoCmd CmdwinEnter [:>] iunmap autocmd MyAutoCmd CmdwinEnter [:>] nunmap " JK peropero " Use logical move instead of physical ones nnoremap j gj nnoremap k gk " Easy to make selection to pars " TODO: u-n, iranai kamo... onoremap ) f) onoremap ( t( " Insert space in normal mode easily nnoremap i nnoremap i " }}} " Filetype setting {{{ autocmd MyAutoCmd BufRead,BufNewFile *.md setfiletype markdown " }}} " }}} " Plugins {{{ " Secret {{{ " This file contains only g:vimrc_secrets. if filereadable(expand('~/.secret_vimrc')) let g:vimrc_secrets = {} execute 'source' expand('~/.secret_vimrc') endif " }}} " Setup {{{ " To use NeoBundle, manually add to runtimepath if has('vim_starting') set runtimepath+=$VIM_NEOBUNDLE_DIR " To load my local development plugin call neobundle#local(expand($VIM_LOCAL_BUNDLE_DIR), { 'resettable' : 0 }) endif " To load remote plugin call neobundle#rc(expand($VIM_REMOTE_BUNDLE_DIR)) " Let NeoBundle manage NeoBundle NeoBundleFetch 'Shougo/neobundle.vim' " }}} " List {{{ NeoBundle 'Shougo/vimproc.vim', { 'build' : { \ 'windows' : 'mingw32-make -f make_mingw32.mak', \ 'cygwin' : 'make -f make_cygwin.mak', \ 'mac' : 'make -f make_mac.mak', \ 'unix' : 'make -f make_unix.mak', \ }} " Library used in vimrc NeoBundle 'vim-jp/vital.vim' " Text object NeoBundle 'kana/vim-textobj-user' NeoBundle 'kana/vim-textobj-entire', { 'depends' : 'kana/vim-textobj-user' } NeoBundle 'kana/vim-textobj-function', { 'depends' : 'kana/vim-textobj-user' } NeoBundle 'kana/vim-textobj-indent', { 'depends' : 'kana/vim-textobj-user' } NeoBundle 'rhysd/vim-textobj-ruby', { 'depends' : 'kana/vim-textobj-user' } NeoBundle 'osyo-manga/vim-textobj-multiblock', { 'depends' : 'kana/vim-textobj-user' } NeoBundle 'osyo-manga/vim-textobj-multitextobj', { 'depends' : 'kana/vim-textobj-user' } " Operator NeoBundle 'kana/vim-operator-user' NeoBundle 'tyru/operator-html-escape.vim', { 'depends' : 'kana/vim-operator-user' } NeoBundle 'bling/vim-airline' NeoBundle 'surround.vim' NeoBundle 'kana/vim-repeat' NeoBundle 'kana/vim-submode' NeoBundle 'osyo-manga/vim-automatic', { 'depends' : [ 'osyo-manga/vim-gift', 'osyo-manga/vim-reunions' ] } NeoBundle 'osyo-manga/vim-reti', { 'depends' : [ 'osyo-manga/vim-chained' ] } NeoBundle 'osyo-manga/vim-anzu' NeoBundle 'jceb/vim-hier' NeoBundle 'LeafCage/foldCC' NeoBundle 'vim-jp/vimdoc-ja' NeoBundle 'tpope/vim-fugitive' NeoBundle 'gregsexton/gitv', { 'depends' : [ 'tpope/vim-fugitive' ] } NeoBundle 'tomtom/tcomment_vim' NeoBundle 'tpope/vim-rbenv' NeoBundle 'thinca/vim-scall' NeoBundle 'thinca/vim-singleton' NeoBundleLazy 'Shougo/unite.vim', { 'depends' : [ 'Shougo/vimproc.vim' ] } NeoBundleLazy 'Shougo/vimshell.vim', { 'depends' : [ 'Shougo/vimproc.vim' ] } NeoBundleLazy 'ujihisa/vimshell-ssh', { 'depends' : [ 'Shougo/vimshell.vim' ] } NeoBundleLazy 'Shougo/vimfiler.vim', { 'depends' : [ 'Shougo/unite.vim' ] } NeoBundleLazy 'Shougo/unite-ssh', { 'depends' : [ 'Shougo/unite.vim' ] } NeoBundleLazy 'Shougo/neosnippet.vim' NeoBundleLazy 'honza/vim-snippets' NeoBundleLazy 'matthewsimo/angular-vim-snippets' NeoBundleLazy 'Shougo/neocomplete.vim' NeoBundleLazy 'rhysd/unite-ruby-require.vim', { 'depends' : [ 'Shougo/unite.vim' ] } NeoBundleLazy 'tsukkee/unite-help', { 'depends' : [ 'Shougo/unite.vim' ] } NeoBundleLazy 'Shougo/unite-outline', { 'depends' : [ 'Shougo/unite.vim' ] } NeoBundleLazy 'ujihisa/unite-colorscheme', { 'depends' : [ 'Shougo/unite.vim' ] } NeoBundleLazy 'ujihisa/unite-locate', { 'depends' : [ 'Shougo/unite.vim' ] } NeoBundleLazy 'osyo-manga/unite-quickfix', { 'depends' : [ 'Shougo/unite.vim' ] } NeoBundleLazy 'osyo-manga/vim-pronamachang', { 'depends' : [ 'osyo-manga/vim-sound', 'Shougo/vimproc.vim' ] } NeoBundleLazy 'osyo-manga/vim-sugarpot', { 'depends' : [ 'Shougo/vimproc.vim' ] } NeoBundleLazy 'osyo-manga/vim-watchdogs', { 'depends' : [ \ 'thinca/vim-quickrun', \ 'Shougo/vimproc.vim', \ 'osyo-manga/shabadou.vim', \ 'jceb/vim-hier', \ 'dannyob/quickfixstatus' \ ] } NeoBundleLazy 'h1mesuke/vim-alignta' NeoBundleLazy 'kana/vim-smartinput' NeoBundleLazy 'cohama/vim-smartinput-endwise', { 'depends' : [ 'kana/vim-smartinput' ] } NeoBundleLazy 'mattn/gist-vim', { 'depends' : [ 'mattn/webapi-vim' ] } NeoBundleLazy 'mattn/emmet-vim' NeoBundleLazy 'thinca/vim-prettyprint' NeoBundleLazy 'thinca/vim-quickrun' NeoBundleLazy 'thinca/vim-ref' NeoBundleLazy 'thinca/vim-qfreplace' NeoBundleLazy 'thinca/vim-editvar' NeoBundleLazy 'tyru/open-browser.vim' NeoBundleLazy 'yuratomo/w3m.vim' NeoBundleLazy 'rbtnn/vimconsole.vim' NeoBundleLazy 'groenewege/vim-less' NeoBundleLazy 'slim-template/vim-slim' NeoBundleLazy 'kchmck/vim-coffee-script' NeoBundleLazy 'dsawardekar/riml.vim' NeoBundleLazy 'LeafCage/vimhelpgenerator' " Colorscheme NeoBundle 'tomasr/molokai' NeoBundle 'w0ng/vim-hybrid' NeoBundle 'altercation/vim-colors-solarized' NeoBundle 'nanotech/jellybeans.vim' NeoBundle 'chriskempson/tomorrow-theme' NeoBundle 'twilight' NeoBundle 'zazen' NeoBundle 'jonathanfilip/vim-lucius' NeoBundle 'jpo/vim-railscasts-theme' " momonga's Kanari Sugoi Plugins (Kanari) NeoBundleLazy 'supermomonga/shaberu.vim', { 'depends' : [ 'Shougo/vimproc.vim' ] } NeoBundleLazy 'supermomonga/vimshell-pure.vim', { 'depends' : [ 'Shougo/vimshell.vim' ] } NeoBundleLazy 'supermomonga/vimshell-inline-history.vim', { 'depends' : [ 'Shougo/vimshell.vim' ] } NeoBundleLazy 'supermomonga/vimshell-wakeup.vim', { 'depends' : [ 'Shougo/vimshell.vim' ] } NeoBundle 'supermomonga/projectlocal.vim' " Communication NeoBundleLazy 'tsukkee/lingr-vim' NeoBundleLazy 'basyura/J6uil.vim', { 'depends' : [ 'Shougo/vimproc.vim', 'mattn/webapi-vim' ] } NeoBundleLazy 'basyura/TweetVim', 'dev', { 'depends' : [ \ 'tyru/open-browser.vim', \ 'basyura/twibill.vim', \ 'basyura/bitly.vim', \ 'Shougo/unite.vim', \ 'Shougo/unite-outline', \ 'Shougo/vimproc.vim', \ 'mattn/favstar-vim', \ 'mattn/webapi-vim' \ ] } " Vim script NeoBundleLazy 'mopp/layoutplugin.vim' " Ruby NeoBundleLazy 'vim-ruby/vim-ruby' NeoBundleLazy 'taka84u9/vim-ref-ri', { 'depends' : [ 'Shougo/unite.vim', 'thinca/vim-ref' ] } NeoBundle 'tpope/vim-rails' NeoBundleLazy 'basyura/unite-rails', { 'depends' : [ 'Shougo/unite.vim' ] } " golang NeoBundleLazy 'jnwhiteh/vim-golang' " Clang NeoBundleLazy 'osyo-manga/vim-snowdrop' " Java NeoBundleLazy 'vim-scripts/javacomplete', { \ 'build': { \ 'cygwin': 'javac autoload/Reflection.java', \ 'mac': 'javac autoload/Reflection.java', \ 'unix': 'javac autoload/Reflection.java' \ }, \ } " MetaQuartsLanguage NeoBundle 'vobornik/vim-mql4' " TODO: Windows build command to get .ctags NeoBundleLazy 'alpaca-tc/alpaca_tags', { \ 'depends' : [ 'Shougo/vimproc.vim' ], \ 'build' : { \ 'mac' : 'wget https://raw.github.com/alpaca-tc/alpaca_tags/master/.ctags -O ~/.ctags', \ 'unix' : 'wget https://raw.github.com/alpaca-tc/alpaca_tags/master/.ctags -O ~/.ctags', \ } \ } NeoBundleLazy 'rbtnn/puyo.vim' " TODO: atode settei simasu... " NeoBundleLazy 'tpope/vim-markdown' " Disable some local bundles NeoBundleDisable vimshell-kawaii.vim NeoBundleDisable vimshell-scopedalias.vim NeoBundleDisable unite-vacount2012.vim NeoBundleDisable vimshell-suggest.vim " Required to use filetype plugin indent on " }}} " Plugin Configurations {{{ if neobundle#tap('vital.vim') " {{{ function! neobundle#tapped.hooks.on_source(bundle) let g:V = vital#of('vital') let g:S = g:V.import("Web.HTTP") function! DecodeURI(uri) return g:S.decodeURI(a:uri) endfunction function! EncodeURI(uri) return g:S.encodeURI(a:uri) endfunction command -nargs=1 DecodeURI echo DecodeURI() command -nargs=1 EncodeURI echo EncodeURI() endfunction endif " }}} if neobundle#tap('unite.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'commands' : [ \ { \ 'name' : 'Unite', \ 'complete' : 'customlist,unite#complete_source' \ }, \ 'UniteWithCursorWord', \ 'UniteWithInput' \ ] \ } \ }) function! s:unite_menu_map_func(key, value) let [word, value] = a:value if isdirectory(value) return { \ 'word' : '[directory] ' . word, \ 'kind' : 'directory', \ 'action__directory' : value \ } elseif !empty(glob(value)) return { \ 'word' : '[file] ' . word, \ 'kind' : 'file', \ 'default_action' : 'tabdrop', \ 'action__path' : value, \ } else return { \ 'word' : '[command] ' . word, \ 'kind' : 'command', \ 'action__command' : value \ } endif endfunction function! neobundle#tapped.hooks.on_source(bundle) " General let g:unite_force_overwrite_statusline = 0 let g:unite_kind_jump_list_after_jump_scroll=0 let g:unite_enable_start_insert = 0 let g:unite_source_rec_min_cache_files = 1000 let g:unite_source_rec_max_cache_files = 5000 let g:unite_source_file_mru_long_limit = 100000 let g:unite_source_file_mru_limit = 100000 let g:unite_source_directory_mru_long_limit = 100000 let g:unite_prompt = '❯ ' " Unite-menu let g:unite_source_menu_menus = get(g:, 'unite_source_menu_menus', {}) let g:unite_source_menu_menus.global = { 'description' : 'global shortcut' } let g:unite_source_menu_menus.unite = { 'description' : 'unite shortcut' } let g:unite_source_menu_menus.global.map = function('s:unite_menu_map_func') let g:unite_source_menu_menus.unite.map = function('s:unite_menu_map_func') let g:unite_source_menu_menus.global.candidates = [ \ [ '[edit] vimrc' , $MYVIMRC ], \ [ '[edit] secret_vimrc' , expand('~/.secret_vimrc') ], \ [ '[terminal] VimShell' , ':VimShell' ], \ [ '[twitter] TweetVim' , ':Unite tweetvim' ], \ [ '[lingr] J6uil' , ':J6uil' ], \ ] let g:unite_source_menu_menus.unite.candidates = [ \ [ 'neobundle/update' , ':Unite neobundle/update -log' ], \ [ 'neobundle/install' , ':Unite neobundle/install -log' ], \ [ 'J6uil/rooms' , ':Unite J6uil/rooms' ], \ [ 'J6uil/members' , ':Unite J6uil/members' ], \ [ 'TweetVim' , ':Unite tweetvim' ], \ [ 'files', ':Unite -start-insert -buffer-name=files buffer_tab file file_mru'], \ [ 'function', ':Unite -start-insert -default-action=edit function'], \ [ 'variable', ':Unite -start-insert -default-action=edit variable'], \ [ 'outline', ':Unite -start-insert outline'], \ [ 'help', ':Unite -start-insert help'], \ [ 'buffer', ':Unite -start-insert buffer'], \ [ 'line', ':Unite -start-insert -auto-preview -buffer-name=search line'], \ [ 'quickfix', ':Unite -no-split -no-quit -auto-preview quickfix -buffer-name=unite_qf'], \ [ 'grep', ':Unite grep -max-multi-lines=1 -truncate -default-action=tabopen -buffer-name=unite_grep'], \ [ 'source', ':Unite -start-insert source'], \ [ 'locate', ':Unite -start-insert locate'], \ [ 'theme', ':Unite -auto-preview colorscheme'], \ [ 'resume grep', ':UniteResume unite_grep'], \ [ 'resume quickfix', ':UniteResume unite_qf'], \ ] endfunction nnoremap u :Unite -start-insert menu:unite nnoremap m :Unite -start-insert menu:global nnoremap f :Unite -start-insert -buffer-name=files buffer_tab file_mru nnoremap b :Unite -start-insert buffer nnoremap s :Unite -start-insert -auto-preview -no-split -buffer-name=search line nnoremap l :Unite -start-insert locate nnoremap g :Unite grep -max-multi-lines=1 -truncate -default-action=tabopen -buffer-name=unite_grep " This j mapping is to define default behavior. Should be changed by " buffer local setting. nnoremap j :Unite -start-insert -buffer-name=files buffer_tab file_mru nnoremap p :call Unite_project_files('-start-insert') function! Unite_project_files(options) if exists('b:projectlocal_root_dir') execute ':Unite file_rec/async:' . b:projectlocal_root_dir . ' ' . a:options else echo "You are not in any project." endif endfunction " TODO: Should those mappings be moved to their own setting section? " That seems collect but it provides better look of the Unite-source " mappings list. if neobundle#is_installed('unite-quickfix') nnoremap q :Unite -no-quit -auto-preview -no-split quickfix endif if neobundle#is_installed('unite-help') nnoremap o :Unite -start-insert -auto-preview \ -no-split outline endif if neobundle#is_installed('unite-outline') nnoremap h :Unite -start-insert help endif endif " }}} if neobundle#tap('vimfiler.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'commands' : [ \ { 'name' : 'VimFiler', 'complete' : 'customlist,vimfiler#complete' }, \ { 'name' : 'VimFilerExplorer', 'complete' : 'customlist,vimfiler#complete' }, \ { 'name' : 'Edit', 'complete' : 'customlist,vimfiler#complete' }, \ { 'name' : 'Write', 'complete' : 'customlist,vimfiler#complete' }, \ 'Read', \ 'Source' \ ], \ 'mappings' : '(vimfiler_', \ 'explorer' : 1, \ } \ }) let g:vimfiler_safe_mode_by_default = 0 let g:unite_kind_file_use_trashbox = 1 let g:vimfiler_as_default_explorer = 1 let g:vimfiler_as_default_explorer = 1 nnoremap e :VimFilerExplorer -winwidth=65 endif " }}} if neobundle#tap('unite-quickfix') " {{{ call neobundle#config({ \ 'autoload' : { \ 'unite_sources' : [ \ 'quickfix', \ ], \ } \ }) endif " }}} if neobundle#tap('unite-outline') " {{{ call neobundle#config({ \ 'autoload' : { \ 'unite_sources' : [ \ 'outline', \ ], \ } \ }) endif " }}} if neobundle#tap('unite-help') " {{{ call neobundle#config({ \ 'autoload' : { \ 'unite_sources' : [ \ 'help', \ ], \ } \ }) endif " }}} if neobundle#tap('unite-ssh') " {{{ call neobundle#config({ \ 'autoload' : { \ 'unite_sources' : [ \ 'ssh', \ ], \ } \ }) endif " }}} if neobundle#tap('unite-colorscheme') " {{{ call neobundle#config({ \ 'autoload' : { \ 'unite_sources' : [ \ 'colorscheme', \ ], \ } \ }) endif " }}} if neobundle#tap('unite-locate') " {{{ call neobundle#config({ \ 'autoload' : { \ 'unite_sources' : [ \ 'locate', \ ], \ } \ }) endif " }}} if neobundle#tap('shaberu.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'commands' : [ 'ShaberuSay', 'ShaberuMuteOn', 'ShaberuMuteOff', 'ShaberuMuteToggle' ] \ } \ }) let g:shaberu_user_define_say_command = 'say-openjtalk "%%TEXT%%"' " Vim core autocmd MyAutoCmd VimEnter * ShaberuSay 'ビムにようこそ' autocmd MyAutoCmd VimLeave * ShaberuSay 'さようなら' " VimShell autocmd MyAutoCmd FileType vimshell \ call vimshell#hook#add('chpwd' , 'my_vimshell_chpwd' , reti#lambda(":ShaberuSay 'よっこいしょ'")) \| call vimshell#hook#add('emptycmd', 'my_vimshell_emptycmd', reti#lambda(":call shaberu#say('コマンドを入力してください') | return a:1")) \| call vimshell#hook#add('notfound', 'my_vimshell_notfound', reti#lambda(":call shaberu#say('コマンドが見つかりません') | return a:1")) " .vimrc保存時に自動的にsource autocmd MyAutoCmd BufWritePost .vimrc nested source $MYVIMRC | ShaberuSay 'ビムアールシーを読み込みました' " 開発用ディレクトリ内.vimファイルに関して、ファイル保存時に自動でsourceする execute 'autocmd MyAutoCmd BufWritePost,FileWritePost' $VIM_LOCAL_BUNDLE_DIR . '*.vim' 'source | echo "sourced : " . bufname("%") | ShaberuSay "ソースしました"' endif " }}} if neobundle#tap('vimshell.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'commands' : [ 'VimShell', 'VimShellPop' ] \ } \ }) " function! neobundle#tapped.hooks.on_source(bundle) " let g:unite_source_vimshell_external_history_path = expand('~/.zsh_history') " endfunction nnoremap :VimShellPop -toggle inoremap :VimShellPop -toggle nnoremap vp :VimShellPop -toggle nnoremap vb :VimShellBufferDir nnoremap vd :VimShellCurrentDir nnoremap vv :VimShell " buffer local mapping function! s:my_vimshell_mappings() imap $a imap xi imap dT/xa imap dT.xa imap dT_xa endfunction autocmd MyAutoCmd FileType vimshell call s:my_vimshell_mappings() " Run VimShell when launch Vim " autocmd MyAutoCmd VimEnter * VimShell endif " }}} if neobundle#tap('vimshell-pure.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'on_source' : [ 'vimshell.vim' ] \ } \ }) endif " }}} if neobundle#tap('vimshell-inline-history.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'on_source' : [ 'vimshell.vim' ] \ } \ }) endif " }}} if neobundle#tap('vimshell-wakeup.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'on_source' : [ 'vimshell.vim' ] \ } \ }) function! neobundle#tapped.hooks.on_source(bundle) let g:vimshell_wakeup_shaberu_text = 'おわだよ' endfunction endif " }}} if neobundle#tap('projectlocal.vim') " {{{ " See unite.vim's setting section. endif " }}} if neobundle#tap('vim-textobj-multiblock') " {{{ let g:textobj_multiblock_blocks = [ \ ['(', ')', 1], \ ['[', ']', 1], \ ['{', '}', 1], \ ['<', '>', 1], \ ['"', '"', 1], \ ["'", "'", 1], \ ['`', '`', 1], \ ['|', '|', 1], \ ] " Couldn't use multiple chars " \ ['if', 'elsif'], " \ ['if', 'else'], " \ ['if', 'end'], " \ ['elsif', 'end'], " \ ['elsif', 'elsif'], " \ ['elsif', 'else'], " \ ['else', 'end'], " \ ['do', 'end'], endif " }}} if neobundle#tap('neocomplete.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'insert' : 1, \ } \ }) " Enable at startup let g:neocomplete#enable_at_startup = 1 " Smartcase let g:neocomplete#enable_smart_case = 1 " Enable _ separated completion let g:neocomplete_enable_underbar_completion = 1 " Minimum length to cache let g:neocomplete_min_syntax_length = 3 " Max size of candidates to show let g:neocomplete#max_list = 1000 " How many length to need to start completion let g:neocomplete_auto_completion_start_length = 2 " Auto select the first candidate " let g:neocomplete_enable_auto_select = 1 " Force to overwrite complete func let g:neocomplete_force_overwrite_completefunc = 1 " let g:neocomplete_enable_camel_case_completion = 1 let g:neocomplete#skip_auto_completion_time = '0.2' " Cancel and close popup " imap neocomplete#cancel_popup() " Omni completion patterns let g:neocomplete#force_omni_input_patterns = get(g:, 'neocomplete#force_omni_input_patterns', {}) let g:neocomplete#force_omni_input_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::' " Omni completion functions let g:neocomplete#sources#omni#functions = get(g:, 'neocomplete#sources#omni#functions', {}) let g:neocomplete#sources#omni#functions.ruby = 'rubycomplete#Complete' endif " }}} if neobundle#tap('neosnippet.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'insert' : 1, \ 'filetype' : 'snippet', \ 'commands' : [ 'NeoSnippetEdit', 'NeoSnippetSource' ], \ 'filetypes' : [ 'nsnippet' ], \ 'unite_sources' : \ ['snippet', 'neosnippet/user', 'neosnippet/runtime'] \ } \ }) let g:neosnippet#enable_snipmate_compatibility = 1 " My original snippets let g:neosnippet_snippets_directories = s:add_to_uniq_list( \ s:get_list(g:, 'neosnippet_snippets_directories'), \ '~/.vim/snippets' \ ) let g:neosnippet#snippets_directory = join(g:neosnippet_snippets_directories, ',') " to expand snippet if can imap !pumvisible() ? "\" : \ neosnippet#expandable() ? "\(neosnippet_expand)" : \ neocomplete#close_popup() " supertab. imap pumvisible() ? "\" : \ neosnippet#jumpable() ? "\(neosnippet_jump)" : \ "\" smap pumvisible() ? "\" : \ neosnippet#jumpable() ? "\(neosnippet_jump)" : \ "\" endif " }}} if neobundle#tap('vim-snippets') " {{{ let g:neosnippet_snippets_directories = s:add_to_uniq_list( \ s:get_list(g:, 'neosnippet_snippets_directories'), \ $VIM_REMOTE_BUNDLE_DIR . '/vim-snippets/snippets' \ ) let g:neosnippet#snippets_directory = join(g:neosnippet_snippets_directories, ',') endif " }}} if neobundle#tap('angular-vim-snippets') " {{{ let g:neosnippet_snippets_directories = s:add_to_uniq_list( \ s:get_list(g:, 'neosnippet_snippets_directories'), \ $VIM_REMOTE_BUNDLE_DIR . '/angular-vim-snippets/snippets' \ ) let g:neosnippet#snippets_directory = join(g:neosnippet_snippets_directories, ',') endif " }}} if neobundle#tap('vim-alignta') " {{{ call neobundle#config({ \ 'autoload' : { \ 'commands' : ['Alignta'], \ } \ }) endif " }}} if neobundle#tap('foldCC') " {{{ set foldmethod=marker set foldtext=FoldCCtext() set foldcolumn=0 set fillchars=vert:\| endif " }}} if neobundle#tap('tcomment_vim') " {{{ endif " }}} if neobundle#tap('vim-smartinput') " {{{ call neobundle#config({ \ 'autoload' : { \ 'insert' : 1 \ } \ }) function! neobundle#tapped.hooks.on_source(bundle) call smartinput#clear_rules() call smartinput#define_default_rules() endfunction function! neobundle#tapped.hooks.on_post_source(bundle) call smartinput_endwise#define_default_rules() endfunction endif " }}} if neobundle#tap('vim-smartinput-endwise') " {{{ function! neobundle#tapped.hooks.on_post_source(bundle) " neosnippet and neocomplete compatible call smartinput#map_to_trigger('i', '(my_cr)', '', '') imap !pumvisible() ? "\(my_cr)" : \ neosnippet#expandable() ? "\(neosnippet_expand)" : \ neocomplete#close_popup() endfunction endif " }}} if neobundle#tap('vim-submode') " {{{ function! neobundle#tapped.hooks.on_source(bundle) let g:submode_keep_leaving_key = 1 " tab moving call submode#enter_with('changetab', 'n', '', 'gt', 'gt') call submode#enter_with('changetab', 'n', '', 'gT', 'gT') call submode#map('changetab', 'n', '', 't', 'gt') call submode#map('changetab', 'n', '', 'T', 'gT') " undo/redo call submode#enter_with('undo/redo', 'n', '', '', '') call submode#enter_with('undo/redo', 'n', '', 'u', 'u') call submode#map('undo/redo', 'n', '', '', '') call submode#map('undo/redo', 'n', '', 'u', 'u') " move between fold call submode#enter_with('movefold', 'n', '', 'zj', 'zjzMzvzz') call submode#enter_with('movefold', 'n', '', 'zk', 'zkzMzv[zzz') call submode#map('movefold', 'n', '', 'j', 'zjzMzvzz') call submode#map('movefold', 'n', '', 'k', 'zkzMzv[zzz') " resize 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', '', '-', '-') " TODO: Repeat last executed macro. umaku dekinai... " call submode#enter_with('macro/a', 'n', '', '@a', '@a') " call submode#map('macro/a', 'n', '', 'a', '@a') endfunction endif " }}} if neobundle#tap('open-browser.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'commands' : [ 'OpenBrowser', 'OpenBrowserSearch', 'OpenBrowserSmartSearch' ], \ } \ }) endif " }}} if neobundle#tap('operator-html-escape.vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'on_source' : [ '' ] \ } \ }) endif " }}} if neobundle#tap('vim-anzu') " {{{ call neobundle#config({}) " Treat folding well nnoremap n anzu#mode#mapexpr('n', '', 'zzzv') nnoremap N anzu#mode#mapexpr('N', '', 'zzzv') " Start search with anzu nmap * (anzu-star-with-echo) nmap # (anzu-sharp-with-echo) " clear status " nmap (anzu-clear-search-status) endif " }}} if neobundle#tap('vim-automatic') " {{{ call neobundle#config({}) nnoremap (quit) :q function! s:my_temporary_window_init(config, context) nmap (quit) " echo a:config " echo a:context endfunction let g:automatic_enable_autocmd_Futures = {} let g:automatic_default_match_config = { \ 'is_open_other_window' : 1, \ } let g:automatic_default_set_config = { \ 'height' : '60%', \ 'move' : 'bottom', \ 'apply' : function('s:my_temporary_window_init') \ } let g:automatic_config = [ \ { 'match' : { 'buftype' : 'help' } }, \ { 'match' : { 'bufname' : '^.vimshell' } }, \ { 'match' : { \ 'autocmd_history_pattern' : 'BufWinEnterFileType$', \ 'filetype' : 'unite' \ } \ }, \ { \ 'match' : { 'bufname' : '^vimfiler' }, \ 'set' : { 'unsettings' : [ 'resize' ], 'move' : 'left'} \ }, \ { \ 'match' : { \ 'filetype' : 'tweetvim_say', \ 'autocmds' : [ 'FileType' ] \ }, \ 'set' : { \ 'height' : '8' \ } \ }, \ { \ 'match' : { \ 'filetype' : 'J6uil_say', \ 'autocmds' : [ 'FileType' ] \ }, \ 'set' : { \ 'height' : '8' \ } \ }, \ { \ 'match' : { \ 'filetype' : 'vimconsole', \ 'autocmds' : [ 'FileType' ] \ } \ }, \ { \ 'match' : { \ 'filetype' : '\v^ref-.+', \ 'autocmds' : [ 'FileType' ] \ } \ }, \ { \ 'match' : { \ 'bufname' : '\[quickrun output\]', \ }, \ 'set' : { \ 'height' : 8, \ } \ }, \ { \ 'match' : { \ 'autocmds' : [ 'CmdwinEnter' ] \ }, \ 'set' : { \ 'is_close_focus_out' : 1, \ 'unsettings' : [ 'move', 'resize' ] \ }, \ } \ ] endif " }}} if neobundle#tap('gist-vim') " {{{ call neobundle#config({ \ 'autoload' : { \ 'commands' : ['Gist'], \ } \ }) function! neobundle#tapped.hooks.on_source(bundle) " TODO: w3m " let g:gist_browser_command = 'w3m %URL%' endfunction let g:gist_open_browser_after_post = 1 let g:gist_clip_command = 'pbcopy' let g:gist_detect_filetype = 1 let g:gist_show_privates = 1 let g:gist_post_private = 1 endif " }}} if neobundle#tap('vim-prettyprint') " {{{ call neobundle#config({ \ 'autoload' : { 'commands' : ['PP'] } \ }) endif " }}} if neobundle#tap('vim-quickrun') " {{{ call neobundle#config({ \ 'autoload' : { \ 'mappings' : [ '(quickrun)' ], \ 'commands' : [ 'QuickRun' ], \ } \ }) let g:quickrun_config = get(g:, 'quickrun_config', {}) let g:quickrun_config.markdown = { \ 'outputter' : 'null', \ 'command' : 'open', \ 'cmdopt' : '-a', \ 'args' : 'Marked', \ 'exec' : '%c %o %a %s', \ } let g:quickrun_config.matlab = { \ 'command' : 'octave', \ 'cmdopt' : '--silent --persist', \ 'exec' : '%c %o %s' \ } if exists('$METALANG') let g:quickrun_config.mql4 = { \ 'command' : 'wine', \ 'cmdopt' : '/usr/local/bin/metalang.exe', \ 'exec' : '%c %o %s' \ } endif let g:quickrun_config.ruby = { \ 'command': 'irb', \ 'cmdopt': '--simple-prompt', \ 'hook/cd': 1, \ 'runner': 'process_manager', \ 'runner/process_manager/load': "load %s", \ 'runner/process_manager/prompt': '>>\s', \ } nnoremap r :QuickRun endif " }}} if neobundle#tap('vim-scall') " {{{ endif " }}} if neobundle#tap('vim-singleton') " {{{ function! neobundle#tapped.hooks.on_source(bundle) call singleton#enable() endfunction endif " }}} if neobundle#tap('vim-textobj-multiblock') " {{{ function! neobundle#tapped.hooks.on_source(bundle) omap ab (textobj-multiblock-a) omap ib (textobj-multiblock-i) vmap ab (textobj-multiblock-a) vmap ib (textobj-multiblock-i) endfunction endif " }}} if neobundle#tap('vim-ref') " {{{ call neobundle#config({ \ 'autoload' : { \ 'commands' : [{ \ 'name' : 'Ref', \ 'complete' : 'customlist,ref#complete' \ }], \ 'unite_sources' : [ 'ref' ] \ } \ }) let g:ref_open = 'split' let g:ref_refe_cmd = '~/.vim/ref/ruby-refm-1.9.3-dynamic-20120829/refe-1_9_3' aug MyAutoCmd au FileType ruby,eruby,ruby.rspec,haml nnoremap d :Unite -no-start-insert ref/refe ref/ri -auto-preview -default-action=below -input= " au FileType php nnoremap d :Unite -no-start-insert ref/refe ref/ri -auto-preview -default-action=below -input= aug END endif " }}} if neobundle#tap('vim-ref-ri') " {{{ call neobundle#config({ \ 'autoload' : { \ 'filetypes' : [ 'ruby', 'haml', 'eruby' ], \ 'unite_sources' : [ 'ref/ri' ] \ }, \ }) endif " }}} if neobundle#tap('vim-qfreplace') " {{{ call neobundle#config({ \ 'autoload' : { \ 'filetypes' : [ 'unite', 'quickfix' ], \ 'commands' : [ 'Qfreplace' ] \ } \ }) endif " }}} if neobundle#tap('vim-editvar') " {{{ call neobundle#config({ \ 'autoload' : { \ 'commands' : [ 'Editvar' ], \ 'unite_sources' : [ 'variable' ] \ } \ }) endif " }}} if neobundle#tap('vim-endwise') " {{{ call neobundle#config({ \ 'autoload' : { \ 'filetypes' : [ 'ruby' ] \ } \ }) function! neobundle#tapped.hooks.on_source(bundle) " TODO: endwise is not working well. need to implement with smartinput " let g:endwise_no_mappings = 1 " if maparg('','i') =~# '=.*crend(.)\|<\%(Plug\|SNR\|SID\)>.*End' " " Already mapped " elseif maparg('','i') =~ '' " exe "imap