.vimrc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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. set nrformats+=alpha
  27. colorscheme elflord
  28. syntax on
  29. set enc=utf8
  30. set updatetime=200
  31. " ファイル名に大文字小文字の区別がないシステム用の設定:
  32. " (例: DOS/Windows/MacOS)
  33. "
  34. if filereadable($VIM . '/vimrc') && filereadable($VIM . '/ViMrC')
  35. " tagsファイルの重複防止
  36. set tags=./tags,tags
  37. endif
  38. " コンソールでのカラー表示のための設定(暫定的にUNIX専用)
  39. if has('unix') && !has('gui_running')
  40. let uname = system('uname')
  41. if uname =~? "linux"
  42. set term=builtin_linux
  43. elseif uname =~? "freebsd"
  44. set term=builtin_cons25
  45. elseif uname =~? "Darwin"
  46. set term=beos-ansi
  47. else
  48. set term=builtin_xterm
  49. endif
  50. unlet uname
  51. endif
  52. " コンソール版で環境変数$DISPLAYが設定されていると起動が遅くなる件へ対応
  53. if !has('gui_running') && has('xterm_clipboard')
  54. set clipboard=exclude:cons\\\|linux\\\|cygwin\\\|rxvt\\\|screen
  55. endif
  56. " タブページの切り替えをWindowsのように
  57. " CTRL+Tab SHIFT+Tabで行うように.
  58. if v:version >= 700
  59. nnoremap <C-Tab> gt
  60. nnoremap <C-S-Tab> gT
  61. endif
  62. if has('+regexpengine')
  63. set re=0
  64. endif
  65. set nocompatible
  66. filetype off
  67. if has('vim_starting')
  68. set runtimepath+=~/.vim/neobundle.vim.git
  69. endif
  70. call neobundle#rc(expand('~/.bundle'))
  71. let g:neobundle_default_git_protocol='https'
  72. NeoBundleFetch 'Shougo/neobundle.vim'
  73. NeoBundle 'thinca/vim-threes'
  74. NeoBundle 'vim-jp/vimdoc-ja'
  75. NeoBundle 'itchyny/calendar.vim'
  76. NeoBundle 'fuenor/qfixhowm', '', 'default'
  77. call neobundle#config('qfixhowm', {
  78. \ 'rev': '5bad8770a6d2ffd2e93182d937710ad6e3fe769f'
  79. \ })
  80. NeoBundle 'osyo-manga/unite-qfixhowm'
  81. call neobundle#config('unite-qfixhowm', {
  82. \ 'lazy' : 1,
  83. \ 'autoload' : { 'unite_sources' : ['qfixhowm', 'qfixhowm/new']},
  84. \ 'depends' : ['Shougo/unite.vim', 'fuenor/qfixhowm']
  85. \ })
  86. NeoBundle 'thinca/vim-prettyprint'
  87. call neobundle#config('vim-prettyprint', {
  88. \ 'lazy' : 1,
  89. \ 'autoload' : { 'commands' : ['PP', 'PrettyPrint']}
  90. \ })
  91. NeoBundle 'thinca/vim-openbuf'
  92. NeoBundle 'jnwhiteh/vim-golang'
  93. call neobundle#config('vim-golang', {
  94. \ 'lazy' : 1,
  95. \ 'autoload' : { 'filetypes' : 'go'}
  96. \ })
  97. NeoBundle 'osyo-manga/vim-snowdrop'
  98. call neobundle#config('vim-snowdrop', {
  99. \ 'lazy' : 1,
  100. \ 'autoload' : { 'filetypes' : 'cpp' }
  101. \ })
  102. NeoBundle 'osyo-manga/vim-reunions'
  103. NeoBundle 'osyo-manga/vim-marching'
  104. call neobundle#config('vim-marching', {
  105. \ 'depends' : ['Shougo/vimproc', 'osyo-manga/vim-reunions']
  106. \ })
  107. NeoBundle 'Shougo/echodoc', '', 'default'
  108. call neobundle#config('echodoc', {
  109. \ 'lazy' : 1,
  110. \ 'autoload' : {
  111. \ 'insert' : 1,
  112. \ }})
  113. if has('lua')
  114. NeoBundle 'Shougo/neocomplete.vim', '', 'default'
  115. else
  116. NeoBundle 'Shougo/neocomplcache', '', 'default'
  117. endif
  118. "NeoBundle 'Shougo/neocomplcache-rsense', '', 'default'
  119. "call neobundle#config('neocomplcache-rsense', {
  120. " \ 'lazy' : 1,
  121. " \ 'depends' : 'Shougo/neocomplcache',
  122. " \ 'autoload' : { 'filetypes' : 'ruby' }
  123. " \ })
  124. NeoBundle 'Shougo/unite.vim', '', 'default'
  125. call neobundle#config('unite.vim',{
  126. \ 'lazy' : 1,
  127. \ 'autoload' : {
  128. \ 'commands' : [{ 'name' : 'Unite',
  129. \ 'complete' : 'customlist,unite#complete_source'},
  130. \ 'UniteWithCursorWord', 'UniteWithInput']
  131. \ }})
  132. NeoBundle 'Shougo/vimfiler', '', 'default'
  133. call neobundle#config('vimfiler', {
  134. \ 'lazy' : 1,
  135. \ 'depends' : 'Shougo/unite.vim',
  136. \ 'autoload' : {
  137. \ 'commands' : [
  138. \ { 'name' : 'VimFiler',
  139. \ 'complete' : 'customlist,vimfiler#complete' },
  140. \ { 'name' : 'VimFilerExplorer',
  141. \ 'complete' : 'customlist,vimfiler#complete' },
  142. \ { 'name' : 'Edit',
  143. \ 'complete' : 'customlist,vimfiler#complete' },
  144. \ { 'name' : 'Write',
  145. \ 'complete' : 'customlist,vimfiler#complete' },
  146. \ 'Read', 'Source'],
  147. \ 'mappings' : ['<Plug>(vimfiler_switch)'],
  148. \ 'explorer' : 1,
  149. \ }
  150. \ })
  151. NeoBundle 'Shougo/vimshell', '', 'default'
  152. call neobundle#config('vimshell', {
  153. \ 'lazy' : 1,
  154. \ 'autoload' : {
  155. \ 'commands' : [{ 'name' : 'VimShell',
  156. \ 'complete' : 'customlist,vimshell#complete'},
  157. \ 'VimShellExecute', 'VimShellInteractive',
  158. \ 'VimShellTerminal', 'VimShellPop'],
  159. \ 'mappings' : ['<Plug>(vimshell_switch)']
  160. \ }})
  161. if has('win32')
  162. NeoBundleLocal 'C:\vim\plugin'
  163. else
  164. NeoBundle 'Shougo/vimproc', '', 'default'
  165. call neobundle#config('vimproc', {
  166. \ 'build' : {
  167. \ 'windows' : 'make -f make_mingw32.mak',
  168. \ 'cygwin' : 'make -f make_cygwin.mak',
  169. \ 'mac' : 'make -f make_mac.mak',
  170. \ 'unix' : 'make -f make_unix.mak',
  171. \ },
  172. \ })
  173. endif
  174. NeoBundle 'thinca/vim-quickrun'
  175. call neobundle#config('vim-quickrun', {
  176. \ 'lazy' : 1,
  177. \ 'autoload' : {
  178. \ 'mappings' : [
  179. \ ['nxo', '<Plug>(quickrun)']],
  180. \ 'commands' : 'QuickRun',
  181. \ },
  182. \ })
  183. NeoBundle 'tsukkee/lingr-vim'
  184. call neobundle#config('lingr-vim', {
  185. \ 'lazy' : 1,
  186. \ 'autoload' : {
  187. \ 'commands' : 'LingrLaunch',
  188. \ },
  189. \ })
  190. NeoBundle 'Shougo/neosnippet', '', 'default'
  191. call neobundle#config('neosnippet', {
  192. \ 'lazy' : 1,
  193. \ 'autoload' : {
  194. \ 'insert' : 1,
  195. \ 'filetypes' : 'snippet',
  196. \ 'unite_sources' : ['snippet', 'neosnippet/user', 'neosnippet/runtime'],
  197. \ }})
  198. NeoBundle 'Shougo/neosnippet-snippets', '', 'default'
  199. call neobundle#config('neosnippet-snippets', {
  200. \ 'depends' : 'Shougo/neosnippet'
  201. \ })
  202. NeoBundle 'tyru/open-browser.vim'
  203. call neobundle#config('open-browser.vim',{
  204. \ 'lazy' : 1,
  205. \ 'autoload' : {
  206. \ 'mappings' : '<Plug>(open-browser-wwwsearch)',
  207. \ }})
  208. NeoBundle 'mattn/gist-vim'
  209. call neobundle#config('gist-vim', {
  210. \ 'lazy' : 1,
  211. \ 'autoload' : { 'commands' : 'Gist' }
  212. \ })
  213. NeoBundle 'mattn/webapi-vim'
  214. NeoBundle 'thinca/vim-ft-clojure'
  215. call neobundle#config('vim-ft-clojure', {
  216. \ 'lazy' : 1,
  217. \ 'autoload' : { 'filetypes' : 'clojure' }
  218. \ })
  219. NeoBundle 'ujihisa/neco-ghc'
  220. call neobundle#config('neco-ghc', {
  221. \ 'lazy' : 1,
  222. \ 'autoload' : { 'filetypes' : 'haskell' }
  223. \ })
  224. NeoBundle 'sudo.vim'
  225. NeoBundle 'ujihisa/vimshell-ssh'
  226. call neobundle#config('vimshell-ssh',{
  227. \ 'lazy' : 1,
  228. \ 'autoload' : { 'filetypes' : 'vimshell'}
  229. \ })
  230. NeoBundle 'Shougo/unite-ssh'
  231. call neobundle#config('unite-ssh', {
  232. \ 'lazy' : 1,
  233. \ 'autoload' : { 'unite_sources' : 'ssh' }
  234. \ })
  235. NeoBundle 'ujihisa/neco-look'
  236. NeoBundle 'vim-jp/vital.vim', '', 'default'
  237. call neobundle#config('vital.vim', {
  238. \ 'lazy' : 1,
  239. \ 'autoload' : {
  240. \ 'commands' : ['Vitalize'],
  241. \ 'functions' : ['vital#of', 'vital']
  242. \ }})
  243. NeoBundle 'dag/vim2hs'
  244. call neobundle#config ('vim2hs', {
  245. \ 'lazy' : 1,
  246. \ 'autoload' : { 'filetypes' : 'haskell' }
  247. \})
  248. NeoBundle 'eagletmt/ghcmod-vim'
  249. call neobundle#config('ghcmod-vim', {
  250. \ 'lazy' : 1,
  251. \ 'autoload' : { 'filetypes' : 'haskell' }
  252. \ })
  253. NeoBundle 'thinca/vim-ref'
  254. NeoBundle 'thinca/vim-singleton'
  255. NeoBundle 'mattn/benchvimrc-vim'
  256. call neobundle#config('benchvimrc-vim', {
  257. \ 'lazy' : 1,
  258. \ 'autoload' : { 'commands' : 'BenchVimrc' }
  259. \ })
  260. NeoBundle 'ryutorion/vim-itunes'
  261. NeoBundle 'raa0121/vim-ulilith'
  262. NeoBundle 'mattn/libcallex-vim'
  263. NeoBundle 'thinca/vim-splash'
  264. NeoBundle 'mattn/sonictemplate-vim'
  265. NeoBundle 'thinca/vim-github'
  266. call neobundle#config('vim-github', {
  267. \ 'lazy' : 1,
  268. \ 'autoload' : { 'commands' : 'Github' }
  269. \ })
  270. NeoBundle 'nosami/Omnisharp'
  271. call neobundle#config('Omnisharp', {
  272. \ 'lazy' : 1,
  273. \ 'autoload' : { 'filetypes' : 'cs' }
  274. \ })
  275. NeoBundle 'jceb/vim-orgmode'
  276. call neobundle#config('vim-orgmode', {
  277. \ 'lazy' : 1,
  278. \ 'autoload' : { 'filetypes' : 'org' }
  279. \ })
  280. "NeoBundle 'Lokaltog/powerline', { 'rtp' : 'powerline/bindings/vim'}
  281. "NeoBundle 'taichouchou2/alpaca_powertabline'
  282. "NeoBundle 'zhaocai/linepower.vim'
  283. NeoBundle 'itchyny/lightline.vim'
  284. NeoBundle 'osyo-manga/quickrun-hook-u-nya-'
  285. " call neobundle#config('quickrun-hook-u-nya-', {
  286. " \ 'lazy' : 1,
  287. " \ 'depends' : 'thinca/quickrun'
  288. " \ })
  289. NeoBundle 'osyo-manga/unite-quickfix'
  290. call neobundle#config('unite-quickfix', {
  291. \ 'lazy' : 1,
  292. \ 'autoload' : { 'unite_sources' : ['quickfix', 'location_list']},
  293. \ 'depends' : 'Shougo/unite.vim'
  294. \ })
  295. NeoBundle 'basyura/J6uil.vim', '', 'default'
  296. call neobundle#config('J6uil.vim', {
  297. \ 'lazy' : 1,
  298. \ 'autoload' : { 'commands' : 'J6uil' },
  299. \ 'depends' : 'mattn/webapi-vim',
  300. \ })
  301. NeoBundle 'mattn/unite-rhythmbox'
  302. call neobundle#config('unite-rhythmbox', {
  303. \ 'lazy' : 1,
  304. \ 'autoload' : { 'unite_sources' : 'rhythmbox' },
  305. \ 'depends' : 'Shougo/unite.vim'
  306. \ })
  307. NeoBundle 'rbtnn/vimconsole.vim'
  308. call neobundle#config('vimconsole.vim', {
  309. \ 'depends' : 'thinca/vim-prettyprint',
  310. \ 'autoload' : { 'commands' : 'VimConsoleOpen' }
  311. \ })
  312. filetype plugin indent on
  313. if has('clientserver')
  314. call singleton#enable()
  315. end
  316. set ww+=h,l,>,<,[,]
  317. set mouse=a
  318. set ttymouse=xterm2
  319. set clipboard=unnamedplus
  320. " ,is: シェルを起動
  321. nnoremap <silent> ,is :VimShell<CR>
  322. " ,ipy: pythonを非同期で起動
  323. nnoremap <silent> ,ipy :VimShellInteractive python<CR>
  324. " ,irb: irbを非同期で起動
  325. nnoremap <silent> ,irb :VimShellInteractive irb<CR>
  326. " ,ss: 非同期で開いたインタプリタに現在の行を評価させる
  327. vmap <silent> ,ss :VimShellSendString<CR>
  328. " 選択中に,ss: 非同期で開いたインタプリタに選択行を評価させる
  329. nnoremap <silent> ,ss <S-v>:VimShellSendString<CR>
  330. " ,vs: vimshell
  331. nnoremap <silent> ,vs :tabnew +VimShell<CR>
  332. " ,vr: .vimrc
  333. nnoremap <silent> ,vr :tabnew ~/.vimrc<CR>:lcd<CR>
  334. nnoremap <silent> ,so :so ~/.vimrc<CR>
  335. nnoremap <silent> ,nu :tabnew +Unite\ neobundle/update<CR>
  336. nnoremap <silent> ,ll :tabnew +LingrLaunch<CR>
  337. nnoremap <Esc><Esc> :nohlsearch<CR><ESC>
  338. if neobundle#is_installed('neocomplcache')
  339. let g:neocomplcache_enable_at_startup = 1
  340. let g:neocomplcache_enable_smart_case = 1
  341. let g:neocomplcache_enable_camel_case_completion = 1
  342. let g:neocomplcache_enable_underbar_completion = 1
  343. let g:neocomplcache_min_syntax_length = 3
  344. let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
  345. if !exists('g:neocomplcache_keyword_patterns')
  346. let g:neocomplcache_keyword_patterns = {}
  347. endif
  348. let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
  349. endif
  350. if neobundle#is_installed('neocomplete.vim')
  351. let g:neocomplete#enable_at_startup = 1
  352. let g:neocomplete#enable_smart_case = 1
  353. let g:neocomplete#enable_camel_case_completion = 1
  354. let g:neocomplete#enable_underbar_completion = 1
  355. let g:neocomplete#min_syntax_length = 3
  356. let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
  357. if !exists('g:neocomplete#keyword_patterns')
  358. let g:neocomplete#keyword_patterns = {}
  359. endif
  360. let g:neocomplete#keyword_patterns['default'] = '\h\w*'
  361. if !exists('g:neocomplete#force_omni_input_patterns')
  362. let g:neocomplete#force_omni_input_patterns = {}
  363. endif
  364. endif
  365. let g:vimfiler_as_default_explorer = 1
  366. "let g:neocomplcache#sources#rsense#home_directory = '/opt/rsense-0.3/'
  367. let g:neocomplcache_text_mode_filetypes = {
  368. \ 'tex': 1,
  369. \ 'plaintex': 1,
  370. \}
  371. let g:neocomplete#text_mode_filetypes = {
  372. \ 'tex': 1,
  373. \ 'plaintex': 1,
  374. \}
  375. let g:neocomplete#force_omni_input_patterns.cpp =
  376. \ '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*'
  377. let g:neosnippet#snippets_directory = '~/.vim/snippet'
  378. "tabで補完候補の選択を行う
  379. imap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "\<C-n>" : "\<TAB>"
  380. imap <expr><S-TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "\<C-u>" : "\<S-TAB>"
  381. smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
  382. \ "\<Plug>(neosnippet_expand_or_jump)"
  383. \: "\<TAB>"
  384. augroup vimrc
  385. autocmd!
  386. augroup END
  387. autocmd vimrc FileType css setlocal omnifunc=csscomplete#CompleteCSS
  388. autocmd vimrc FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
  389. autocmd vimrc FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
  390. autocmd vimrc FileType python setlocal omnifunc=pythoncomplete#Complete
  391. autocmd vimrc FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
  392. autocmd vimrc BufNewFile,BufRead *.{md,mdwn,mkd,mkdn,mark*} setlocal filetype=markdown
  393. let g:netrw_nogx = 1
  394. nmap gx <Plug>(openbrowser-smart-search)
  395. vmap gx <Plug>(openbrowser-smart-search)
  396. let g:quickrun_config = {}
  397. let g:quickrun_config['markdown'] = {
  398. \ 'outputter': 'browser'
  399. \ }
  400. let g:quickrun_config.ruby = {
  401. \ 'command': 'ruby',
  402. \ 'exec': '/usr/bin/env ruby %s',
  403. \ 'tempfile': '{tempname()}.rb'
  404. \ }
  405. let g:quickrun_config = {
  406. \ 'cpp': {
  407. \ 'cmdopt': '-std=c++11 -Wall'
  408. \ }
  409. \ }
  410. let g:quickrun_config = {
  411. \ '_' : {
  412. \ 'hook/close_unite_quickfix/enable_hook_loaded' : 1,
  413. \ 'hook/unite_quickfix/enable_failure' : 1,
  414. \ 'hook/close_quickfix/enable_exit' : 1,
  415. \ 'hook/close_buffer/enable_failure' : 1,
  416. \ 'hook/close_buffer/enable_empty_data' : 1,
  417. \ 'outputter' : 'multi:buffer:quickfix',
  418. \ 'hook/u_nya_/enable' : 1,
  419. \ 'hook/sweep/enable' : 0,
  420. \ 'outputter/buffer/split' : ':botright 15sp',
  421. \ 'outputter/buffer/running_mark' : 'バン(∩`・ω・)バンバンバンバン゙ン',
  422. \ 'runner' : 'vimproc',
  423. \ 'runner/vimproc/updatetime' : 40,
  424. \ 'runner/vimproc/sleep' : 0,
  425. \ }
  426. \ }
  427. let g:lingr_vim_user = 'raa0121'
  428. let g:J6uil_display_offline = 0
  429. let g:J6uil_display_online = 0
  430. let g:J6uil_echo_presence = 1
  431. let g:J6uil_display_icon = 0
  432. let g:J6uil_display_interval = 0
  433. let g:J6uil_updatetime = 1000
  434. let QFixHowm_Key = 'g'
  435. let howm_dir = '~/howm'
  436. let howm_filename = '%Y/%m/%Y-%m-%d-%H%M%S.txt'
  437. let howm_fileencoding = 'utf-8'
  438. let howm_fileformat = 'unix'
  439. let g:qfixmemo_calendar = 0
  440. let g:calendar_howm_syntax = 0
  441. let mygrepprg = 'grep'
  442. if has('win32unix')
  443. let MyGrep_cygwin17 = 1
  444. endif
  445. let g:calendar_google_calendar = 1
  446. let g:calendar_google_task = 1
  447. let g:marching_clang_command = '/usr/bin/clang'
  448. let g:marching_clang_command_option="-std=c++1y"
  449. let g:marching_enable_neocomplete = 1
  450. let g:marching_include_paths = ['/usr/include/c++/4.8.2/']
  451. let g:snowdrop#libclang_path='/usr/lib'
  452. augroup plugin-lingr-vim
  453. autocmd!
  454. autocmd FileType lingr-messages nmap <silent> <buffer> t <Plug>(lingr-messages-show-say-buffer)
  455. autocmd FileType lingr-say let &syntax='clojure'
  456. augroup END
  457. function! s:SID_PREFIX()
  458. return matchstr(expand('<sfile>'), '<SNR>\d\+_')
  459. endfunction
  460. set titlelen=100
  461. set guioptions-=e
  462. autocmd vimrc BufEnter * let &titlestring = '%{' . s:SID_PREFIX() . 'titlestring()}'
  463. autocmd vimrc User plugin-lingr-unread let &titlestring = '%{' . s:SID_PREFIX() . 'titlestring()}'
  464. if !has('gui_running')
  465. set t_Co=256
  466. endif
  467. if exists('$TMUX') || exists('$WINDOW')
  468. set t_ts=k
  469. set t_fs=\
  470. endif
  471. function! s:titlestring()
  472. if &filetype =~ '^lingr'
  473. let &titlestring = 'lingr: ' . lingr#unread_count()
  474. else
  475. let &titlestring = bufname('')
  476. endif
  477. endfunction
  478. " tabline
  479. set showtabline=2 " always show tabline
  480. let g:lightline = {
  481. \ 'colorscheme': 'wombat',
  482. \ 'component': {
  483. \ 'readonly': '%{&readonly?"":""}',
  484. \ },
  485. \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
  486. \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
  487. \ }
  488. let &tabline = '%!' . s:SID_PREFIX() . 'tabline()'
  489. function! s:tabline()
  490. " show each tab
  491. let s = ''
  492. for i in range(1, tabpagenr('$'))
  493. let list = tabpagebuflist(i)
  494. let nr = tabpagewinnr(i)
  495. let current_tabnr = tabpagenr()
  496. "let title = bufname('')
  497. if i == current_tabnr
  498. let title = fnamemodify(getcwd(), ':t') . '/'
  499. "let title = bufname('')
  500. else
  501. let title = fnamemodify(gettabvar(i, 'cwd'), ':t') . '/'
  502. endif
  503. let title = empty(title) ? '[No Name]' : title
  504. let s .= i == current_tabnr ? '%#TabLineSel#' : '%#TabLine#'
  505. let s .= '%' . i . 'T[' . i . '] ' . title
  506. let s .= ' '
  507. endfor
  508. " show lingr unread count
  509. let lingr_unread = ""
  510. if exists('*lingr#unread_count')
  511. let lingr_unread_count = lingr#unread_count()
  512. if lingr_unread_count > 0
  513. let lingr_unread = "%#ErrorMsg#(" . lingr_unread_count . ")"
  514. elseif lingr_unread_count == 0
  515. let lingr_unread = "()"
  516. endif
  517. endif
  518. " build tabline
  519. let s .= '%#TabLineFill#%T%=%<[' . getcwd() . ']' . lingr_unread
  520. return s
  521. endfunction
  522. augroup vimrc-scratch-buffer
  523. autocmd!
  524. " Make a scratch buffer when unnamed buffer.
  525. autocmd BufEnter * call s:scratch_buffer()
  526. autocmd FileType qfreplace autocmd! vimrc-scratch * <buffer>
  527. function! s:scratch_buffer()
  528. if exists('b:scratch_buffer') || bufname('%') !=# '' || &l:buftype !=# ''
  529. return
  530. endif
  531. let b:scratch_buffer = 1
  532. call openbuf#add('scratch', bufnr('%'))
  533. setlocal buftype=nofile nobuflisted noswapfile bufhidden=hide
  534. augroup vimrc-scratch
  535. autocmd! * <buffer>
  536. autocmd BufWriteCmd <buffer> call s:scratch_on_BufWriteCmd()
  537. augroup END
  538. endfunction
  539. function! s:scratch_on_BufWriteCmd()
  540. silent! setl buftype< buflisted< swapfile< bufhidden< nomodified
  541. autocmd! vimrc-scratch * <buffer>
  542. if bufname('%') ==# '' && exists('b:scratch_buffer')
  543. execute 'saveas' . (v:cmdbang ? '!' : '') ' <afile>'
  544. filetype detect
  545. endif
  546. call openbuf#remove('scratch', bufnr('%'))
  547. unlet! b:scratch_buffer
  548. endfunction
  549. augroup END
  550. 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
  551. command! -nargs=? UniGrep let s:pat = empty(<q-args>) ? @/ : <q-args> | execute 'Unite grep:%::' . escape(s:pat, '\')
  552. let g:github_user = 'raa0121'
  553. let g:github#user = 'raa0121'