Skip to content

Instantly share code, notes, and snippets.

@qickstarter
Created August 18, 2012 03:55
Show Gist options
  • Save qickstarter/3384269 to your computer and use it in GitHub Desktop.
Save qickstarter/3384269 to your computer and use it in GitHub Desktop.
"------------------------------------
" プラグインごとの設定 Plugins
"------------------------------------
call arpeggio#map('i', '', 0, 'jk', '<Esc>')
"------------------------------------
" Align
"------------------------------------
" Alignを日本語環境で使用するための設定"{{{
let g:Align_xstrlen = 3
vmap <C-N> :Align<Space>
"}}}
"------------------------------------
" surround.vim
"------------------------------------
function! SetSurroundMapping()"{{{
nmap ,( csw(
nmap ,) csw)
nmap ,{ csw{
nmap ,} csw}
nmap ,[ csw[
nmap ,] csw]
nmap ,' csw'
nmap ," csw"
endfunction
" au FileType eruby call SetErubyMapping()
""}}}
" ------------------------------------
" grep.vim
"------------------------------------
"{{{
" カーソル下の単語をgrepする
nnoremap <silent> <C-g><C-g> :<C-u>Rgrep<Space><C-r><C-w> *<Enter><CR>
nnoremap <C-g><C-b> :<C-u>GrepBuffer<Space><C-r><C-w><ENTER>
" 検索外のディレクトリ、ファイルパターン
let Grep_Skip_Dirs = '.svn .git .hg .swp'
let Grep_Skip_Files = '*.bak *~'
"qf内でファイルを開いた後画面を閉じる
function! OpenInQF()
.cc
ccl
" filetype on
endfunction
"rgrepなどで開いたqfを編修可にする
"また、Enterで飛べるようにする
function! OpenGrepQF()
"QuickFixをqだけで閉じる
nnoremap <buffer> q :q!<CR>
" cw
set nowrap "折り返ししない
set modifiable "編修可
" gfで開くときに、新しいTabで開く
nmap <buffer>gf <C-W>gf
" C-Mで開ける
nmap <C-M> :call OpenInQF()<CR>
"Enterで開ける
nmap <CR> :call OpenInQF()<CR>
endfunction
autocmd Filetype qf call OpenGrepQF()
"}}}
"------------------------------------
" taglist.Vim
"------------------------------------
"{{{
let Tlist_Ctags_Cmd = '~/local/bin/jctags' " ctagsのパス
let Tlist_Show_One_File = 1 " 現在編集中のソースのタグしか表示しない
let Tlist_Exit_OnlyWindow = 1 " taglistのウィンドーが最後のwindowならばVimを閉じる
let Tlist_Use_Right_Window = 1 " 右側でtaglistのウィンドーを表示
let Tlist_Enable_Fold_Column = 1 " 折りたたみ
let Tlist_Auto_Open = 0 " 自動表示
let Tlist_Auto_Update = 1
let Tlist_WinWidth = 20
" taglistを開くショットカットキー
let g:tlist_javascript_settings = 'javascript;c:class;m:method;f:function'
let tlist_objc_settings='objc;P:protocols;i:interfaces;I:implementations;M:instance methods;C:implementation methods;Z:protocol methods'
nmap <Space>t :Tlist<CR>
"}}}
"------------------------------------
" tagbar.vim
"------------------------------------
"{{{
" nnoremap <Space>t :TagbarToggle<CR>
let g:tagbar_ctags_bin="~/local/bin/jctags"
"}}}
"------------------------------------
" open-blowser.vim
"------------------------------------
"{{{
" カーソル下のURLをブラウザで開く
nmap <Leader>o <Plug>(openbrowser-open)
vmap <Leader>o <Plug>(openbrowser-open)
" ググる
nnoremap <Leader>g :<C-u>OpenBrowserSearch<Space><C-r><C-w><Enter>
"}}}
"------------------------------------
" unite.vim
"------------------------------------
"{{{
" 入力モードで開始する
let g:unite_enable_start_insert=1
" 全部乗せ
nnoremap <C-H><C-U> :<C-u>UniteWithCurrentDir -split -buffer-name=files buffer file_mru bookmark file<CR>
" 現在のバッファのカレントディレクトリからファイル一覧
"nnoremap <C-P><C-P> :<C-u>UniteWithBufferDir file<CR>
" バッファ一覧
"noremap <C-P> :Unite buffer<CR>
" ファイル一覧
"noremap <C-H> :Unite -buffer-name=file file<CR>
" 最近使ったファイルの一覧
noremap <C-H><C-H> :Unite file_mru<CR>
function! UniteSetting()
" 動き
imap <buffer><C-K> <Up>
imap <buffer><C-L> <Left>
imap <buffer><C-H> <Right>
imap <buffer><C-J> <Down>
" 開き方
nnoremap <silent><buffer><expr><C-K> unite#do_action('split')
nnoremap <silent><buffer><expr><C-L> unite#do_action('vsplit')
" inoremap <silent><buffer><expr><C-V> unite#do_action('vsplit')
" inoremap <silent><buffer><expr><C-E> unite#do_action('split')
endfunction
au FileType unite call UniteSetting()
au FileType unite call MovingInsertMode()
" 初期設定関数を起動する
" au FileType unite call s:unite_my_settings()
let g:unite_source_file_mru_limit = 200 "最大数
"}}}
"------------------------------------
" VimFiler
"------------------------------------
"{{{
" 起動コマンド
" default <leader><leader>
nnoremap <Leader><leader> :VimFilerBufferDir<CR>
let g:vimfiler_safe_mode_by_default = 0
let g:vimfiler_as_default_explorer = 1
let g:vimfiler_sort_type = "filename"
let g:vimfiler_sendto = {
\ 'unzip' : 'unzip'
\ , 'gedit' : 'gedit'
\ }
aug VimFilerKeyMapping
au!
autocmd FileType vimfiler call s:vimfiler_local()
function! s:vimfiler_local()
if has('unix')
" 開き方
call vimfiler#set_execute_file('sh', 'sh')
call vimfiler#set_execute_file('mp3', 'iTunes')
endif
" Unite bookmark連携
nmap <buffer> z <C-u>:Unite bookmark<CR>
nmap <buffer> A <C-u>:UniteBookmarkAdd<CR>
" Unite bookmarkのアクションをVimFilerに
call unite#custom_default_action('source/bookmark/directory' , 'vimfiler')
" incremental search
nmap <buffer> ? /^\s*\(\|-\\|\|+\\|+\\|-\) \zs
endfunction
aug END
"gitの場合、ルートディレクトリに移動
function! s:git_root_dir()
if(system('git rev-parse --is-inside-work-tree') == "true\n")
return ':VimFiler ' . system('git rev-parse --show-cdup') . '\<CR>'
else
echoerr '!!!current directory is outside git working tree!!!'
endif
endfunction
" nmap <buffer>gg <SID>git_root_dir()
"}}}
"------------------------------------
" quickrun.vim
"------------------------------------
"{{{
"<Leader>r で、php,js,cなどのコンパイル、テスト出来る
let g:quickrun_config = {}
let g:quickrun_config._ = {'runner' : 'vimproc'}
" default のキーマップを使用しない
let g:quickrun_no_default_key_mappings = 1
nmap <Leader>r <Plug>(quickrun)
" add type for quick run
let g:quickrun_config = {}
let g:quickrun_config['coffee'] = {
\'command' : 'coffee',
\'exec' : ['%c -cbp %s']
\}
" gem install bluecloth
" \ 'command': 'kramdown',
let markdownHead = "<!DOCTYPE HTML> <html lang=\"ja\"> <head> <meta charset=\"UTF-8\"> </head><body>"
let markdownFoot = "</body> </html>"
let g:quickrun_config['markdown'] = {
\ 'command' : 'bluecloth',
\ 'exec' : ["echo \'" . markdownHead. "'", '%c %s', "echo \'" . markdownFoot. "'"],
\ 'outputter' : 'browser',
\ }
let g:quickrun_config['ruby'] = {
\ 'command': 'ruby',
\ }
" Rspecの設定
let g:quickrun_config['ruby.rspec'] = {
\'command': 'rspec',
\ 'exec': '%c %o --color ' . getcwd()
\}
let g:quickrun_config['rspec/bundle'] = {
\ 'type': 'rspec/bundle',
\ 'command': 'rspec',
\ 'exec': '%c --drb --color ' . expand("%:p"),
\ 'outputter' : 'rspec_outputter'
\}
let rspec_outputter = quickrun#outputter#buffer#new()
function! rspec_outputter.init(session)
call call(quickrun#outputter#buffer#new().init, [a:session], self)
endfunction
function! rspec_outputter.finish(session)
" 文字に色をつける。
" highlight default RSpecGreen ctermfg=Green ctermbg=none guifg=Green guibg=none
" highlight default RSpecRed ctermfg=Red ctermbg=none guifg=Red guibg=none
" highlight default RSpecComment ctermfg=Cyan ctermbg=none guifg=Cyan guibg=none
" highlight default RSpecNormal ctermfg=White ctermbg=none guifg=Black guibg=White
" 背景に色をつける。
highlight default RSpecGreen ctermfg=White ctermbg=Green guifg=White guibg=Green
highlight default RSpecRed ctermfg=White ctermbg=Red guifg=White guibg=Red
" highlight default RSpecComment ctermfg=White ctermbg=Cyan guifg=White guibg=Cyan
" highlight default RSpecNormal ctermfg=Black ctermbg=White guifg=Black guibg=White
call matchadd("RSpecGreen", "^[\.F]*\.[\.F]*$")
call matchadd("RSpecGreen", "^.*, 0 failures$")
call matchadd("RSpecRed", "F")
call matchadd("RSpecRed", "^.*, [1-9]* failures.*$")
call matchadd("RSpecRed", "^.*, 1 failure.*$")
call matchadd("RSpecRed", "^ *(.*$")
call matchadd("RSpecRed", "^ *expected.*$")
call matchadd("RSpecRed", "^ *got.*$")
call matchadd("RSpecRed", "Failure/Error:.*$")
call matchadd("RSpecRed", "^.*(FAILED - [0-9]*)$")
" call matchadd("RSpecRed", "^rspec .*:.*$")
" call matchadd("RSpecComment", " # .*$")
call matchadd("NonText", "Failures:")
call matchadd("NonText", "Finished")
call matchadd("NonText", "Failed")
call call(quickrun#outputter#buffer#new().finish, [a:session], self)
endfunction
call quickrun#register_outputter("rspec_outputter", rspec_outputter)
" カーソル行のみ実行
" let g:quickrun_config['ruby.rspec'] = {'command': "rspec -l {line('.')}"}
augroup UjihisaRSpec
autocmd!
autocmd BufWinEnter,BufNewFile *_spec.rb setl ft=ruby.rspec
augroup END
" ファイル名が_spec.rbで終わるファイルを読み込んだ時に上記の設定を自動で読み込む
function! RSpecQuickrun()
nnoremap <expr><silent><Leader>lr :QuickRun -cmdopt -l line(".")
au User Rails nnoremap <silent><buffer><Leader>ar :!rake spec -drb
let b:quickrun_config = {'type' : 'rspec/bundle'}
endfunction
au BufReadPost *_spec.rb call RSpecQuickrun()
"javascriptの実行をnode.jsで
let $JS_CMD='node'
"}}}
"------------------------------------
" toggle.vim
"------------------------------------
"{{{
"<C-T>で、true<->falseなど切り替えられる
" imap <C-D> <Plug>ToggleI
" nmap <C-D> <Plug>ToggleN
" vmap <C-D> <Plug>ToggleV
"
" let g:toggle_pairs = { 'and':'or', 'or':'and', 'if':'unless', 'unless':'if', 'yes':'no', 'no':'yes', 'enable':'disable', 'disable':'enable', 'pick':'reword', 'reword':'fixup', 'fixup':'squash', 'squash':'edit', 'edit':'exec', 'exec':'pick'}
"}}}
"----------------------------------------
" titanium-vim
"----------------------------------------
"{{{
"g:titanium_android_sdk_path *g:titanium_android_sdk_path*
" Android SDK のパスを指定します。
" 設定が行われていない場合、環境変数 ANDROID_HOME の
" 値を使用します。
"g:titanium_complete_head *g:titanium_complete_head*
" 先頭マッチの Omni 補完を実施するかどうかを制御するフラグ。
" このフラグがOFFの場合、メソッド名から Titanium API の
" クラス名を補完します。
" デフォルトは 0 です。
"g:titanium_method_complete_disabled *g:titanium_method_complete_disabled*
" Titanium API に存在するメソッドを Omni 補完する機能を抑止す
" るためのフラグです。
" デフォルトは 1 です。
"g:titanium_complete_short_style *g:titanium_complete_short_style*
" Omni 補完の候補に表示する項目を Ti prefix にするための
" フラグです。
" デフォルトは 1 です。
"g:titanium_desktop_complete_keywords_path *g:titanium_desktop_complete_keywords_path*
" Desktop API 補完キーワードファイルパスです。
" 指定がない場合は、*ft-titanium* 付属のファイルから補完
" キーワードを検索します。
"g:titanium_mobile_complete_keywords_path *g:titanium_mobile_complete_keywords_path*
" Mobile API 補完キーワードファイルパスです。
" 指定がない場合は、*ft-titanium* 付属のファイルから補完
" キーワードを検索します。
"g:titanium_sdk_root_dir *g:titanium_sdk_root_dir*
" Titanium SDK が格納されている root ディレクトリです。
" 指定なしの場合は、環境に応じて任意のディレクトリを
" 検索し、発見されたSDKを使用します。
"g:titanium_disable_keymap *g:titanium_disable_keymap*
" プラグイン側でのマッピング処理を実施しません。
" このフラグが有効な場合、omnifunc の設定も
" 実施しません。
"****************************************
"ref-titanium
" let g:ref_timobileref_cmd = 'w3m -dump %s'
" let g:ref_timobileref_docroot = '~/.vim/dict/'
" nmap rt :Ref timobileref<Space>
"}}}
"----------------------------------------
" zencoding
"----------------------------------------
"{{{
"<C-Y>, でzencodingを使える
let g:user_zen_leader_key = '<C-Y>'
let g:user_zen_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);",
\ },
\ },
\ 'java' : {
\ 'indentation' : ' ',
\ 'snippets' : {
\ 'main': "public static void main(String[] args) {\n\t|\n}",
\ 'println': "System.out.println(\"|\");",
\ 'class': "public class | {\n}\n",
\ },
\ },
\}
"}}}
"----------------------------------------
" vim-ref
"----------------------------------------
"{{{
" make -f ~/.vim/bundle/vimproc/mac_make
" をしなければいけない
let g:ref_use_vimproc = 1
let g:ref_alc_start_linenumber = 47
let g:ref_no_default_key_mappings = 'K'
let g:ref_open = 'split'
let g:ref_cache_dir = expand('~/.Trash')
let g:ref_refe_cmd = expand('~/.vim/ref/ruby-ref1.9.2/refe-1_9_2')
let g:ref_phpmanual_path = expand('~/.vim/ref/php-chunked-xhtml')
let g:ref_ri_cmd = expand('~/.rvm/bin/ri')
"リファレンスを簡単に見れる。
nmap K <Nop>
nmap <C-K> :<C-U>Ref alc <Space><C-R><C-W><CR>
autocmd FileType ruby,eruby,ruby.rspec nmap <buffer>K :<C-U>Unite ref/refe <Space><C-R><C-W><CR>
autocmd User Rails nmap <buffer><C-K> :<C-U>Unite ref/ri <Space><C-R><C-W><CR>
" refビューワー内の設定
" vim-ref内の移動を楽に
function! s:initialize_ref_viewer()
nmap <buffer><CR> <Plug>(ref-keyword)
nmap <buffer>th <Plug>(ref-back)
nmap <buffer>tl <Plug>(ref-forward)
" nmap <buffer> q<C-w>c
nmap <buffer>q :q!<CR>
setlocal nonumber
endfunction
autocmd FileType ref call s:initialize_ref_viewer()
"alc
nmap ra :<C-u>Ref alc<Space>
nmap rp :<C-u>Unite ref/phpmanual<Space>
nmap rr :<C-u>Unite ref/refe<Space>
nmap ri :<C-u>Unite ref/ri<Space>
nmap rm :<C-u>Unite ref/man<Space>
nmap rpy :<C-u>Unite ref/pydoc<Space>
nmap rpe :<C-u>Unite ref/perldoc<Space>
let g:ref_alc_encoding = 'utf-8'
"使用するには、lynxかw3mが必要です
"lynxの場合
let g:ref_alc_cmd = 'lynx -dump -nonumbers -assume_charset=utf-8 -assume_local_charset=utf-8 -assume_unrec_charset=utf-8 -display_charset=utf-8 %s'
let g:ref_phpmanual_cmd = 'lynx -dump -nonumbers -assume_charset=utf-8 -assume_local_charset=utf-8 -assume_unrec_charset=utf-8 -display_charset=utf-8 %s'
let g:ref_refe_cmd = 'lynx -dump -nonumbers -assume_charset=utf-8 -assume_local_charset=utf-8 -assume_unrec_charset=utf-8 -display_charset=utf-8 %s'
"w3mの場合
" let g:ref_alc_cmd = 'w3m -dump %s'
" let g:ref_html_cmd = 'w3m -dump %s'
" let g:ref_phpmanual_cmd = 'w3m -dump %s'
" let g:ref_rails_cmd = 'w3m -dump %s'
"}}}
"----------------------------------------
" vim-fugitive
"----------------------------------------
"{{{
"vim上からgitを使う 便利
" nnoremap <Space>gd :<C-u>Gdiff<CR>
" nnoremap <Space>gs :<C-u>Gstatus<CR>
" nnoremap <Space>gl :<C-u>Glog<CR>
" nnoremap <Space>ga :<C-u>Gwrite<CR>
" nnoremap <Space>gm :<C-u>Gcommit<CR>
" nnoremap <Space>gM :<C-u>Git commit --amend<CR>
" nnoremap <Space>gb :<C-u>Gblame<CR>
"}}}
"----------------------------------------
" vim-git
"----------------------------------------
"{{{
"vim上からgitを使う 便利
nmap <Space>gd :GitDiff<CR>
nmap <Space>gB :GitBlame<CR>
nmap <Space>gb :Gitblanch<CR>
nmap <Space>gp :GitPush<CR>
nmap <Space>gD :GitDiff --cached<CR>
nmap <Space>gs :GitStatus<CR>
nmap <Space>gl :GitLog<CR>
nmap <Space>ga :GitAdd
nmap <Space>gA :GitAdd -A<CR>
nmap <Space>gm :GitCommit<CR>
nmap <Space>gM :GitCommit --amend<CR>
"}}}
"----------------------------------------
" html5.vim
"----------------------------------------
"{{{
"html5のシンタックスを有効化
"Disable event-handler attributes support:
let g:html5_event_handler_attributes_complete = 0
"Disable RDFa attributes support:
let g:html5_rdfa_attributes_complete = 0
"Disable microdata attributes support:
let g:html5_microdata_attributes_complete = 0
"Disable WAI-ARIA attribute support:
let g:html5_aria_attributes_complete = 0
" HTML 5 tags
syn keyword htmlTagName contained article aside audio bb canvas command
syn keyword htmlTagName contained datalist details dialog embed figure
syn keyword htmlTagName contained header hgroup keygen mark meter nav output
syn keyword htmlTagName contained progress time ruby rt rp section time
syn keyword htmlTagName contained source figcaption
syn keyword htmlArg contained autofocus autocomplete placeholder min max
syn keyword htmlArg contained contenteditable contextmenu draggable hidden
syn keyword htmlArg contained itemprop list sandbox subject spellcheck
syn keyword htmlArg contained novalidate seamless pattern formtarget
syn keyword htmlArg contained formaction formenctype formmethod
syn keyword htmlArg contained sizes scoped async reversed sandbox srcdoc
syn keyword htmlArg contained hidden role
syn match htmlArg "\<\(aria-[\-a-zA-Z0-9_]\+\)=" contained
syn match htmlArg contained "\s*data-[-a-zA-Z0-9_]\+"
"}}}
"------------------------------------
" smartword.vim
"------------------------------------
"{{{
map W <Plug>(smartword-w)
map B <Plug>(smartword-b)
map E <Plug>(smartword-e)
"}}}
"------------------------------------
" camelcasemotion.vim
"------------------------------------
"{{{
" <Shift-wbe>でCameCaseやsnake_case単位での単語移動
map <silent> w <Plug>CamelCaseMotion_w
map <silent> b <Plug>CamelCaseMotion_b
map <silent> e <Plug>CamelCaseMotion_e
sunmap w
sunmap b
sunmap e
" nmap dw d,w
nmap diw di,w
nmap dib di,b
nmap die di,e
nmap viw vi,w
nmap vib vi,b
nmap vie vi,e
nmap ciw ci,w
nmap cib ci,b
nmap cie ci,e
nmap daw da,w
nmap dab da,b
nmap dae da,e
" text-objectで使用できるように
omap <silent> iw <Plug>CamelCaseMotion_iw
xmap <silent> iw <Plug>CamelCaseMotion_iw
omap <silent> ib <Plug>CamelCaseMotion_ib
xmap <silent> ib <Plug>CamelCaseMotion_ib
omap <silent> ie <Plug>CamelCaseMotion_ie
xmap <silent> ie <Plug>CamelCaseMotion_ie
"}}}
"------------------------------------
" matchit.zip
"------------------------------------
"{{{
" % での移動出来るタグを増やす
let b:match_words = '<div.*>:</div>,<ul.*>:</ul>,<li.*>:</li>,<head.*>:</head>,<a.*>:</a>,<p.*>:</p>,<form.*>:</form>,<span.*>:</span>,<iflame.*>:</iflame>:<if>:<endif>,<while>:<endwhile>,<foreach>:<endforeach>'
let b:match_ignorecase = 1
" let b:match_debug = ?
" let b:match_skip
"}}}
"------------------------------------
" powerline
"------------------------------------
"{{{
">の形をを許可する
"ちゃんと/.vim/fontsのfontを入れていないと動かないよ
"set guifont=Ricty_for_Powerline:h10
set guifontwide=Ricty:h10
let g:Powerline_symbols = 'fancy'
"let g:Powerline_symbols = 'compatible'
"}}}
"------------------------------------
" vimshell
"------------------------------------
"{{{
function! s:SID() "{{{
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
endfunction "}}}
function! s:SNR(map) "{{{
return printf("<SNR>%d_%s", s:SID(), a:map)
endfunction "}}}
function! s:skip_spaces(q_args) "{{{
return substitute(a:q_args, '^\s*', '', '')
endfunction "}}}
function! s:parse_one_arg_from_q_args(q_args) "{{{
let arg = s:skip_spaces(a:q_args)
let head = matchstr(arg, '^.\{-}[^\\]\ze\([ \t]\|$\)')
let rest = strpart(arg, strlen(head))
return [head, rest]
endfunction "}}}
function! s:eat_n_args_from_q_args(q_args, n) "{{{
let rest = a:q_args
for _ in range(1, a:n)
let rest = s:parse_one_arg_from_q_args(rest)[1]
endfor
let rest = s:skip_spaces(rest) " for next arguments.
return rest
endfunction "}}}
function! s:globpath(path, expr) "{{{
return split(globpath(a:path, a:expr), "\n")
endfunction "}}}
" 上の関数の他にもちょくちょく定義されてないExコマンドや関数とかありますが
" それについては
" http://github.com/tyru/dotfiles/blob/master/.vimrc
" とか参照してください
" let g:vimshell_user_prompt = '"(" . getcwd() . ") --- (" . $USER . "@" . hostname() . ")"'
let g:vimshell_user_prompt = '"(" . getcwd() . ")" '
let g:vimshell_prompt = '$ '
" let g:vimshell_right_prompt = '"(" . getcwd() . ") --- (" . $USER . "@" . hostname() . ")"'
let g:vimshell_ignore_case = 1
let g:vimshell_smart_case = 1
autocmd FileType vimshell call s:vimshell_settings()
function! s:vimshell_settings() "{{{
" No -bar
command!
\ -buffer -nargs=+
\ VimShellAlterCommand
\ call vimshell#altercmd#define(
\ s:parse_one_arg_from_q_args(<q-args>)[0],
\ s:eat_n_args_from_q_args(<q-args>, 1)
\ )
" Alias
VimShellAlterCommand vi vim
VimShellAlterCommand df df -h
VimShellAlterCommand diff diff --unified
VimShellAlterCommand du du -h
VimShellAlterCommand free free -m -l -t
VimShellAlterCommand j jobs -l
VimShellAlterCommand jobs jobs -l
" VimShellAlterCommand l. ls -d .*
" VimShellAlterCommand l ls -lh
VimShellAlterCommand ll ls -lh
VimShellAlterCommand la ls -A
VimShellAlterCommand less less -r
VimShellAlterCommand sc screen
VimShellAlterCommand whi which
VimShellAlterCommand whe where
VimShellAlterCommand go gopen
VimShellAlterCommand termtter iexe termtter
VimShellAlterCommand sudo iexe sudo
call vimshell#set_alias('l.', 'ls -d .*')
" Abbrev
inoreabbrev <buffer> l@ <Bar> less
inoreabbrev <buffer> g@ <Bar> grep
inoreabbrev <buffer> p@ <Bar> perl
inoreabbrev <buffer> s@ <Bar> sort
inoreabbrev <buffer> u@ <Bar> sort -u
inoreabbrev <buffer> c@ <Bar> xsel --input --clipboard
inoreabbrev <buffer> x@ <Bar> xargs --no-run-if-empty
inoreabbrev <buffer> n@ >/dev/null 2>/dev/null
inoreabbrev <buffer> e@ 2>&1
inoreabbrev <buffer> h@ --help 2>&1 <Bar> less
inoreabbrev <buffer> H@ --help 2>&1
if executable('perldocjp')
VimShellAlterCommand perldoc perldocjp
endif
let less_sh = s:globpath(&rtp, 'macros/less.sh')
if !empty(less_sh)
call vimshell#altercmd#define('vless', less_sh[0])
endif
" Hook
function! s:chpwd_ls(args, context)
call vimshell#execute('ls')
endfunction
call vimshell#hook#set('chpwd', [s:SNR('chpwd_ls')])
" Add/Remove some mappings.
" unmap [n] -buffer <C-n>
" Unmap [n] -buffer <C-p>
" Unmap [i] -buffer <C-k>
" Map [i] -buffer -force <C-l> <Space><Bar><Space>
" Unmap [i] -buffer <Tab>
" Map [i] -remap -buffer -force <Tab><Tab> <Plug>(vimshell_command_complete)
" Misc.
" setlocal backspace-=eol
setlocal updatetime=1000
NeoComplCacheEnable
endfunction "}}}
nmap <Leader>v :VimShell<CR>
"}}}
"------------------------------------
" memolist.vim
"------------------------------------
""{{{
let g:memolist_path = "$HOME/.vim/memolist"
let g:memolist_memo_suffix = "mkd"
let g:memolist_memo_date = "%Y-%m-%d %H:%M"
let g:memolist_memo_date = "epoch"
let g:memolist_memo_date = "%D %T"
let g:memolist_prompt_tags = 1
let g:memolist_prompt_categories = 1
let g:memolist_qfixgrep = 0
let g:memolist_vimfiler = 1
let g:memolist_template_dir_path = "$HOME/.vim/memolist"
" mapping
map <Space>mn :MemoNew<CR>
map <Space>ml :MemoList<CR>
map <Space>mg :MemoGrep<CR>
"}}}
"------------------------------------
" coffee script
"------------------------------------
" filetypeを認識させる"{{{
au BufRead,BufNewFile *.coffee set filetype=coffee
" 保存するたびに、コンパイル
autocmd BufWritePost *.coffee silent CoffeeMake! -cb | cwindow | redraw!"}}}
"------------------------------------
" browsereload-mac
"------------------------------------
"{{{
" リロード後に戻ってくるアプリ
let g:returnApp = "iTerm"
nmap Bc :ChromeReloadStart<CR>
nmap BC :ChromeReloadStop<CR>
nmap Bf :FirefoxReloadStart<CR>
nmap BF :FirefoxReloadStop<CR>
nmap Bs :SafariReloadStart<CR>
nmap BS :SafariReloadStop<CR>
nmap Bo :OperaReloadStart<CR>
nmap BO :OperaReloadStop<CR>
nmap Ba :AllBrowserReloadStart<CR>
nmap BA :AllBrowserReloadStop<CR>
"}}}
"------------------------------------
" t_comment
"------------------------------------
" let g:tcommentMapLeader1 = "<C-_>""{{{
" mappingを消費するので、段々デフォルトになれるべし。
" nmap <Leader>x <C-_><C-_>
" nmap <Leader>b <C-_>p
" vmap <Leader>x <C-_><C-_>
if !exists('g:tcomment_types')
let g:tcomment_types = {}
endif
let g:tcomment_types = {
\'php_surround' : "<?php %s ?>",
\'eruby_surround' : "<%% %s %%>",
\'eruby_surround_minus' : "<%% %s -%%>",
\'eruby_surround_equality' : "<%%= %s %%>",
\'eruby_block' : "<%%=begin rdoc%s=end%%>",
\'eruby_nodoc_block' : "<%%=begin%s=end%%>"
\}
function! SetErubyMapping2()
nmap <buffer> <C-_>c :TCommentAs eruby_surround<CR><Right><Right><Right>
nmap <buffer> <C-_><C-C> :TCommentAs eruby_surround<CR><Right><Right><Right>
nmap <buffer> <C-_>- :TCommentAs eruby_surround_minus<CR><Right><Right><Right>
nmap <buffer> <C-_>= :TCommentAs eruby_surround_equality<CR><Right><Right><Right><Right>
nmap <buffer> <C-_>d :TCommentAs eruby_block<CR><Right><Right><Right><Right>
nmap <buffer> <C-_>n :TCommentAs eruby_nodoc_block<CR><Right><Right><Right><Right>
imap <buffer> <C-_>c <% %><ESC><Left><Left>i
imap <buffer> <C-_><C-C> <% %><ESC><Left><Left>i
imap <buffer> <C-_>- <% -%><ESC><Left><Left><Left>i
imap <buffer> <C-_>= <%= %><ESC><Left><Left>i
imap <buffer> <C-_>d <%= begin rdoc =end %><ESC><Left><Left>i
imap <buffer> <C-_>n <%= begin =end %><ESC><Left><Left>i
vmap <buffer> <C-_>c :TCommentAs eruby_surround<CR>
vmap <buffer> <C-_><C-C> :TCommentAs eruby_surround<CR>
vmap <buffer> <C-_>- :TCommentAs eruby_surround_minus<CR>
vmap <buffer> <C-_>= :TCommentAs eruby_surround_equality<CR>
endfunction
function! SetRubyMapping()
nmap <buffer> <C-_>d :TCommentAs ruby_block<CR><Right><Right><Right><Right>
nmap <buffer> <C-_>n :TCommentAs ruby_nodoc_block<CR><Right><Right><Right><Right>
imap <buffer> <C-_>d <%= begin rdoc =end %><ESC><Left><Left>i
imap <buffer> <C-_>n <%= begin =end %><ESC><Left><Left>i
endfunction
au FileType eruby call SetErubyMapping2()
au FileType ruby,ruby.rspec call SetRubyMapping()
au FileType php nmap <buffer><C-_>c :TCommentAs php_surround<CR><Right><Right><Right>
au FileType php vmap <buffer><C-_>c :TCommentAs php_surround<CR><Right><Right><Right>
"}}}
"------------------------------------
" ctrlp
"------------------------------------
" ctrlp"{{{
let g:ctrlp_map = '<Nul>'
let g:ctrlp_regexp = 1
let g:ctrlp_tabpage_position = 'al'
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_custom_ignore = {
\ 'dir': '\.\(hg\|git\|sass-cache\|svn\)$',
\ 'file': '\.\(dll\|exe\|gif\|jpg\|png\|psd\|so\|woff\)$' }
let g:ctrlp_open_new_file = 't'
let g:ctrlp_open_multiple_files = 'tj'
let g:ctrlp_lazy_update = 1
let g:ctrlp_mruf_max = 1000
let g:ctrlp_mruf_exclude = '\(\\\|/\)\(Temp\|Downloads\)\(\\\|/\)\|\(\\\|/\)\.\(hg\|git\|svn\|sass-cache\)'
let g:ctrlp_mruf_case_sensitive = 0
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("t")': ['<c-n>'],
\ }
hi link CtrlPLinePre NonText
hi link CtrlPMatch IncSearch
function! s:CallCtrlPBasedOnGitStatus()
let s:git_status = system('git status')
if v:shell_error == 128
execute 'CtrlPCurFile'
else
execute 'CtrlP'
endif
endfunction
nnoremap <C-H><C-B> :CtrlPBuffer<Return>
nnoremap <C-H><C-D> :CtrlPClearCache<Return>:CtrlP ~/Dropbox/Drafts<Return>
nnoremap <C-H><C-G> :CtrlPClearCache<Return>:call <SID>CallCtrlPBasedOnGitStatus()<Return>
"}}}
"------------------------------------
" vim-ruby
"------------------------------------
function! s:vimRuby()"{{{
" let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
endfunction
au FileType ruby,eruby,ruby.rspec call s:vimRuby()
"}}}
"------------------------------------
" vim-rails.vim
"------------------------------------
""{{{
"有効化
let g:rails_some_option = 1
let g:rails_level = 4
let g:rails_syntax = 1
let g:rails_statusline = 1
let g:rails_url='http://localhost:3000'
let g:rails_subversion=0
" let g:dbext_default_SQLITE_bin = 'mysql2'
let g:rails_default_file='config/database.yml'
" let g:rails_ctags_arguments = ''
function! SetUpRailsSetting()
nmap <buffer><C-C> <Nop>
imap <buffer><C-C> <Nop>
map <buffer><C-_><C-C> <Nop>
nmap <buffer><Space>r :R<CR>
nmap <buffer><Space>a :A<CR>
nmap <buffer><Space>m :Rmodel<Space>
nmap <buffer><Space>c :Rcontroller<Space>
nmap <buffer><Space>v :Rview<Space>
nmap <buffer><Space>s :Rspec<Space>
nmap <buffer><Space>gm :Rgen model<Space>
nmap <buffer><Space>gc :Rgen contoller<Space>
nmap <buffer><Space>gs :Rgen scaffold<Space>
nmap <buffer><Space>p :Rpreview<CR>
autocmd FileType css,scss,less setlocal sw=2 sts=2 ts=2 et
au FileType ruby,eruby,ruby.rspec let g:neocomplcache_dictionary_filetype_lists = {
\'ruby' : $HOME.'/.vim/dict/rails.dict',
\'eruby' : $HOME.'/.vim/dict/rails.dict'
\}
setl dict+=~/.vim/dict/rails.dict
setl dict+=~/.vim/dict/ruby.dict
endfunction
autocmd User Rails call SetUpRailsSetting()
"}}}
"------------------------------------
" vim-rsense
"------------------------------------
" Rsense
let g:rsenseUseOmniFunc = 1
let g:rsenseHome = expand('~/.vim/ref/rsense-0.3')
function! SetUpRubySetting()
nmap <buffer>tj :RSenseJumpToDefinition<CR>
nmap <buffer>tk :RSenseWhereIs<CR>
nmap <buffer>td :RSenseTypeHelp<CR>
endfunction
autocmd FileType ruby,eruby,ruby.rspec call SetUpRubySetting()
"------------------------------------
" gist.vim
"------------------------------------
"{{{
let g:gist_clip_command = 'pbcopy'
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
let g:gist_browser_command = 'w3m %URL%'
let g:github_user = 'taichouchou'
nnoremap <C-H>g :Gist<CR>
nnoremap <C-H>gp :Gist -p<CR>
nnoremap <C-H>ge :Gist -e<CR>
nnoremap <C-H>gd :Gist -d<CR>
nnoremap <C-H>gl :Gist -l<CR>
"}}}
"------------------------------------
" twitvim
"------------------------------------
nnoremap <silent><Space>n :Unite tweetvim<CR>
" you can display tweet's source.
let g:tweetvim_display_source = 1
let g:tweetvim_display_time = 0
let g:tweetvim_open_buffer_cmd = 'tabnew'
"------------------------------------
" alter
"------------------------------------
"specの設定
au User Rails nmap <buffer><Space>s <Plug>(altr-forward)
au User Rails nmap <buffer><Space>s <Plug>(altr-back)
call altr#define('%.rb', 'spec/%_spec.rb')
" For rails tdd
call altr#define('app/models/%.rb', 'spec/models/%_spec.rb', 'spec/factories/%s.rb')
call altr#define('app/controllers/%.rb', 'spec/controllers/%_spec.rb')
call altr#define('app/helpers/%.rb', 'spec/helpers/%_spec.rb')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment