Skip to content

Instantly share code, notes, and snippets.

@aiya000
Created May 11, 2014 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aiya000/f8e67c2c9e2a712411e2 to your computer and use it in GitHub Desktop.
Save aiya000/f8e67c2c9e2a712411e2 to your computer and use it in GitHub Desktop.
"----------------------------"
" Target of this config "
" - UNIX like OS "
" - Cygwin "
" - Kaoriya Vim "
"----------------------------"
"---------------------"
" Parameters "
"---------------------"
"{{{
"----------------------------------------
" {- Hints -} "
" @Undecide => Do not supported functions when now.
" @Wakegawa => I don't know why this functioned.
" @Provision => (Provisional config | Provisional arrangement)
" -> I may place this config to different place.
" @DNOF => This operate don't functioned.
" @See => Referred URL, Saw Document, and etc...
"-------------------
" Designating the target platform.
" @Hoge{Win|Ubuntu} : This function for Win and Ubuntu.
" @Hoge!{Mac} : This function for other than Mac.
"----------------------------------------
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:vimHome = expand('~/.vim')
let s:vimrc = expand('~/.vimrc')
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.
"}}}
"-------------------------"
" Initialization "
"-------------------------"
filetype plugin indent on
" For Support Kaoriya Vim {{{
if s:isDosWin
" もはやKaoriyaVimはここで収束させる
let s:vimHome = $VIM.'/_vim/'
let s:vimrc = $VIM.'/_vimrc'
let &runtimepath = &runtimepath.','.s:vimHome
let &runtimepath = &runtimepath.','.s:vimHome.'/bundle/neobundle.vim'
let $HOME = $VIM
if isdirectory('/cygwin')
let $PATH = '/cygwin/bin;/cygwin/usr/bin;/cygwin/usr/sbin;'.$PATH
endif
" Build Base Directories
if !isdirectory(s:vimHome)
call mkdir(s:vimHome)
endif
" For Using Default vimproc
if isdirectory(s:vimHome.'/bundle/vimproc.vim')
call system('rm -rf '.s:vimHome.'/bundle/vimproc.vim')
endif
" Visualize Unseen Chars for cp932
set list
set listchars=tab:>_
" Unset Kaoriya Preference
set noignorecase
set nosmartcase
endif
"}}}
" Check NeoBundle exists {{{
let s:bundleDir = s:vimHome.'/bundle/'
let s:neobundleDir = s:bundleDir.'/neobundle.vim/'
if !isdirectory(s:bundleDir)
call mkdir(s:bundleDir)
endif
function! s:rmEmptyBundleDir() "{{{
let dirs = split(system('ls '.s:bundleDir), '\n')
for dir in dirs
let pluginDir = s:bundleDir.'/'.dir
let isEmpty = system('ls '.pluginDir) ==# ''
if isEmpty
call system('rmdir '.pluginDir)
endif
endfor
endfunction "}}}
function! s:fetchNeoBundle() " {{{
if executable('git')
echo 'NeoBundle was not installed...'
echo 'Installing NeoBundle.'
execute '!git clone http://github.com/Shougo/neobundle.vim '.s:neobundleDir
return 0
else
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
" Throw error when nothing NeoBundle
call neobundle#rc(expand(s:bundleDir))
catch
if isdirectory(s:neobundleDir) && !exists(':NeoBundle')
" Plugin directories may be empty when git cloned.
call s:rmEmptyBundleDir() "@Undecide{Win}
echo 'bundle directories initialized.'
endif
if s:fetchNeoBundle()
call neobundle#rc(expand(s:bundleDir))
echo 'NeoBundle installed.'
echo 'Please closing vim and reopening vim once,'
echo 'and executing :NeoBundleInstall .'
endif
endtry
endif
unlet s:neobundleDir
unlet s:bundleDir
"}}}
" autocmd Groups {{{
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
"}}}
" Check Backup, Swap and Undo directory exists {{{
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
"}}}
"-------------------------"
" Plugin Manage "
"-------------------------"
"*** Plugin List ***"{{{
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'
NeoBundle 'vim-scripts/Align'
"NeoBundleCheck
"}}}
"*** Plugin Depends and Auto Config ***" {{{
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.vim'],
\ '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']
\})
" }}}
"------------------------"
"*** Plugin Configure ***"
"------------------------"
"--- 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
" }}}
"--- TweetVim ---"{{{
"let g:tweetvim_display_username = 0
let g:tweetvim_async_post = 1
augroup plugin_prefs
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> U :TweetVimUserTimeline<Space>
autocmd FileType tweetvim setlocal wrap
autocmd FileType tweetvim_say nmap <buffer> q <NOP>
autocmd FileType tweetvim_say imap <buffer> <C-i> <Space><Space>
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 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
"}}}
"--- 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> H <BS>
autocmd FileType w3m nmap <buffer> <C-u> :W3mAddressBar <CR>
autocmd FileType w3m nmap <buffer> <leader>E :W3mShowExtenalBrowser <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
"}}}
"--- 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
"}}}
"--- For Private ---"{{{
" プライバシー設定を分割
if filereadable(expand('~/.vimrc_private'))
source ~/.vimrc_private
endif
"}}}
"-------------------------"
" View Configure "
"-------------------------"
"{{{
" Status Bar always displayed
set laststatus=2
" Line is not wrap
set nowrap
" View line number
set number
" Indent Width
set tabstop=4
" Highlight Hit Keyword
set hlsearch
" ☆Fix View 2byte Code (Not support gnore-terminal)
if !s:isUbuntu | set ambiwidth=double | endif
" それでもなんとか緩和する
syntax sync fromstart
" Set Color Scheme
colorscheme desert
" Syntax Highlight On
syntax on
" Visualize Tab and Space
if !s:isDosWin
set list
set listchars=tab:»_,trail:_,extends:»,precedes:«,nbsp:%
endif
" 構文ハイライトを補強 " {{{
"function! s:syntaxHolyLight()
" syntax match EmSpace " " display containedin=ALL
" highlight EmSpace cterm=standout ctermfg=White
"endfunction
"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 ctermbg=Black
highlight StatusLineNC ctermfg=Blue
highlight LineNr ctermfg=Blue
augroup syntax_highlights
autocmd InsertEnter ?* highlight StatusLine ctermfg=Black ctermbg=Cyan
autocmd InsertLeave ?* highlight StatusLine ctermfg=Cyan ctermbg=Black
"autocmd BufWinEnter ?* call s:syntaxHolyLight()
augroup END
" }}}
"}}}
"-------------------------"
" 挙動の設定 "
"-------------------------"
"{{{
" Set Compatibility with vi is off
set nocompatible
" Set Backspace can delete empty line
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
" Regex Search Engine Type[1]
" 0: if search new engine is failure then search old engine [default]
" 1: search old engine only
" 2: search new engine only
"set regexpengine=0
" インクリメンタルサーチ
set incsearch
" don't return file top when completed searching
"set nowrapscan
" Tag Jump Quickly
"set tagbsearch
" 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
"}}}
"-------------------------"
" イベント処理 "
"-------------------------"
"{{{
function! s:ghciType() "{{{
if match(@%, 'ghci') == 0
augroup file_posit_save
autocmd!
augroup END
set nolist " TODO @NOF
endif
endfunction "}}}
augroup file_events
" Auto Reload when save this file
autocmd BufWritePost $MYVIMRC source $MYVIMRC
" Disable Highlights when buffer is GHCi
autocmd BufWinEnter ?* call s:ghciType()
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
"}}}
"-----------------------------------"
" グローバルキーマッピング "
"-----------------------------------"
"{{{
" Disable De Facto Standard Keys {{{
nnoremap <Up> <NOP>
nnoremap <Down> <NOP>
nnoremap <Left> <NOP>
nnoremap <Right> <NOP>
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
" }}}
" Bash like KeyMaps {{{
nmap <C-j> <CR>
imap <C-j> <CR>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-a> <Home>
cnoremap <C-h> <Backspace>
cnoremap <C-d> <Del>
cnoremap <C-e> <End>
cnoremap <C-k> <C-\>e getcmdpos() < 2 ?'':getcmdline()[:getcmdpos()-2] <CR>
" }}}
" Original KeyMaps {{{
nnoremap <C-k><C-l> :so %<CR>
" Appendency Event [InsertLeave]
inoremap <C-c> <Esc>
augroup plugin_prefs
nmap <Leader>w <Plug>(openbrowser-open)
augroup END
" }}}
"}}}
"--------------------------"
" FileTypes "
"--------------------------"
"{{{
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 execute 'e '.s:vimrc
command! VimConfigTab execute 'tabnew|e '.s:vimrc
command! Reload execute 'so '.s:vimrc
command! Wso w|so %
if !s:isWindows
command! ForceSave w !sudo tee > /dev/null %
endif
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
command! GistPrivate Gist -p
" 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() "{{{
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 executable('ghc') && executable('ghci')
command! Ghc !runghc %
command! Ghci ConqueTerm ghci
command! Vghci vsp|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