Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

685 lines
20 KiB

11 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
12 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
  1. " this is my .vimrc; part of https://github.com/brennen/bpb-kit
  2. "
  3. " to use:
  4. "
  5. " cp [this file] ~/.vimrc
  6. " mkdir -p ~/.vim/bundle
  7. " git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/Vundle.vim
  8. " vim +PluginInstall
  9. "
  10. " if there are funny-looking folded sections below and you're confused,
  11. " hitting zR will unfold them all, while zr will unfold the one your
  12. " cursor is on. this note is as much for my benefit as yours.
  13. "
  14. " some of this config is very specific to my preferences. there are
  15. " keybindings for filters i use regularly, things that automatically happen
  16. " when i open certain files, and shortcuts bound to the F-keys. you might
  17. " find good examples here, but you may not want the behavior. don't say you
  18. " weren't warned.
  19. "
  20. " items particularly likely to be personal preference are marked with the
  21. " string CUSTOMIZE and a note.
  22. "
  23. " -- bpb | https://p1k3.com/ | https://github.com/brennen
  24. set nocompatible
  25. " vundle setup & vundle-managed plugins {{{
  26. filetype off
  27. set rtp+=~/.vim/bundle/Vundle.vim/
  28. call vundle#rc()
  29. " let Vundle manage Vundle - required:
  30. Plugin 'VundleVim/Vundle.vim'
  31. " really nice file tree - see keybindings section below for some tweaks:
  32. Plugin 'scrooloose/nerdtree'
  33. Plugin 'Xuyuanp/nerdtree-git-plugin'
  34. " fancy start screen with recent files & bookmarks
  35. " CUSTOMIZE: you'll probably want different bookmarks
  36. " Plugin 'mhinz/vim-startify'
  37. " let g:startify_bookmarks = [ {'v': '~/.vimrc'}, '~/.zshrc', '~/notes/', '~/p1k3' ]
  38. " Vim Outliner of Markups - see :help voom - no idea yet if this is any good
  39. Plugin 'VOoM'
  40. " align text vertically on a string:
  41. Plugin 'Align'
  42. " wrap common version control commands:
  43. Plugin 'vcscommand.vim'
  44. Plugin 'tpope/vim-fugitive'
  45. " visual marking of changes in working tree:
  46. " Plugin 'git://github.com/airblade/vim-gitgutter.git'
  47. " match lots of things:
  48. Plugin 'edsono/vim-matchit'
  49. " commands for surrounding chars:
  50. Plugin 'tpope/vim-repeat' " used by vim-surround
  51. Plugin 'tpope/vim-surround'
  52. " readline-style keybindings in command line / insert:
  53. Plugin 'tpope/vim-rsi'
  54. " a yank/paste ring - hit ctrl-p after pasting:
  55. " let g:yankring_history_dir = '$HOME/.vim'
  56. " Plugin 'vim-scripts/YankRing.vim'
  57. " a bunch of colorschemes + a gui menu listing them:
  58. Plugin 'flazz/vim-colorschemes'
  59. Plugin 'altercation/vim-colors-solarized'
  60. Plugin 'chriskempson/vim-tomorrow-theme.git'
  61. Plugin 'desert-warm-256'
  62. Plugin 'ColorSchemeMenuMaker'
  63. " beyondgrep.com:
  64. Plugin 'mileszs/ack.vim'
  65. " navigate & control tmux windows + vim buffers - see also .tmux.conf
  66. " Plugin 'christoomey/vim-tmux-navigator'
  67. " Plugin 'benmills/vimux'
  68. " find files / buffers / etc.:
  69. " Plugin 'L9' " - required by FuzzyFinder
  70. " Plugin 'FuzzyFinder'
  71. Plugin 'Shougo/unite.vim'
  72. " fzf - fuzzy finding
  73. Plugin 'junegunn/fzf'
  74. " ASCII art
  75. Plugin 'DrawIt'
  76. " most recently used files - my fork allows for a top-level menu
  77. let g:MRU_Menu_Path = '&Recent\ Files'
  78. let g:MRU_Max_Menu_Entries = 30
  79. let g:MRU_Max_Submenu_Entries = 30
  80. Plugin 'brennen/mru'
  81. " database stuffs
  82. " Plugin 'dbext.vim'
  83. " do stuff with tables - used by some vim-markdown features
  84. Plugin 'godlygeek/tabular'
  85. " filetypes / modes / language support:
  86. Plugin 'fatih/vim-go' " golang
  87. " Plugin 'brennen/vim-markdown'
  88. " the above a fork of plasticboy's version w/tweaks for variants i use
  89. " you probably want:
  90. Plugin 'plasticboy/vim-markdown'
  91. " graceful syntax checking for many languages:
  92. Plugin 'scrooloose/syntastic'
  93. let g:syntastic_check_on_open = 1
  94. let g:syntastic_php_checkers = ['php']
  95. let g:syntastic_perl_lib_path = [ './lib', './lib/auto' ]
  96. " add option to show a diff when there's a swapfile on disk:
  97. " Plugin 'chrisbra/Recover.vim'
  98. " CUSTOMIZE: fancy status line; laststatus can be set so it always shows up
  99. Plugin 'vim-airline/vim-airline'
  100. Plugin 'vim-airline/vim-airline-themes'
  101. " set laststatus=2
  102. " let g:airline#extensions#tabline#enabled = 1
  103. " let g:airline_theme = 'base16_solarized'
  104. if has("gui_running")
  105. let g:airline_theme = 'base16_ashes'
  106. endif
  107. " nginx config file highlighting
  108. Plugin 'nginx.vim'
  109. " GUI font size - use <Leader><Leader>+ or - to adjust:
  110. Plugin 'drmikehenry/vim-fontsize'
  111. Plugin 'jceb/vim-orgmode'
  112. Plugin 'tpope/vim-speeddating'
  113. " a calendar - used in conjunction with vimwiki diaries
  114. let g:calendar_keys = {
  115. \ 'goto_next_month': '<C-Right>',
  116. \ 'goto_prev_month': '<C-Left>',
  117. \ 'goto_next_year': '<C-Up>',
  118. \ 'goto_prev_year': '<C-Down>'
  119. \ }
  120. Plugin 'mattn/calendar-vim'
  121. " CUSTOMIZE: vimwikis - for notes, daily logs, etc. {{{
  122. " main personal wiki
  123. let wiki = {}
  124. let wiki.path = '~/notes/vimwiki/'
  125. let wiki.path_html = '~/notes/html/'
  126. let wiki.auto_tags = 1
  127. " do syntax highlight in preformatted blocks:
  128. let wiki.nested_syntaxes = {
  129. \ 'python': 'python',
  130. \ 'ruby': 'ruby',
  131. \ 'perl': 'perl',
  132. \ 'sh': 'sh'
  133. \ }
  134. " public p1k3 topics / tags
  135. let wiki_p1k3 = {}
  136. let wiki_p1k3.path = '~/p1k3/topics'
  137. let wiki_p1k3.syntax = 'markdown'
  138. let wiki_p1k3.ext = '.md'
  139. " there can be many of these:
  140. let g:vimwiki_list = [wiki, wiki_p1k3]
  141. " don't make temporary wikis based on file extensions in the list
  142. let g:vimwiki_global_ext = 0
  143. let g:vimwiki_folding = 'expr'
  144. " let g:vimwiki_folding = 'syntax'
  145. " let g:vimwiki_folding = 'list'
  146. " make links clickable and such
  147. let g:vimwiki_use_mouse = 1
  148. " use colors in header highlighting
  149. let g:vimwiki_hl_headers = 1
  150. " map Shift-Backspace to go back - the plugin will check for this mapping
  151. " and not associate it with regular backspace:
  152. " XXX: this does not work
  153. " nmap <S-BS> <Plug>VimwikiGoBackLink
  154. " selectively activate foldcolumn:
  155. " au FileType vimwiki setlocal foldcolumn=3
  156. " au FileType vimwiki :set tw=80
  157. Plugin 'vimwiki/vimwiki'
  158. " regenerate vimwiki diary on file load - this doesn't seem to work,
  159. " maybe because overrides something in vimwiki (?) but seems like it
  160. " probably could:
  161. " au BufReadPost,BufNewFile diary.wiki :VimwikiDiaryGenerateLinks
  162. " }}}
  163. " snippets
  164. " Plugin 'SirVer/ultisnips'
  165. " Plugin 'honza/vim-snippets'
  166. " " trigger configuration
  167. " " don't use <tab> if you use https://github.com/Valloric/YouCompleteMe
  168. " let g:UltiSnipsExpandTrigger="<tab>"
  169. " let g:UltiSnipsJumpForwardTrigger="<c-b>"
  170. " let g:UltiSnipsJumpBackwardTrigger="<c-z>"
  171. " " if you want :UltiSnipsEdit to split your window.
  172. " let g:UltiSnipsEditSplit="vertical"
  173. filetype plugin on
  174. filetype indent on
  175. " }}}
  176. " misc UI {{{
  177. set title
  178. " pretty colors
  179. set t_Co=256
  180. syntax on
  181. " pretty characters
  182. set encoding=utf-8
  183. " do not beep or flash at me
  184. " vb is needed to stop beep
  185. " t_vb sets visual bell action, we're nulling it out here
  186. " note also that this may need to be repeated in .gvimrc
  187. set visualbell
  188. set t_vb=
  189. " enable mouse for (a)ll, (n)ormal, (v)isual, (i)nsert, or (c)ommand line
  190. " mode - seems to work in most terminals
  191. set mouse=a
  192. " render a useful popup menu for right-click instead of extending
  193. " selection (good for spellchecking, etc.):
  194. set mousemodel=popup_setpos
  195. " let me delete stuff like crazy in insert mode
  196. set backspace=indent,eol,start
  197. " see :help virtualedit - you probably don't want this
  198. " set virtualedit=onemore
  199. " display commands as-typed + current position in file
  200. set showcmd
  201. set ruler
  202. " display a visual menu for tab-completion of files:
  203. set wildmenu
  204. " add git status to statusline; otherwise emulate standard line with ruler
  205. " -- mostly supplanted for the moment by vim-airline
  206. set statusline=%<%{fugitive#statusline()}\ %f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
  207. " keep lots of command-line history
  208. set history=10000
  209. " search:
  210. set incsearch
  211. set ignorecase
  212. set smartcase
  213. set wrapscan
  214. " for gvim. no toolbar, otherwise these are the defaults:
  215. set guioptions=aegimrLt
  216. " use + register (x window clipboard) as unnamed register (copy to system
  217. " clipboard on yy, for example):
  218. set clipboard=unnamedplus,autoselect
  219. " include '-' in words. counts for both movement commands and autcomplete.
  220. " to test, try moving across and autocompleting for some-words-bunched-together
  221. " this is an experiment - mainly i want to use inline dashes in identifiers
  222. " in markdown documents, and so forth
  223. set iskeyword+=-
  224. " }}}
  225. " file saving/loading/swap/backups {{{
  226. " read (unchanged) buffers when they're modified on filesystem.
  227. " this saves me a lot of time and agony because i switch git branches
  228. " constantly, but it might not be what you want.
  229. set autoread
  230. " uncomment to disable swapfiles:
  231. " set noswapfile
  232. " }}}
  233. " whitespace {{{
  234. " display tabs and trailing spaces:
  235. set listchars=tab:⇾\ ,trail
  236. set list
  237. " display tab characters as 8 spaces, indent 2 spaces,
  238. " always use spaces instead of tabs:
  239. set tabstop=8
  240. set shiftwidth=2
  241. set softtabstop=2
  242. set expandtab
  243. set autoindent
  244. " set smarttab
  245. " set smartindent
  246. " for c code, no tab expansion, turn off softtabstop
  247. au FileType c setlocal noexpandtab
  248. au FileType c setlocal shiftwidth=8
  249. au FileType c setlocal softtabstop=0
  250. " turn off tab expansion for Makefiles
  251. au FileType make setlocal noexpandtab
  252. " wrap entire words in markdown files
  253. " http://stackoverflow.com/questions/19624105/how-can-i-make-vim-break-lines-only-on-whitespace
  254. au FileType markdown setlocal wrap linebreak breakat&vim
  255. " }}}
  256. " misc. autocommands {{{
  257. " to get a list of current autocommands:
  258. " http://vim.wikia.com/wiki/Capture_ex_command_output
  259. " :redir @a
  260. " :autocmd
  261. " :redir END
  262. " "ap
  263. " assume *.t files are PHP - i was doing this to override the assumption
  264. " that they're perl
  265. " au BufRead,BufNewFile *.t set filetype=php
  266. " retain view/folds on a specific file:
  267. " au BufWinLeave notes.txt mkview
  268. " au BufWinEnter notes.txt silent loadview
  269. au BufReadPost,BufNewFile *.md set filetype=markdown
  270. " CUSTOMIZE: this invokes a function for doing some custom filetype
  271. " overrides, like treating blog entries as markdown. it is mostly
  272. " for places where i couldn't figure out an autocmd, or needed something
  273. " more complex than the pattern matching offered by au
  274. "
  275. " at present, this fails for files named `index`, probably because of
  276. " a fugitive bug: https://github.com/tpope/vim-fugitive/issues/834
  277. au BufReadPost,BufNewFile * call BPB_FiletypeOverrides()
  278. au BufNewFile * call BPB_NewFileOverrides()
  279. " TODO: make a colorscheme logger here - it'd be nice to know all the
  280. " schemes i ever use for later reference:
  281. " au ColorScheme * call BPB_ColorSchemeOverrides()
  282. " }}}
  283. " keybindings {{{
  284. " CUSTOMIZE: my keybinding habits may be idiosyncratic
  285. " aside from function keys, i try not to stomp on the main keybinding
  286. " 'namespace' too much, with the exception of replacing K with something
  287. " useful.
  288. " a handful of functions are called here, all with a prefix of BPB_ -
  289. " they can be found in the "functions" section below
  290. " use comma for the leader key - this is used as a prefix for
  291. " a bunch of bindings further down
  292. let mapleader = ","
  293. " i use the F-keys a _lot_. this is what makes NERDTree usable.
  294. " F2 toggles the nerdtree file browser pane
  295. map <F2> :NERDTreeToggle<CR>
  296. imap <F2> <Esc>:NERDTreeToggle<CR>
  297. " F3 finds the current file in nerdtree
  298. map <F3> :NERDTreeFind<CR>
  299. " F4 toggles line numbers
  300. map <F4> :set invnumber<CR>
  301. imap <F4> <Esc>:set invnumber<CR>
  302. " i just am not that big a fan of relative numbers, so this version of
  303. " the above is unused for the moment:
  304. " map <F4> :call BPB_CycleLineNumbers()<CR>
  305. " imap <F4> <Esc>:call BPB_CycleLineNumbers()<CR>
  306. " F5 saves everything
  307. map <F5> :wall<CR>
  308. imap <F5> <Esc><F5>
  309. " F6 brings up a recently-used file list using MRU
  310. map <F6> :MRU<CR>
  311. imap <F6> <Esc><F6>
  312. " F7 opens ~/.vimrc (in existing tab if open, new otherwise)
  313. " see http://learnvimscriptthehardway.stevelosh.com/chapters/07.html
  314. map <F7> :call BPB_TabDrop($MYVIMRC)<CR>
  315. imap <F7> <Esc><F7>
  316. " F8 inserts a datestamp (eight rhymes with date)
  317. " (used to open the options window; use :options for that)
  318. " map <F8> :r! date -Is<CR> " iso-8601
  319. map <F8> :r! date -Is<CR>kJ
  320. imap <F8> <Esc><F8>
  321. " F9 toggles search highlighting and some other noise
  322. map <F9> :call BPB_Crosshairs()<CR>
  323. imap <F9> <Esc><F9>
  324. map <F10> :Gcommit -av<CR>
  325. " in normal or insert mode, <F12> copies all in buffer
  326. " in visual/select modes, it just yanks the selected bit
  327. nmap <F12> :%y+<CR>
  328. imap <F12> <Esc><F12>
  329. vmap <F12> y+
  330. " split lines under the cursor (modeled on, maybe, emacs?)
  331. map K i<CR><Esc>g;
  332. " get a datestamp for a p1k3 entry
  333. nmap <Leader>tD :call BPB_Datestamp()<CR>
  334. " lowercased date for a p1k3 entry (ridiculous)
  335. nmap <Leader>td :call BPB_Datestamp()<CR>0v$gu
  336. " CUSTOMIZE: randomize certain text decorations - silly
  337. nmap <Leader>D :call BPB_RunFilter("filter-decorate")<CR>
  338. nmap <Leader>d i<p class="centerpiece"> <Esc>:r !fragment-bullet<CR>kJA </p><Esc>
  339. " i didn't wind up using this much, and it potentially messes
  340. " with vimwiki mappings:
  341. " nmap <Leader>w :call BPB_CommandOutputInNewWindow("dict <cword>"))<CR>
  342. " CUSTOMIZE: these are simple filter scripts to preprocess some
  343. " shell commands in HTML or Markdown files - see scripts for details
  344. nmap <Leader>r :call BPB_RunFilter("filter-exec-raw")<CR>:call BPB_RunFilter("filter-exec")<CR>
  345. " pull up the last hundred git commits in a scratch buffer
  346. " nmap <Leader>l :vnew<CR>:set buftype=nofile<CR>:set bufhidden=hide<CR>:setlocal noswapfile<CR>:r !git log -100<CR>:set ft=git<CR>gg<C-w>r<C-w>l
  347. nmap <Leader>l :Glog<CR>:copen<CR>
  348. nmap <leader>m :make<CR>
  349. " jump to next, previous errors
  350. nmap <Leader>n :cnext<CR>
  351. nmap <Leader>p :cprev<CR>
  352. " reformat a paragraph
  353. nmap <Leader>q gqip
  354. " Q mapping (it usually enters ex mode) based on this mail from bram:
  355. " https://groups.google.com/forum/#!search/vim/vim_use/iXH_Zxj8iBA/H7YDtbACBAAJ
  356. map Q gq
  357. " generate a password-like string with apg
  358. nmap <Leader>pw :r !apg -a 0 -m 20 -n 1<CR>
  359. " tab navigation somewhat like firefox
  360. " http://vim.wikia.com/wiki/Alternative_tab_navigation
  361. nmap <C-S-Tab> :tabprevious<CR>
  362. nmap <C-Tab> :tabnext<CR>
  363. map <C-S-Tab> :tabprevious<CR>
  364. map <C-Tab> :tabnext<CR>
  365. imap <C-S-Tab> <Esc>:tabprevious<CR>i
  366. imap <C-Tab> <Esc>:tabnext<CR>i
  367. " new tab:
  368. nmap <Leader>tn :tabnew<CR>
  369. " trigger unite.vim
  370. map <Leader>u :Unite<CR>
  371. " split window navigation (ctrl-j/k, alt-h/l)
  372. map <C-J> <C-W>j<C-W>_
  373. map <C-K> <C-W>k<C-W>_
  374. map <M-Right> <C-W>l
  375. map <M-Left> <C-W>h
  376. " check php syntax - replaced by using Syntastic
  377. " noremap <Leader>c :echom system('php -l ' . bufname('%'))<CR>
  378. " }}}
  379. " functions {{{
  380. " run the file through a custom filter, leaving the cursor at its original
  381. " location in the file (or close) - there might be a better way to do this,
  382. " but i don't know what it is
  383. function! BPB_RunFilter(filter)
  384. let l:currentline = line('.')
  385. exe ":%!" . a:filter
  386. exe ":" . l:currentline
  387. endfunction
  388. " do some normal-mode commands and return the cursor to its previous location
  389. function! BPB_ExecNormalAndReturnCursor(commands)
  390. let l:currentline = line('.')
  391. " see http://learnvimscriptthehardway.stevelosh.com/chapters/30.html
  392. exe "normal! " . a:commands
  393. exe ":" . l:currentline
  394. endfunction
  395. " set custom filetypes for some things - invoked by an autocommand above
  396. function! BPB_FiletypeOverrides()
  397. " make sure NERDTree windows don't get messed up
  398. if bufname("%") =~ "NERD_tree"
  399. return
  400. endif
  401. " echom 'testing for p1k3 match'
  402. " using expand('%:p') instead of bufname("%") for full path, per:
  403. " http://vim.wikia.com/wiki/Get_the_name_of_the_current_file
  404. " the initial slash in the regex seems to be necessary to make \v work
  405. if expand('%:p') =~ "\\vp1k3\/archives.*([0-9]|[a-z])+$"
  406. " echom 'p1k3 match - setting filetype to markdown'
  407. set filetype=markdown
  408. endif
  409. endfunction
  410. function! BPB_NewFileOverrides()
  411. if expand('%:p') =~ "\\vp1k3\/archives.*([0-9]|[a-z])+$"
  412. call BPB_DatestampHTML()
  413. endif
  414. endfunction
  415. function! BPB_DatestampHTML()
  416. put='<h1>'
  417. r !today
  418. put='</h1>'
  419. -2
  420. join 3
  421. endfunction
  422. " spit out a date for today, using ~/bin/today, on the current line
  423. function! BPB_Datestamp()
  424. " . is current line, -1 is 1 line above that, r would otherwise read
  425. " the output onto the line below the cursor
  426. .-1r !today
  427. endfunction
  428. " spit out a current timestamp
  429. function! BPB_Timestamp()
  430. .-1r !rightnow
  431. endfunction
  432. function! BPB_ColorSchemeOverrides()
  433. endfunction
  434. " add some display sugar that helps highlight cursor, searches, and
  435. " textwidth. good for fiddling with alignment, reflowing text, etc.
  436. function! BPB_Crosshairs()
  437. set invhlsearch
  438. set invcursorcolumn
  439. set invcursorline
  440. " toggle a colorcolumn - will get weird if it's set outside this function
  441. if &colorcolumn == "+1"
  442. set colorcolumn=0
  443. else
  444. " i think this is relative to textwidth
  445. set colorcolumn=+1
  446. endif
  447. endfunction
  448. " cycle between no, absolute, and relative line numbers
  449. function! BPB_CycleLineNumbers()
  450. if (&number)
  451. set nonumber
  452. return
  453. endif
  454. if (&relativenumber)
  455. set number norelativenumber
  456. else
  457. set number relativenumber
  458. endif
  459. endfunction
  460. " this is pretty much horked from:
  461. " http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window
  462. function! BPB_CommandOutputInNewWindow(cmdline)
  463. echo a:cmdline
  464. let expanded_cmdline = a:cmdline
  465. for part in split(a:cmdline, ' ')
  466. if part[0] =~ '\v[%#<]'
  467. let expanded_part = fnameescape(expand(part))
  468. let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '')
  469. endif
  470. endfor
  471. botright new
  472. setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
  473. call setline(1, 'You entered: ' . a:cmdline)
  474. call setline(2, 'Expanded Form: ' . expanded_cmdline)
  475. call setline(3, substitute(getline(2), '.', '=', 'g'))
  476. execute '$read !' . expanded_cmdline
  477. setlocal nomodifiable
  478. 1
  479. endfunction
  480. " tab drop (edit in existing or new tab) a file's real path, in case it is a
  481. " symlink - useful for, frex, symlinked .vimrc. does wildcard expansion on
  482. " the path. as usual, there are probably better ways to do all of this.
  483. function! BPB_TabDrop(path)
  484. let realpath = system('readlink -f ' . shellescape(expand(a:path)))
  485. echom realpath
  486. execute 'tab drop ' . realpath
  487. endfunction
  488. " get a list of key bindings, along with where they were defined, and
  489. " open it in a tab. this variant of redir and map seen at:
  490. " https://stackoverflow.com/questions/7642746/is-there-any-way-to-view-the-currently-mapped-keys-in-vim#7642762
  491. function! BPB_ListBindings()
  492. redir! > ~/vim_keys.txt
  493. silent verbose map
  494. redir END
  495. call BPB_TabDrop("~/vim_keys.txt")
  496. endfunction
  497. " }}}
  498. " colors {{{
  499. " CUSTOMIZE: you are gonna want some other colors i bet - i have used
  500. " these all at one time or another and liked them for various reasons
  501. " colorscheme brookstream
  502. " colorscheme mustang
  503. " colorscheme dark-ruby
  504. colorscheme Tomorrow-Night-Bright
  505. " colorscheme pyte
  506. " colorscheme wargrey
  507. " colorscheme hybrid
  508. " colorscheme icansee
  509. " colorscheme candycode
  510. " }}}
  511. " folding {{{
  512. " turn off folding by default - i constantly open some file and have to
  513. " expand folds to see what's going on; this is easy to get back with zi
  514. set nofoldenable
  515. " use {{{ and }}} to denote a folded section (these can be adjusted by
  516. " setting foldmarker, but i'm sticking with the vim defaults):
  517. set foldmethod=marker
  518. " for custom foldline colors:
  519. " highlight Folded guibg=grey guifg=blue
  520. highlight FoldColumn ctermbg=darkgrey ctermfg=white guibg=darkgrey guifg=white
  521. " forked from: http://dhruvasagar.com/2013/03/28/vim-better-foldtext
  522. function! BPB_NeatFoldText()
  523. let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
  524. let lines_count = v:foldend - v:foldstart + 1
  525. let lines_count_text = '| ' . printf("%10s", lines_count . ' lines') . ' |'
  526. let foldchar = matchstr(&fillchars, 'fold:\zs.')
  527. let foldtextstart = strpart('+' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
  528. let foldtextend = lines_count_text . repeat(foldchar, 8)
  529. let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
  530. return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
  531. endfunction
  532. set foldtext=BPB_NeatFoldText()
  533. " }}}
  534. " vim:foldmethod=marker:foldlevel=0