Skip to content

Instantly share code, notes, and snippets.

@aiya000
Created May 2, 2014 03:49
Show Gist options
  • Save aiya000/11467236 to your computer and use it in GitHub Desktop.
Save aiya000/11467236 to your computer and use it in GitHub Desktop.
"-------------------------"
" パラメータ設定 "
"-------------------------"
"{{{
"----------------------------------------
" ヒント "
" @Undecide => 完全に動作するか未確定
" @Wakegawa => わけがわからないよ(なぜかこれなら動作する…等)
" @Provisional => 仮設定 | 仮配置
"----------------------------------------
let s:isWindows = has('win32') || has('win64')
let s:isCygwin = has('win32unix')
let s:isDosWin = s:isWindows && !s:isCygwin
let s:isUnix = has('unix')
let s:isMac = has('mac')
let s:isUbuntu = system('uname -a') =~? 'Ubuntu'
let s:vimrc = expand('~/.vimrc')
let s:vimHome = expand('~/.vim')
let s:backupdir = expand('~/.backup/vim_backup')
let s:directory = s:backupdir.'/swp'
let s:undodir = s:backupdir.'/undo'
let s:viewdir = s:backupdir.'/view'
let s:username = expand('$USER')
let s:groupname = expand('$USER') " $GROUPがねえ in Ubuntu and Cygwin.
"}}}
"-------------------------"
" イニシャライズ "
"-------------------------"
filetype plugin indent on
" NeoBundleの存在確認 " {{{
let s:neobundleDir = s:vimHome.'/bundle/neobundle.vim/'
function! s:fetchNeoBundle() " {{{
if executable('git')
execute '!
\ echo "NeoBundle was not installed...";
\ echo "Installing NeoBundle.";
\ echo;
\ git clone http://github.com/Shougo/neobundle.vim '.s:neobundleDir
return 0
else
executer '!
\ echo "Sorry, You do not have git command."
\ echo "Cannot introduce NeoBundle."'
return -1
endif
endfunction " }}}
if has('vim_starting')
try
set runtimepath+=~/.vim/bundle/neobundle.vim
call neobundle#rc(expand('~/.vim/bundle/'))
catch
if isdirectory(s:neobundleDir) && !exists(':NeoBundle')
call system('rm -rf '.s:neobundleDir)
endif
if s:fetchNeoBundle()
set runtimepath+=~/.vim/bundle/neobundle.vim
call neobundle#rc(expand('~/.vim/bundle/'))
endif
endtry
endif
unlet s:neobundleDir
" }}}
" グループ " {{{
augroup plugin_prefs | autocmd!
augroup END
augroup file_events | autocmd!
augroup END
augroup file_posit_save | autocmd!
augroup END
augroup prog_types | autocmd!
augroup END
augroup syntax_highlights | autocmd!
augroup END
" }}}
" (バックアップ|スワップ)ポイントの確認 " {{{
if !isdirectory(s:backupdir)
call mkdir(s:backupdir, 'p', 0755)
call system(printf('chown -R %s:%s %s', s:username, s:groupname, s:backupdir))
endif
if !isdirectory(s:directory)
call mkdir(s:directory, 'p', 0755)
call system(printf('chown -R %s:%s %s', s:username, s:groupname, s:directory))
endif
if !isdirectory(s:undodir)
call mkdir(s:undodir, 'p', 0755)
call system(printf('chown -R %s:%s %s', s:username, s:groupname, s:backupdir))
endif
" }}}
"-------------------------"
" プラグイン設定 "
"-------------------------"
"*** プラグイン管理 ***"{{{
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle 'basyura/twibill.vim'
NeoBundle 'tyru/open-browser.vim'
NeoBundle 'h1mesuke/unite-outline'
NeoBundle 'basyura/bitly.vim'
NeoBundle 'Shougo/unite.vim'
NeoBundle 'Shougo/vimproc.vim'
NeoBundle 'basyura/TweetVim'
NeoBundle 'mattn/webapi-vim'
NeoBundle 'Shougo/vimshell.vim'
NeoBundle 'rhysd/wandbox-vim'
NeoBundle 'thinca/vim-quickrun'
NeoBundle 'osyo-manga/quickrun-outputter-replace_region'
NeoBundle 'yuratomo/gmail.vim'
NeoBundle 'basyura/J6uil.vim'
NeoBundle 'osyo-manga/vim-gyazo'
NeoBundle 'yuratomo/w3m.vim'
NeoBundle 'mattn/learn-vimscript'
NeoBundle 'rbtnn/vimconsole.vim'
NeoBundle 'jimsei/winresizer'
NeoBundle 'add20/vim-conque'
NeoBundle 'supermomonga/thingspast.vim'
NeoBundle 'supermomonga/vimshell-kawaii.vim'
NeoBundle 'mattn/excitetranslate-vim'
NeoBundle 'kana/vim-altercmd'
NeoBundle 'mattn/unite-advent_calendar'
NeoBundleLazy 'thinca/vim-splash'
NeoBundle 'supermomonga/jazzradio.vim'
NeoBundle 'mattn/favstar-vim'
NeoBundle 'ujihisa/unite-colorscheme'
NeoBundle 'Shougo/vinarise.vim'
NeoBundle 'mattn/gist-vim'
"}}}
"*** プラグイン個別設定 ***" {{{
call neobundle#config('vimproc.vim', {
\ 'build' : {
\ 'unix' : 'make -f make_unix.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'windows' : 'make -f make_mingw32.mak',
\ 'mac' : 'make -f make_mac.mak'
\ }
\})
call neobundle#config('TweetVim', {
\ 'depends' : [
\ 'basyura/twibill.vim',
\ 'tyru/open-browser.vim',
\ 'h1mesuke/unite-outline',
\ 'basyura/bitly.vim',
\ 'Shougo/unite.vim',
\ 'Shougo/vimproc.vim',
\ 'mattn/favstar-vim'
\ ],
\ 'autoload' : {'on_source' : ['vimproc.vim']}
\})
call neobundle#config('vimshell.vim', {
\ 'depends' : ['Shougo/vimproc.vim'],
\})
call neobundle#config('quickrun-outputter-replace_region', {
\ 'depends' : ['thinca/vim-quickrun']
\})
call neobundle#config('gmail.vim', {
\ 'depends' : ['Shougo/vimproc.vim']
\})
call neobundle#config('J6uil.vim', {
\ 'depends' : [
\ 'mattn/webapi-vim',
\ 'Shougo/vimproc.vim',
\ 'tyru/open-browser.vim',
\ 'Shougo/unite.vim'
\ ]
\})
call neobundle#config('vim-gyazo', {
\ 'depends' : [
\ 'tyru/open-browser.vim',
\ 'basyura/TweetVim'
\ ]
\})
call neobundle#config('vimshell-kawaii.vim', {
\ 'depends' : ['Shougo/vimshell'],
\ 'autoload' : {'on_source' : ['vimshell.vim']}
\})
call neobundle#config('unite-advent_calendar', {
\ 'depends' : ['h1mesuke/unite-outline']
\})
call neobundle#config('vim-splash', {
\ 'autoload' : {'commands' : 'Splash'}
\})
call neobundle#config('jazzradio.vim', {
\ 'depends' : ['Shougo/unite.vim']
\})
" }}}
"------------------------"
"*** プラグイン別設定 ***"
"------------------------"
"--- vim-quickrun ---" {{{
let g:quickrun_config = {
\ '_' : {
\ 'split' : '',
\ 'runner' : 'vimproc',
\ 'runner/vimproc/updatetime' : 10,
\ 'hook/time/enable' : 1,
\ },
\ 'cpp' : {
\ 'command' : 'g++',
\ 'cmdopt' : '-I/usr/include/c++/4.9 -I/usr/include/c++/4.9/x86_64-linux-gnu -std=c++11',
\ },
\ 'java' : {'cmdopt' : '-source 1.7'},
\}
if s:isUnix
let g:quickrun_config['cs'] = {
\ 'command' : 'gmcs',
\ 'exec' : ['%c %o %s:p > /dev/null', 'mono %s:p:r.exe', 'rm %s:p:r.exe'],
\ 'tempfile' : '{tempname()}.cs',
\}
endif
if s:isCygwin
let g:quickrun_config['java'] = {
\ 'command' : 'javac',
\ 'exec' : ['%c %o `echo %s | sed s:¥:/:g | cygpath -w -f -`', '%c %s:t:r %a'],
\ 'hook/output_encode/encoding': 'Shift_JIS',
\ 'cmdopt' : '-source 1.7 -encoding UTF-8',
\}
let g:quickrun_config['haskell'] = {
\ 'command' : 'ghc',
\ 'exec' : 'ghc %s',
\}
endif
augroup plugin_prefs
autocmd FileType quickrun setlocal wrap
augroup END
" }}}
"--- unite.vim ---"{{{
augroup plugin_prefs
autocmd!
autocmd FileType *unite* nmap <buffer> <C-j> <CR>
autocmd FileType *unite* imap <buffer> <C-j> <CR>
augroup END
"}}}
"--- TweetVim ---"{{{
"let g:tweetvim_display_username = 0
let g:tweetvim_async_post = 1
augroup plugin_prefs
autocmd!
autocmd FileType tweetvim nmap <buffer> <leader>R <Plug>(tweetvim_action_remove_status)
autocmd FileType tweetvim nmap <buffer> s :TweetVimSay <CR>
autocmd FileType tweetvim nmap <buffer> <C-r> :TweetVimHomeTimeline <CR>
autocmd FileType tweetvim nmap <buffer> <C-a> :TweetVimSwitchAccount<Space>
autocmd FileType tweetvim nmap <buffer> <C-j> <CR>
autocmd FileType tweetvim nmap <buffer> U :TweetVimUserTimeline<Space>
autocmd FileType tweetvim setlocal wrap
autocmd FileType tweetvim_say nmap <buffer> <C-j> <CR>
autocmd FileType tweetvim_say nmap <buffer> q <NOP>
augroup END
"}}}
"--- J6uil---"{{{
augroup plugin_prefs
autocmd FileType J6uil nmap <buffer> <C-j> <CR>
autocmd FileType J6uil_say nmap <buffer> <C-j> <CR>
augroup END
"}}}
"--- vimshell.vim ---"{{{
"let g:vimshell_user_prompt = 'fnamemodify(getcwd(), ":~")'
let g:vimshell_no_save_history_commands = {
\ 'history': 1,
\ 'ls' : 1,
\ 'clear' : 1
\}
augroup plugin_prefs
autocmd FileType vimshell nunmap <buffer> Q
autocmd FileType vimshell nunmap <buffer> q
autocmd FileType vimshell nmap <buffer> <C-j> <CR>
autocmd FileType vimshell imap <buffer> <C-j> <CR>
autocmd FileType vimshell imap <buffer> <C-l> <Plug>(vimshell_clear)
autocmd FileType vimshell imap <buffer> <C-k> <Plug>(vimshell_history_unite)
autocmd FileType vimshell iunmap <buffer> <C-p>
autocmd FileType vimshell iunmap <buffer> <C-n>
autocmd FileType vimshell
\ call vimshell#altercmd#define('thanks', "echo \"You're welcome!\"")
\| call vimshell#set_alias('svsp', ':sp | VimShellCreate')
\| call vimshell#set_alias('vvsp', ':vsp | VimShellCreate')
augroup END
"}}}
"--- gmail.vim ---"{{{
augroup plugin_prefs
autocmd FileType gmail-list nmap <buffer> <C-j> <CR>
autocmd FileType gmail-mailbox nmap <buffer> <C-j> <CR>
autocmd FileType gmail-bnew nmap <buffer> <C-j> <CR>
augroup END
"}}}
"--- w3m.vim ---"{{{
let g:w3m#external_browser = 'firefox'
let g:w3m#homepage = 'http://www.google.co.jp/'
augroup plugin_prefs
autocmd FileType w3m nmap <buffer> <C-j> <CR>
autocmd FileType w3m nmap <buffer> H <BS>
autocmd FileType w3m nmap <buffer> <C-u> :W3mAddressBar <CR>
autocmd FileType w3m nmap <buffer> <leader>E :W3mShowExtenalBrowser <CR>
augroup END
"}}}
"--- vimconsole.vim ---"{{{
augroup plugin_prefs
autocmd FileType VimConsole nmap <buffer> <C-j> <CR>
autocmd FileType VimConsole nmap <buffer> <C-r> VimConsoleRedraw <CR>
autocmd FileType VimConsole nmap <buffer> <C-l> VimConsoleClear <CR>
augroup END
"}}}
"--- vim-conque ---"{{{
let g:ConqueTerm_CloseOnEnd = 1
let g:ConqueTerm_SessionSupport = 1
let g:ConqueTerm_ReadUnfocused = 1
let g:ConqueTerm_Color = 1
let g:ConqueTerm_InsertOnEnter = 0
let g:ConqueTerm_StartMessages = 1
if match(@%, 'ghci') == 0
augroup file_posit_save
autocmd!
augroup END
augroup syntax_highlights
set nolist
augroup END
endif
"}}}
"--- jazzradio.vim ---"{{{
if neobundle#tap('jazzradio.vim')
call neobundle#config({
\ 'autoload' : {
\ 'unite_sources' : ['jazzradio'],
\ 'commands' : [
\ 'JazzradioUpdateChannels',
\ 'JazzradioStop', {
\ 'name' : 'JazzradioPlay',
\ 'complete' : 'customlist,jazzradio#channel_id_comlete'
\ }
\ ],
\ 'function_prefix' : 'Jazzradio'
\ }
\})
endif
"}}}
"--- open-browser.vim ---"{{{
augroup plugin_prefs
nmap <Leader>w <Plug>(openbrowser-open)
augroup END
"}}}
"--- For Private ---"{{{
" プライバシー設定を分割
if filereadable(expand('~/.vimrc_private'))
source ~/.vimrc_private
endif
"}}}
"-------------------------"
" 表示設定 "
"-------------------------"
"{{{
" 常にステータスバー表示
set laststatus=2
" 折り曲げ禁止
set nowrap
" 行番号表示
set number
" インデント幅
set tabstop=4
" ☆<-これとかの表示を直す(ただしgnome-terminalでは直らない)
if !s:isUbuntu | set ambiwidth=double | endif
" それでもなんとか緩和する
syntax sync fromstart
" カラースキーム設定
colorscheme desert
" 構文ハイライトをオン
syntax on
" (タブ|空白|改行)を可視化
augroup syntax_highlights
set list
set listchars=tab:»_,trail:_,extends:»,precedes:«,nbsp:%
augroup END
" 構文ハイライトを補強 " {{{
function! s:syntaxHolyLight()
"syntax match EmSpace " " display containedin=ALL
"highlight EmSpace cterm=standout ctermfg=White
endfunction
augroup syntax_highlights
"highlight Normal cterm=NONE ctermfg=Cyan
highlight Visual cterm=underline ctermfg=White ctermbg=Cyan
highlight IncSearch ctermfg=Black ctermbg=Cyan
highlight Pmenu cterm=standout ctermfg=Blue
highlight PmenuSel ctermfg=Black ctermbg=White
highlight TabLine cterm=standout ctermfg=Blue
highlight TabLineSel cterm=NONE ctermfg=Cyan
highlight TabLineFill cterm=standout ctermfg=Blue
highlight VertSplit cterm=NONE ctermfg=Cyan ctermbg=Blue
highlight StatusLine ctermfg=Cyan
highlight StatusLineNC ctermfg=Blue
highlight LineNr ctermfg=Blue
autocmd InsertEnter ?* highlight StatusLine ctermfg=Black ctermbg=Cyan
autocmd InsertLeave ?* highlight StatusLine ctermfg=Cyan
autocmd BufWinEnter ?* call s:syntaxHolyLight()
augroup END
" }}}
"}}}
"-------------------------"
" 挙動の設定 "
"-------------------------"
"{{{
" viとの互換性をオフ(カーソルキー有効化)
set nocompatible
" バックスペース動作をテキストエディタと同じように
if s:isCygwin
set whichwrap=b,s,h,l,<,>,[,]
set backspace=indent,eol,start
noremap x127 x08
noremap! x127 x08
endif
" 自動改行オフ
set textwidth=0
" オートインデント
set autoindent
" インクリメンタルサーチ
set incsearch
" C言語特化型オートインデント(bcpad等のようなアレ)
set cindent
" オートインデント時のインデント幅
set shiftwidth=4
" 「{{{」「}}}」で折りたたみ
set fdm=marker
" swpファイルの集約
let &directory = s:directory
" View履歴の保持
let &viewdir = s:viewdir
" Vimを閉じてもUndo履歴を保持する
if has('persistent_undo')
set undofile
let &undodir = s:undodir
endif
" 音の代わりに画面フラッシュ
set visualbell
"}}}
"-------------------------"
" 内部設定 "
"-------------------------"
"{{{
" 基本のファイルエンコーディング
set fileencoding=UTF-8
" 履歴を残す(50件まで)
set history=50
" Vimプラグイン読込み先の追加
set runtimepath+=~/.vim/makes/arot13.vim
set runtimepath+=~/.vim/vimball
" Vimballのインストール先を設定
let g:vimball_home = expand('~/.vim/vimball')
" コマンド補完候補を表示
set wildmenu
"set wildmode=list
" パス区切りをスラッシュに
set shellslash
"}}}
"-------------------------"
" イベント処理 "
"-------------------------"
"{{{
call system('touch dekitenai')
" このファイルを保存した後に自動再読み込み
augroup file_events
autocmd BufWritePost s:vimrc source s:vimrc
augroup END
" カーソル位置を保存
augroup file_posit_save
autocmd BufWinLeave ?* silent mkview
autocmd BufWinEnter ?* silent loadview
augroup END
" 分毎にファイルをバックアップする
set nobackup
function! UpdateBackupByDate() "{{{
let l:dailydir = s:backupdir . '/' . strftime("%Y-%m-%d")
if !isdirectory(l:dailydir)
call mkdir(l:dailydir, 'p', 0755)
call system(printf('chown -R %s:%s %s', s:username, s:groupname, l:dailydir))
endif
let filepath = split(expand('%'), '/')
let filename = filepath[len(filepath)-1] . strftime('_at_%H:%M')
execute 'write! '.l:dailydir.'/'.filename
endfunction "}}}
augroup file_events | autocmd BufWritePre ?* silent call UpdateBackupByDate() | augroup END
"}}}
"-------------------------"
" キーマッピング "
"-------------------------"
"{{{
nmap <C-j> <CR>
imap <C-j> <CR>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-a> <Home>
cnoremap <C-d> <Del>
if s:isDosWin
cnoremap <C-e> <End>
cnoremap <C-h> <Backspace>
cnoremap <C-i> <Tab>
endif
cnoremap <C-k> <C-\>e getcmdpos() < 2 ?'':getcmdline()[:getcmdpos()-2] <CR>
"}}}
"-------------------------"
" FileType "
"-------------------------"
"{{{
augroup file_events
autocmd FileType netrw nmap <C-j> <CR>
autocmd FileType netrw nmap q :quit<CR>
augroup END
augroup prog_types
autocmd FileType haskell syntax match HfSpace "^\s*" display containedin=ALL
autocmd FileType haskell highlight HfSpace cterm=underline ctermfg=Cyan
augroup END
"}}}
"-------------------------"
" エイリアス "
"-------------------------"
"{{{
call altercmd#load()
command! VimConfig e ~/.vimrc
command! VimpConfig e ~/.vimrc_private
command! Reload so ~/.vimrc
command! Wso w|so %
command! ForceSave w !sudo tee > /dev/null %
function! ClearViewFunc() "{{{
call system('rm '.s:viewdir.'/*')
endfunction "}}}
command! ClearView call ClearViewFunc()
command! CV call ClearViewFunc()
command! ColorPreview Unite colorscheme -auto-preview
command! NeoBundleSearch Unite neobundle/search
" Twitter {{{
"-- 基本 --"
command! Twitter TweetVimHomeTimeline
function! TwitterTabFunc() "{{{
execute ':tabnew | TweetVimHomeTimeline'
endfunction "}}}
command! TwitterTab call TwitterTabFunc()
command! Tweet TweetVimSay
"-- プライベートアカウント --"
function! TwitterPrivateFunc() "{{{
execute ':TweetVimSwitchAccount '.g:myPriv['twitter'].privAc
execute ':TweetVimHomeTimeline'
endfunction "}}}
command! TwitterPrivate call TwitterPrivateFunc()
function! TwitterPrivateTabFunc() "{{{
execute ':tabnew'
call TwitterPrivateFunc()
endfunction "}}}
command! TwitterPrivateTab call TwitterPrivateTabFunc()
function! TweetPrivateFunc() "{{{
execute ':TweetVimSwitchAccount '.g:myPriv['twitter'].privAc
execute ':TweetVimSay'
endfunction "}}}
command! TweetPrivate call TweetPrivateFunc()
"-- パブリックアカウント --"
function! TwitterPublicFunc() "{{{
let publicAc = 'public_ai000ya'
execute ':TweetVimSwitchAccount '.g:myPriv['twitter'].publAc
execute ':TweetVimHomeTimeline'
endfunction "}}}
command! TwitterPublic call TwitterPublicFunc()
function! TwitterPublicTabFunc() "{{{
execute ':tabnew'
call TwitterPublicFunc()
endfunction "}}}
command! TwitterPublicTab call TwitterPublicTabFunc()
function! TweetPublicFunc() "{{{
execute ':TweetVimSwitchAccount '.g:myPriv['twitter'].publAc
execute ':TweetVimSay'
endfunction "}}}
command! TweetPublic call TweetPublicFunc()
" }}}
command! Bitly TweetVimBitly
AlterCommand tvs TweetVimSwitchAccount
AlterCommand Lingr J6uil
command! Translate ExciteTranslate
command! JazzUpdate JazzradioUpdateChannels
command! JazzList Unite jazzradio
AlterCommand JazzPlay JazzradioPlay
command! JazzStop JazzradioStop
if s:isUnix && executable('ghci')
command! Ghci ConqueTerm ghci
endif
"}}}
"-------------------------"
" デイニシャライズ "
"-------------------------"
"{{{
function! UnloadFileEvent() " {{{
augroup file_posit_save
autocmd!
augroup END
endfunction " }}}
autocmd FileType vimshell call UnloadFileEvent()
"}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment