Skip to content

Instantly share code, notes, and snippets.

@cohalz
Created March 22, 2014 15:10
Show Gist options
  • Save cohalz/9708686 to your computer and use it in GitHub Desktop.
Save cohalz/9708686 to your computer and use it in GitHub Desktop.
set nocompatible
set hidden
filetype off
set autoread
set noswapfile
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim
call neobundle#rc(expand('~/.vim/bundle'))
endif
" ここにインストールしたいプラグインのリストを書く
NeoBundle 'kana/vim-operator-user'
NeoBundle 'kana/vim-operator-replace'
NeoBundle 'kana/vim-textobj-user'
NeoBundle 'kana/vim-textobj-indent'
NeoBundle 'kana/vim-filetype-haskell'
NeoBundle 'kana/vim-smartinput'
NeoBundle 'kana/vim-submode'
NeoBundle 'thinca/vim-textobj-plugins'
NeoBundle 'thinca/vim-quickrun'
NeoBundle 'thinca/vim-ref'
NeoBundle 'thinca/vim-threes'
NeoBundle 'modsound/gips-vim'
NeoBundle 'osyo-manga/unite-quickfix'
NeoBundle 'osyo-manga/vim-watchdogs'
NeoBundle 'ujihisa/neco-ghc'
NeoBundle 'vim-scripts/c.vim'
NeoBundle 'klen/python-mode'
NeoBundle 'pangloss/vim-javascript'
NeoBundle 'kchmck/vim-coffee-script'
NeoBundle 'xolox/vim-misc'
NeoBundle 'xolox/vim-lua-ftplugin'
NeoBundle 'derekwyatt/vim-scala'
NeoBundle 'pekepeke/titanium-vim'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'airblade/vim-rooter'
NeoBundle 'itchyny/lightline.vim'
NeoBundle 'itchyny/calendar.vim'
NeoBundle 'glts/vim-textobj-comment'
NeoBundle 'tpope/vim-surround'
NeoBundle 'rhysd/clever-f.vim'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'tyru/restart.vim'
NeoBundle 'jimsei/winresizer'
NeoBundle 'w0ng/vim-hybrid'
NeoBundle 'honza/vim-snippets'
NeoBundle 'taka84u9/vim-ref-ri'
NeoBundle 'cocopon/colorswatch.vim'
NeoBundle 'rosstimson/scala-vim-support'
NeoBundle 'LeafCage/foldCC'
NeoBundle 'Yggdroot/indentLine'
NeoBundle 'dag/vim2hs'
NeoBundle 'basyura/TweetVim'
NeoBundle 'mattn/webapi-vim'
NeoBundle 'basyura/twibill.vim'
NeoBundle 'tyru/open-browser.vim'
NeoBundle 'h1mesuke/unite-outline'
NeoBundle 'basyura/bitly.vim'
NeoBundle 'vim-scripts/YankRing.vim'
NeoBundle 'vim-jp/vital.vim'
NeoBundle 'mattn/gist-vim'
NeoBundle 'majutsushi/tagbar'
NeoBundle 'tyru/foldballoon.vim'
NeoBundle 'gcmt/wildfire.vim'
NeoBundle 'gregsexton/gitv'
NeoBundle 'Shougo/unite.vim'
NeoBundle 'Shougo/neocomplete.vim'
NeoBundle 'Shougo/neobundle.vim'
NeoBundle 'Shougo/neosnippet.vim'
NeoBundle 'Shougo/vimfiler'
NeoBundle 'Shougo/echodoc', '', 'default'
NeoBundle 'Shougo/neosnippet-snippets'
NeoBundle 'Shougo/vimshell'
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'windows' : 'make -f make_mingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
NeoBundleLazy 'Shougo/neosnippet', {
\ 'autoload' : {
\ 'insert' : 1,
call neobundle#config('echodoc', {
\ 'lazy' : 1,
\ 'autoload' : {
\ 'insert' : 1,
\ }})
\ }}
filetype plugin on
filetype indent on
nnoremap Q <Nop>
" neocomplete用設定
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_ignore_case = 1
let g:neocomplete#enable_smart_case = 1
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns._ = '\h\w*'
" <TAB>: completion.
" inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<S-TAB>"
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
" SuperTab like snippets behavior.
" imap <expr><TAB> neosnippet#jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "\<C-n>" : "\<TAB>"
imap <expr><TAB> pumvisible() ? "\<C-n>" : neosnippet#jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'c' : $HOME.'/.vim/etc/dict/c.dict',
\ 'cpp' : $HOME.'/.vim/etc/dict/cpp.dict',
\ 'haskell' : $HOME.'/.vim/etc/dict/haskell.dict',
\ 'java' : $HOME.'/.vim/etc/dict/java.dict',
\ 'javascript' : $HOME.'/.vim/etc/dict/javascript.dict',
\ 'lua' : $HOME.'/.vim/etc/dict/lua.dict',
\ 'ocaml' : $HOME.'/.vim/etc/dict/ocaml.dict',
\ 'scheme' : $HOME.'/.vim/etc/dict/scheme.dict',
\ 'scala' : $HOME.'/.vim/etc/dict/scala.dict'
\ }
" , y でヤンク履歴
nmap ,y :YRShow<CR>
" クリップボード共有
set clipboard+=unnamedplus,unnamed
" e .などでvimfilerが起動できるように
let g:vimfiler_as_default_explorer = 1
"http://www.daisaru11.jp/blog/2011/09/vimsyntastic%E3%81%A7%E6%96%87%E6%B3%95%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%82%92%E8%87%AA%E5%8B%95%E3%81%A7%E8%A1%8C%E3%81%86/
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=2
"EscしたらIMEをオフに
inoremap <silent> <ESC> <ESC>:set iminsert=0<CR>
"Yの挙動を変更
nnoremap Y y$
"lightlineカラースキームはじまり
let g:lightline = {
\ 'mode_map': {'c': 'NORMAL'},
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'modified': 'MyModified',
\ 'readonly': 'MyReadonly',
\ 'fugitive': 'MyFugitive',
\ 'filename': 'MyFilename',
\ 'fileformat': 'MyFileformat',
\ 'filetype': 'MyFiletype',
\ 'fileencoding': 'MyFileencoding',
\ 'mode': 'MyMode'
\ }
\ }
function! MyModified()
return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyReadonly()
return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? 'x' : ''
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()
try
if &ft !~? 'vimfiler\|gundo' && exists('*fugitive#head')
return fugitive#head()
endif
catch
endtry
return ''
endfunction
function! MyFileformat()
return winwidth('.') > 70 ? &fileformat : ''
endfunction
function! MyFiletype()
return winwidth('.') > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! MyFileencoding()
return winwidth('.') > 70 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! MyMode()
return winwidth('.') > 60 ? lightline#mode() : ''
endfunction
"--------------------
"operator-replace
"Rで置換できるようにする
"defaultのRが使えなくなるので注意
"--------------------
map R <Plug>(operator-replace)
"caw.vim
nmap <Leader>c <Plug>(caw:I:toggle)
vmap <Leader>c <Plug>(caw:I:toggle)
" runner/vimproc/updatetime で出力バッファの更新間隔をミリ秒で設定できます
" updatetime が一時的に書き換えられてしまうので注意して下さい
let g:quickrun_config = {
\ "_" : {
\ "hook/shabadoubi_touch_henshin/enable" : 1,
\ "hook/shabadoubi_touch_henshin/wait" : 20,
\ "outputter/buffer/split" : ":botright 8sp",
\ "runner" : "vimproc",
\ "runner/vimproc/updatetime" : 40,
\ }
\}
"検索を画面の中央に表示
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
"<C-j>でEsc
inoremap <C-j> <Esc>
nnoremap <C-j> <Esc>
vnoremap <C-j> <Esc>
let g:quickrun_config.coffee = {'command': 'coffee', 'cmdopt': '-pb'}
"Neosnippetで使うディレクトリを指定
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets, ~/.vim/etc/snippets'
"https://gist.github.com/frangio/985684
autocmd BufNewFile,BufRead *
\ if expand('%:~') =~ '^\~/Dropbox' |
\ set noswapfile |
\ else |
\ set swapfile |
\ endif
"インサートから<C-o>連打^^;
nnoremap <C-o> o
"http://blog.supermomonga.com/articles/vim/vimshell-dynamicprompt.html
let g:my_vimshell_prompt_counter = -1
function! g:my_vimshell_dynamic_prompt()
let g:my_vimshell_prompt_counter += 1
let anim = [
\ "(´・_・`)",
\ "( ´・_・)",
\ "( ´・_)",
\ "( ´・)",
\ "( ´)",
\ "( )",
\ "( )",
\ "(` )",
\ "(・` )",
\ "(_・` )",
\ "(・_・` )",
\ ]
return anim[g:my_vimshell_prompt_counter % len(anim)]
endfunction
let g:vimshell_prompt_expr = 'g:my_vimshell_dynamic_prompt()." > "'
let g:vimshell_prompt_pattern = '^([ ´・_・`]\{5}) > '
"ステータスバーを常に表示
set laststatus=2
"https://sites.google.com/site/fudist/Home/vim-nihongo-ban/vim-japanese/ime-control
let IM_CtrlMacVimKaoriya = 0
"im_control.vimのある場所を設定して下さい
set runtimepath+=~/.vim/etc
if has('gui_running')
" 「日本語入力固定モード」の動作モード
let IM_CtrlMode = 4
" GVimで<C-^>が使える場合の「日本語入力固定モード」切替キー
inoremap <silent> <C-]> <C-^><C-r>=IMState('FixMode')<CR>
else
" 非GUIの場合(この例では「日本語入力固定モード」を無効化している)
let IM_CtrlMode = 0
endif
"Ctrl+:でコマンドモードへ、設定するにはhttps://www.dropbox.com/s/vklvp9qbq7mz1w0/private.xml からKeyRemap4Macbookで"Vim Keybind"をオンにしてください
"USキーボードMac以外の動作は保証できません
inoremap x02 <C-o>:
nnoremap x02 :
cnoremap x02 <Esc>:
"Ctrl+hやlでインサートモードも動けるように
inoremap <C-l> <C-o>a
inoremap <C-h> <Esc>i
"VimShellを簡単に作る^^;
nnoremap <silent> cohalz <C-w>v<C-w>10><C-w><C-w>:TweetVimUserStream<CR>:VimShell<CR><Esc><C-w>h
"UniteのBookmark(http://promamo.com/?p=1822)
call unite#custom_default_action('source/bookmark/directory' , 'vimfiler')
"http://ameblo.jp/toki917/entry-11559823574.html
autocmd VimEnter * VimFiler -split -simple -winwidth=20 -no-quit
"<C-w><C-w>で次に進むのでその逆として
nnoremap <C-w><C-q> <C-w>h
"VimFilerのセーフモードをオフに
let g:vimfiler_safe_mode_by_default = 0
"括弧とエンターでインデントを作る。vim-smartinputで設定しても動かなかったので
" inoremap {<CR> {}<Esc>i<CR><CR><Esc>kA<Tab>
" inoremap (<CR> ()<Esc>i<CR><CR><Esc>kA<Tab>
"http://d.hatena.ne.jp/leafcage/20111223/1324705686
set foldmethod=indent
set foldlevel=100
set foldtext=foldCC#foldtext()
set foldcolumn=0
set fillchars=vert:\|
hi Folded gui=bold term=standout ctermbg=LightGrey ctermfg=DarkBlue guibg=Grey30 guifg=Grey80
hi FoldColumn gui=bold term=standout ctermbg=LightGrey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue
noremap [space] <nop>
nmap <Space> [space]
noremap [space]j zj
noremap [space]k zk
noremap [space]n ]z
noremap [space]p [z
noremap [space]h zc
noremap [space]l zo
noremap [space]a za
noremap [space]m zM
noremap [space]i zMzv
noremap [space]r zR
noremap [space]f zf
"http://lisia.hatenadiary.jp/entry/2014/01/25/000301
set list listchars=tab:\¦\
let g:indentLine_color_term = 111
"http://qiita.com/laiso/items/22139ebc3f1d94a0ea23
let g:haskell_conceal = 0
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
au BufWritePost *.coffee CoffeeCompile vert
autocmd BufWritePost *.coffee silent make!
set autoread
set clipboard=unnamed
set clipboard=autoselect
set foldminlines=1
function! OpenNewTab()
let f = expand("%:p")
execute ":tabnew ".f
endfunction
set clipboard=unnamed,autoselect
"クリップボードとヤンクを同期
if has("clipboard")
vmap ,y "+y
nmap ,p "+gP
" exclude:{pattern} must be last ^= prepend += append
if has("gui_running") || has("xterm_clipboard")
silent! set clipboard^=unnamedplus
set clipboard^=unnamed
endif
endif
nnoremap <silent> <Leader>z :<C-u>VimFilerBufferDir -split -simple -winwidth=20 -toggle -no-quit<CR>
nnoremap <silent> twi :TweetVimUserStream<CR>
nnoremap <silent> <Leader>x <C-^>$
nnoremap <silent> vs :VimShell<CR><Esc>
nnoremap <Leader>s :TweetVimSay<CR>
let g:tweetvim_empty_separator = 1
nnoremap <silent> <Leader>v :VimShellInteractive scala<CR><Esc><C-w><C-x><C-w>10>
vmap <silent> ,ss :VimShellSendString<CR>
" 選択中に,ss: 非同期で開いたインタプリタに選択行を評価させる
nnoremap <silent> ,ss <S-v>:VimShellSendString<CR>
nnoremap <Tab> <Plug>(vimshell_zsh_complete)
au FileType scala setl sw=2 sts=2 et
autocmd BufNewFile,BufRead,BufWritePost * retab! | IndentLinesReset
let g:indentLine_faster = 1
"http://qiita.com/tekkoc/items/98adcadfa4bdc8b5a6ca
nnoremap s <Nop>
nnoremap sj <C-w>j
nnoremap sk <C-w>k
nnoremap sl <C-w>l
nnoremap sh <C-w>h
nnoremap sn gt
nnoremap sp gT
nnoremap sr <C-w>r
nnoremap s= <C-w>=
nnoremap sw <C-w>w
nnoremap so <C-w>_<C-w>|
nnoremap sO <C-w>=
nnoremap sN :<C-u>bn<CR>
nnoremap sP :<C-u>bp<CR>
nnoremap st :<C-u>tabnew<CR>
nnoremap sv :<C-u>vs<CR>
call submode#enter_with('bufmove', 'n', '', 's>', '<C-w>>')
call submode#enter_with('bufmove', 'n', '', 's<', '<C-w><')
call submode#map('bufmove', 'n', '', '>', '<C-w>>')
call submode#map('bufmove', 'n', '', '<', '<C-w><')
"alias about vim-surround
nnoremap S <Nop>
nmap s} ysiw}
nmap s{ ysiw{
nmap sb ysiw}
nmap sB ysiw)
nmap s( ysiw(
nmap s) ysiw)
nmap s" ysiw"
nmap s' ysiw'
nmap S} ysiW}
nmap S{ ysiW{
nmap Sb ysiW}
nmap SB ysiW)
nmap S( ysiW(
nmap S) ysiW)
nmap S" ysiW"
nmap S' ysiW'
"https://github.com/majutsushi/tagbar/wiki
let g:tagbar_type_scala = {
\ 'ctagstype' : 'Scala',
\ 'kinds' : [
\ 'p:packages:1',
\ 'V:values',
\ 'v:variables',
\ 'T:types',
\ 't:traits',
\ 'o:objects',
\ 'a:aclasses',
\ 'c:classes',
\ 'r:cclasses',
\ 'm:methods'
\ ]
\ }
let g:tagbar_ctags_bin = '/usr/local/bin/ctags'
set tags += ~/Downloads/scala-master/src/library/tags
set tags += ~/Downloads/scalaz-scalaz-seven/tags
nmap ss :TagbarToggle<CR>
nnoremap <silent> so :<C-u>Unite -auto-preview outline<CR>
"http://d.hatena.ne.jp/tyru/20130509/vim_replaceable_keys
nnoremap <C-h> b
nnoremap <C-l> w
nnoremap <S-h> ge
nnoremap <S-l> e
"http://d.hatena.ne.jp/itchyny/20130918/1379461406
let g:lightline = {
\ 'active': {
\ 'right': [ [ 'syntastic', 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_expand': {
\ 'syntastic': 'SyntasticStatuslineFlag',
\ },
\ 'component_type': {
\ 'syntastic': 'error',
\ }
\ }
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
"http://d.hatena.ne.jp/tyru/20130520/foldballoon
set ballooneval
set balloonexpr=foldballoon#balloonexpr()
"http://hail2u.net/blog/software/vim-wildfire.html
let g:wildfire_water_map = '<S-Enter>'
let g:wildfire_objects = ["ii", "i'", 'i"', "i)", "i]", "i}", "ip", "it"]
"https://github.com/modsound/gips-vim
let g:gips_reading_txt = '$HOME/.vim/bundle/gips-vim/autoload/dict/quickref_vim.txt'
let g:gist_clip_command = 'pbcopy'
let g:gist_detect_filetype = 1
let g:github_user = 'cohalz'
" https://github.com/cohama/.vim/blob/master/.vimrc
autocmd myautocmd FileType git setlocal nofoldenable foldlevel=0
autocmd myautocmd FileType gitv call GitvSettings()
function! GitToggleFolding()
if &filetype ==# 'git'
setlocal foldenable!
endif
endfunction
function! GitvGetCurrentHash()
return matchstr(getline('.'), '\[\zs.\{7\}\ze\]$')
endfunction
function! GitvSettings()
setlocal iskeyword+=/,-,.
nmap <buffer> U ugg<CR>
cnoremap <buffer><expr> <C-r><C-h> GitvGetCurrentHash()
nnoremap <silent><buffer> J :<C-u>windo call GitToggleFolding()<CR>1<C-w>w
nnoremap <buffer> . :<C-u> <C-r>=GitvGetCurrentHash()<CR><Home>
nnoremap <buffer> [Git]rb :<C-u>Git rebase <C-r>=GitvGetCurrentHash()<CR><Space>
nnoremap <buffer> [Git]ri :<C-u>Git rebase -i <C-r>=GitvGetCurrentHash()<CR><Space>
nnoremap <buffer> [Git]R :<C-u>Git revert <C-r>=GitvGetCurrentHash()<CR>
nnoremap <buffer> ch :<C-u>Git cherry-pick <C-r>=GitvGetCurrentHash()<CR>
nnoremap <buffer> [Git]a :<C-u>Git add -A<CR>
nnoremap <buffer> [Git]rh :<C-u>Git reset --hard <C-r>=GitvGetCurrentHash()<CR><Space>
nnoremap <buffer> [Git]rm :<C-u>Git reset <C-r>=GitvGetCurrentHash()<CR><Space>
nnoremap <buffer> [Git]rs :<C-u>Git reset --soft <C-r>=GitvGetCurrentHash()<CR><Space>
nnoremap <silent><buffer> C :<C-u>Git checkout <C-r><C-w><CR>
nnoremap <buffer> m :<C-u>Git merge --no-ff --no-commit<Space>
nnoremap <buffer> cb :<C-u>Git checkout -b <C-r>=GitvGetCurrentHash()<CR><Left><Left><Left><Left><Left><Left><Left><Left>
nnoremap <buffer> fb :<C-u>Git branch -f <C-r>=GitvGetCurrentHash()<CR><Left><Left><Left><Left><Left><Left><Left><Left>
nnoremap <buffer> db :<C-u>Git branch -D <C-r><C-w>
nnoremap <buffer> m :<C-u>Git merge <C-r><C-w>
endfunction
nnoremap [Git]k :<C-u>Gitv --all<CR>
nnoremap [Git]K :<C-u>Gitv!<CR>
let g:Gitv_TruncateCommitSubjects = 1
autocmd FileType c,cpp,java,scala set cindent
set number
if v:version >= 703
set relativenumber
endif
set wrapscan
nnoremap k gk
nnoremap j gj
let g:calendar_google_calendar = 1
inoremap <Up> <Nop>
inoremap <Down> <Nop>
inoremap <Left> <Nop>
inoremap <Right> <Nop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment