.vimrc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. " coding:utf-8
  2. " ζ*'ヮ')ζ ζ(*'ヮ'リ+
  3. "
  4. set ignorecase
  5. set smartcase
  6. set tabstop=2
  7. set expandtab
  8. set autoindent
  9. set backspace=2
  10. set wrapscan
  11. set showmatch
  12. set wildmenu
  13. set formatoptions+=mM
  14. set softtabstop=2
  15. set shiftwidth=4
  16. set fileencodings=utf-8,sjis,cp932,euc-jp,default,latin
  17. set number
  18. set ruler
  19. set nolist
  20. set wrap
  21. set laststatus=2
  22. set cmdheight=2
  23. set showcmd
  24. set title
  25. set hlsearch
  26. colorscheme evening
  27. syntax on
  28. set enc=utf8
  29. " ファイル名に大文字小文字の区別がないシステム用の設定:
  30. " (例: DOS/Windows/MacOS)
  31. "
  32. if filereadable($VIM . '/vimrc') && filereadable($VIM . '/ViMrC')
  33. " tagsファイルの重複防止
  34. set tags=./tags,tags
  35. endif
  36. " コンソールでのカラー表示のための設定(暫定的にUNIX専用)
  37. if has('unix') && !has('gui_running')
  38. let uname = system('uname')
  39. if uname =~? "linux"
  40. set term=builtin_linux
  41. elseif uname =~? "freebsd"
  42. set term=builtin_cons25
  43. elseif uname =~? "Darwin"
  44. set term=beos-ansi
  45. else
  46. set term=builtin_xterm
  47. endif
  48. unlet uname
  49. endif
  50. " コンソール版で環境変数$DISPLAYが設定されていると起動が遅くなる件へ対応
  51. if !has('gui_running') && has('xterm_clipboard')
  52. set clipboard=exclude:cons\\\|linux\\\|cygwin\\\|rxvt\\\|screen
  53. endif
  54. " タブページの切り替えをWindowsのように
  55. " CTRL+Tab SHIFT+Tabで行うように.
  56. if v:version >= 700
  57. nnoremap <C-Tab> gt
  58. nnoremap <C-S-Tab> gT
  59. endif
  60. if has('+regexpengine')
  61. set re=0
  62. endif
  63. set nocompatible
  64. filetype off
  65. if has('vim_starting')
  66. set runtimepath+=~/.vim/neobundle.vim.git
  67. endif
  68. call neobundle#rc(expand('~/.bundle'))
  69. let g:neobundle_default_git_protocol='git'
  70. NeoBundle 'thinca/vim-openbuf'
  71. NeoBundle 'jnwhiteh/vim-golang'
  72. NeoBundle 'osyo-manga/vim-snowdrop'
  73. NeoBundle 'Shougo/echodoc', '', 'default'
  74. call neobundle#config('echodoc', {
  75. \ 'lazy' : 1,
  76. \ 'autoload' : {
  77. \ 'insert' : 1,
  78. \ }})
  79. if has('lua')
  80. NeoBundle 'Shougo/neocomplete.vim', '', 'default'
  81. call neobundle#config('neocomplete.vim', {
  82. \ 'lazy' : 1,
  83. \ 'autoload' : {
  84. \ 'commands' : 'NeoComplateEnable'
  85. \ }})
  86. else
  87. NeoBundle 'Shougo/neocomplcache', '', 'default'
  88. call neobundle#config('neocomplcache', {
  89. \ 'lazy' : 1,
  90. \ 'autoload' : {
  91. \ 'commands' : 'NeoComplCacheEnable',
  92. \ }})
  93. endif
  94. "NeoBundle 'Shougo/neocomplcache-rsense', '', 'default'
  95. "call neobundle#config('neocomplcache-rsense', {
  96. " \ 'lazy' : 1,
  97. " \ 'depends' : 'Shougo/neocomplcache',
  98. " \ 'autoload' : { 'filetypes' : 'ruby' }
  99. " \ })
  100. NeoBundle 'Shougo/neobundle.vim'
  101. NeoBundle 'Shougo/unite.vim', '', 'default'
  102. call neobundle#config('unite.vim',{
  103. \ 'lazy' : 1,
  104. \ 'autoload' : {
  105. \ 'commands' : [{ 'name' : 'Unite',
  106. \ 'complete' : 'customlist,unite#complete_source'},
  107. \ 'UniteWithCursorWord', 'UniteWithInput']
  108. \ }})
  109. NeoBundle 'Shougo/vimfiler', '', 'default'
  110. call neobundle#config('vimfiler', {
  111. \ 'lazy' : 1,
  112. \ 'depends' : 'Shougo/unite.vim',
  113. \ 'autoload' : {
  114. \ 'commands' : [
  115. \ { 'name' : 'VimFiler',
  116. \ 'complete' : 'customlist,vimfiler#complete' },
  117. \ { 'name' : 'VimFilerExplorer',
  118. \ 'complete' : 'customlist,vimfiler#complete' },
  119. \ { 'name' : 'Edit',
  120. \ 'complete' : 'customlist,vimfiler#complete' },
  121. \ { 'name' : 'Write',
  122. \ 'complete' : 'customlist,vimfiler#complete' },
  123. \ 'Read', 'Source'],
  124. \ 'mappings' : ['<Plug>(vimfiler_switch)'],
  125. \ 'explorer' : 1,
  126. \ }
  127. \ })
  128. NeoBundle 'Shougo/vimshell', '', 'default'
  129. call neobundle#config('vimshell', {
  130. \ 'lazy' : 1,
  131. \ 'autoload' : {
  132. \ 'commands' : [{ 'name' : 'VimShell',
  133. \ 'complete' : 'customlist,vimshell#complete'},
  134. \ 'VimShellExecute', 'VimShellInteractive',
  135. \ 'VimShellTerminal', 'VimShellPop'],
  136. \ 'mappings' : ['<Plug>(vimshell_switch)']
  137. \ }})
  138. if has('win32')
  139. NeoBundleLocal 'C:\vim\plugin'
  140. else
  141. NeoBundle 'Shougo/vimproc', '', 'default'
  142. call neobundle#config('vimproc', {
  143. \ 'build' : {
  144. \ 'windows' : 'make -f make_mingw32.mak',
  145. \ 'cygwin' : 'make -f make_cygwin.mak',
  146. \ 'mac' : 'make -f make_mac.mak',
  147. \ 'unix' : 'make -f make_unix.mak',
  148. \ },
  149. \ })
  150. endif
  151. NeoBundle 'thinca/vim-quickrun'
  152. call neobundle#config('vim-quickrun', {
  153. \ 'lazy' : 1,
  154. \ 'autoload' : {
  155. \ 'mappings' : [
  156. \ ['nxo', '<Plug>(quickrun)']],
  157. \ 'commands' : 'QuickRun',
  158. \ },
  159. \ })
  160. NeoBundle 'tsukkee/lingr-vim'
  161. call neobundle#config('lingr-vim', {
  162. \ 'lazy' : 1,
  163. \ 'autoload' : {
  164. \ 'commands' : 'LingrLaunch',
  165. \ },
  166. \ })
  167. NeoBundle 'Shougo/neosnippet', '', 'default'
  168. call neobundle#config('neosnippet', {
  169. \ 'lazy' : 1,
  170. \ 'autoload' : {
  171. \ 'insert' : 1,
  172. \ 'filetypes' : 'snippet',
  173. \ 'unite_sources' : ['snippet', 'neosnippet/user', 'neosnippet/runtime'],
  174. \ }})
  175. NeoBundle 'browser.vim'
  176. NeoBundle 'synmark.vim'
  177. NeoBundleLazy 'tyru/open-browser.vim', { 'autoload' : {
  178. \ 'mappings' : '<Plug>(open-browser-wwwsearch)',
  179. \ }}
  180. NeoBundle 'mattn/gist-vim'
  181. NeoBundle 'mattn/webapi-vim'
  182. NeoBundle 'mru.vim'
  183. NeoBundle 'thinca/vim-ft-clojure'
  184. NeoBundleLazy 'ujihisa/neco-ghc', { 'autoload' : {
  185. \ 'filetypes' : 'haskell',
  186. \ }}
  187. NeoBundle 'sudo.vim'
  188. NeoBundleLazy 'ujihisa/vimshell-ssh', { 'autoload' : {
  189. \ 'filetypes' : 'vimshell',
  190. \ }}
  191. NeoBundle 'Shougo/unite-ssh'
  192. NeoBundle 'ujihisa/neco-look'
  193. NeoBundle 'vim-jp/vital.vim', '', 'default'
  194. "call neobundle#config('vital.vim', {
  195. " \ 'lazy' : 1,
  196. " \ 'autoload' : {
  197. " \ 'commands' : ['Vitalize'],
  198. " \ }})
  199. NeoBundleLazy 'dag/vim2hs', { 'autoload' : {
  200. \ 'filetypes' : 'haskell',
  201. \ }}
  202. NeoBundleLazy 'eagletmt/ghcmod-vim', { 'autoload' : {
  203. \ 'filetypes' : 'haskell',
  204. \ }}
  205. NeoBundle 'thinca/vim-ref'
  206. NeoBundle 'thinca/vim-singleton'
  207. NeoBundle 'mattn/benchvimrc-vim'
  208. NeoBundle 'ryutorion/vim-itunes'
  209. NeoBundle 'raa0121/vim-ulilith'
  210. NeoBundle 'mattn/libcallex-vim'
  211. NeoBundle 'thinca/vim-splash'
  212. NeoBundle 'mattn/sonictemplate-vim'
  213. NeoBundle 'raa0121/vim-eclim'
  214. NeoBundle 'thinca/vim-github'
  215. NeoBundle 'nosami/Omnisharp'
  216. NeoBundle 'jceb/vim-orgmode'
  217. "NeoBundle 'Lokaltog/powerline', { 'rtp' : 'powerline/bindings/vim'}
  218. "NeoBundle 'taichouchou2/alpaca_powertabline'
  219. "NeoBundle 'zhaocai/linepower.vim'
  220. NeoBundle 'osyo-manga/quickrun-hook-u-nya-'
  221. NeoBundle 'osyo-manga/unite-quickfix'
  222. NeoBundle 'basyura/J6uil.vim', '', 'default'
  223. call neobundle#config('J6uil.vim', {
  224. \ 'lazy' : 1,
  225. \ 'autoload' : {
  226. \ 'commands' : 'J6uil',
  227. \ },
  228. \ 'depends' : 'mattn/webapi-vim',
  229. \ })
  230. NeoBundle 'mattn/unite-rhythmbox'
  231. NeoBundleLazy 'rbtnn/vimconsole.vim', {
  232. \ 'depends' : 'thinca/vim-prettyprint',
  233. \ 'autoload' : {
  234. \ 'commands' : 'VimConsoleOpen'
  235. \ }}
  236. filetype plugin indent on
  237. if has('clientserver')
  238. call singleton#enable()
  239. end
  240. set ww+=h,l,>,<,[,]
  241. set mouse=a
  242. set ttymouse=xterm2
  243. set clipboard=unnamedplus
  244. " ,is: シェルを起動
  245. nnoremap <silent> ,is :VimShell<CR>
  246. " ,ipy: pythonを非同期で起動
  247. nnoremap <silent> ,ipy :VimShellInteractive python<CR>
  248. " ,irb: irbを非同期で起動
  249. nnoremap <silent> ,irb :VimShellInteractive irb<CR>
  250. " ,ss: 非同期で開いたインタプリタに現在の行を評価させる
  251. vmap <silent> ,ss :VimShellSendString<CR>
  252. " 選択中に,ss: 非同期で開いたインタプリタに選択行を評価させる
  253. nnoremap <silent> ,ss <S-v>:VimShellSendString<CR>
  254. " ,vs: vimshell
  255. nnoremap <silent> ,vs :tabnew +VimShell<CR>
  256. " ,vr: .vimrc
  257. nnoremap <silent> ,vr :tabnew ~/.vimrc<CR>:lcd<CR>
  258. nnoremap <silent> ,so :so ~/.vimrc<CR>
  259. nnoremap <silent> ,nu :tabnew +Unite\ neobundle/update<CR>
  260. nnoremap <silent> ,ll :tabnew +LingrLaunch<CR>
  261. nnoremap <Esc><Esc> :nohlsearch<CR><ESC>
  262. if neobundle#is_installed('neocomplcache')
  263. let g:neocomplcache_enable_at_startup = 1
  264. let g:neocomplcache_enable_smart_case = 1
  265. let g:neocomplcache_enable_camel_case_completion = 1
  266. let g:neocomplcache_enable_underbar_completion = 1
  267. let g:neocomplcache_min_syntax_length = 3
  268. let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
  269. if !exists('g:neocomplcache_keyword_patterns')
  270. let g:neocomplcache_keyword_patterns = {}
  271. endif
  272. let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
  273. endif
  274. if neobundle#is_installed('neocomplete.vim')
  275. let g:neocomplete#enable_at_startup = 1
  276. let g:neocomplete#enable_smart_case = 1
  277. let g:neocomplete#enable_camel_case_completion = 1
  278. let g:neocomplete#enable_underbar_completion = 1
  279. let g:neocomplete#min_syntax_length = 3
  280. let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
  281. if !exists('g:neocomplete#keyword_patterns')
  282. let g:neocomplete#keyword_patterns = {}
  283. endif
  284. let g:neocomplete#keyword_patterns['default'] = '\h\w*'
  285. endif
  286. let g:vimfiler_as_default_explorer = 1
  287. "let g:neocomplcache#sources#rsense#home_directory = '/opt/rsense-0.3/'
  288. let g:neocomplcache_text_mode_filetypes = {
  289. \ 'tex': 1,
  290. \ 'plaintex': 1,
  291. \}
  292. "tabで補完候補の選択を行う
  293. inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<TAB>"
  294. inoremap <expr><S-TAB> pumvisible() ? "\<Up>" : "\<S-TAB>"
  295. let g:OmniSharp_host = 'http://localhost:2020'
  296. let g:OmniSharp_typeLookupInPreview = 1
  297. set noshowmatch
  298. autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
  299. autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
  300. autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
  301. autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
  302. autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
  303. autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
  304. let g:netrw_nogx = 1
  305. nmap gx <Plug>(openbrowser-smart-search)
  306. vmap gx <Plug>(openbrowser-smart-search)
  307. let g:quickrun_config = {}
  308. let g:quickrun_config['markdown'] = {
  309. \ 'outputter': 'browser'
  310. \ }
  311. let g:quickrun_config.ruby = {
  312. \ 'command': 'ruby',
  313. \ 'exec': '/usr/bin/env ruby %s',
  314. \ 'tempfile': '{tempname()}.rb'
  315. \ }
  316. let g:quickrun_config = {
  317. \ 'cpp': {
  318. \ 'cmdopt': '-std=c++11 -Wall'
  319. \ }
  320. \ }
  321. let g:quickrun_config = {
  322. \ '_' : {
  323. \ 'hook/close_unite_quickfix/enable_hook_loaded' : 1,
  324. \ 'hook/unite_quickfix/enable_failure' : 1,
  325. \ 'hook/close_quickfix/enable_exit' : 1,
  326. \ 'hook/close_buffer/enable_failure' : 1,
  327. \ 'hook/close_buffer/enable_empty_data' : 1,
  328. \ 'outputter' : 'multi:buffer:quickfix',
  329. \ 'hook/u_nya_/enable' : 1,
  330. \ 'hook/sweep/enable' : 0,
  331. \ 'outputter/buffer/split' : ':botright 15sp',
  332. \ 'outputter/buffer/running_mark' : 'バン(∩`・ω・)バンバンバンバン゙ン',
  333. \ 'runner' : 'vimproc',
  334. \ 'runner/vimproc/updatetime' : 40,
  335. \ 'runner/vimproc/sleep' : 0,
  336. \ }
  337. \ }
  338. let g:lingr_vim_user = 'raa0121'
  339. let g:J6uil_display_offline = 0
  340. let g:J6uil_display_online = 0
  341. let g:J6uil_echo_presence = 1
  342. let g:J6uil_display_icon = 0
  343. let g:J6uil_display_interval = 0
  344. let g:J6uil_updatetime = 1000
  345. augroup plugin-lingr-vim
  346. autocmd!
  347. autocmd FileType lingr-messages nmap <silent> <buffer> t <Plug>(lingr-messages-show-say-buffer)
  348. autocmd FileType lingr-say let &syntax='clojure'
  349. augroup END
  350. augroup vimrc
  351. autocmd!
  352. augroup END
  353. function! s:SID_PREFIX()
  354. return matchstr(expand('<sfile>'), '<SNR>\d\+_')
  355. endfunction
  356. set titlelen=100
  357. set guioptions-=e
  358. autocmd vimrc BufEnter * let &titlestring = '%{' . s:SID_PREFIX() . 'titlestring()}'
  359. autocmd vimrc User plugin-lingr-unread let &titlestring = '%{' . s:SID_PREFIX() . 'titlestring()}'
  360. if exists('$TMUX') || exists('$WINDOW')
  361. set t_ts=k
  362. set t_fs=\
  363. endif
  364. function! s:titlestring()
  365. if &filetype =~ '^lingr'
  366. let &titlestring = 'lingr: ' . lingr#unread_count()
  367. else
  368. let &titlestring = bufname('')
  369. endif
  370. endfunction
  371. " tabline
  372. set showtabline=2 " always show tabline
  373. let &tabline = '%!' . s:SID_PREFIX() . 'tabline()'
  374. function! s:tabline()
  375. " show each tab
  376. let s = ''
  377. for i in range(1, tabpagenr('$'))
  378. let list = tabpagebuflist(i)
  379. let nr = tabpagewinnr(i)
  380. let current_tabnr = tabpagenr()
  381. "let title = bufname('')
  382. if i == current_tabnr
  383. let title = fnamemodify(getcwd(), ':t') . '/'
  384. "let title = bufname('')
  385. else
  386. let title = fnamemodify(gettabvar(i, 'cwd'), ':t') . '/'
  387. endif
  388. let title = empty(title) ? '[No Name]' : title
  389. let s .= i == current_tabnr ? '%#TabLineSel#' : '%#TabLine#'
  390. let s .= '%' . i . 'T[' . i . '] ' . title
  391. let s .= ' '
  392. endfor
  393. " show lingr unread count
  394. let lingr_unread = ""
  395. if exists('*lingr#unread_count')
  396. let lingr_unread_count = lingr#unread_count()
  397. if lingr_unread_count > 0
  398. let lingr_unread = "%#ErrorMsg#(" . lingr_unread_count . ")"
  399. elseif lingr_unread_count == 0
  400. let lingr_unread = "()"
  401. endif
  402. endif
  403. " build tabline
  404. let s .= '%#TabLineFill#%T%=%<[' . getcwd() . ']' . lingr_unread
  405. return s
  406. endfunction
  407. augroup vimrc-scratch-buffer
  408. autocmd!
  409. " Make a scratch buffer when unnamed buffer.
  410. autocmd BufEnter * call s:scratch_buffer()
  411. autocmd FileType qfreplace autocmd! vimrc-scratch * <buffer>
  412. function! s:scratch_buffer()
  413. if exists('b:scratch_buffer') || bufname('%') !=# '' || &l:buftype !=# ''
  414. return
  415. endif
  416. let b:scratch_buffer = 1
  417. call openbuf#add('scratch', bufnr('%'))
  418. setlocal buftype=nofile nobuflisted noswapfile bufhidden=hide
  419. augroup vimrc-scratch
  420. autocmd! * <buffer>
  421. autocmd BufWriteCmd <buffer> call s:scratch_on_BufWriteCmd()
  422. augroup END
  423. endfunction
  424. function! s:scratch_on_BufWriteCmd()
  425. silent! setl buftype< buflisted< swapfile< bufhidden< nomodified
  426. autocmd! vimrc-scratch * <buffer>
  427. if bufname('%') ==# '' && exists('b:scratch_buffer')
  428. execute 'saveas' . (v:cmdbang ? '!' : '') ' <afile>'
  429. filetype detect
  430. endif
  431. call openbuf#remove('scratch', bufnr('%'))
  432. unlet! b:scratch_buffer
  433. endfunction
  434. augroup END
  435. command! -nargs=? ExtractMatches let s:pat = empty(<q-args>) ? @/ : <q-args> | let s:result = filter(getline(1, '$'), 'v:val =~# s:pat') | new | put =s:result
  436. command! -nargs=? UniGrep let s:pat = empty(<q-args>) ? @/ : <q-args> | execute 'Unite grep:%::' . escape(s:pat, '\')
  437. let g:github_user = 'raa0121'
  438. let g:github_token = 'e3ded9cf6669cc31dbca'
  439. let g:github#user = 'raa0121'