removed files
[~madcoder/dotfiles.git] / vimrc
1 " {{{ settings
2
3 set nocompatible                " Use Vim defaults instead of 100% vi compatibility
4 set backspace=indent,eol,start  " more powerful backspacing
5
6 set autoindent                  " always set auto-indenting on
7 set autoread                    " reload unchanged files silentely
8 set clipboard=unnamed           " copy/paste to global clipboard
9 set hidden                      " allow to cycle and hide modified buffers
10 set nobackup                    " Don't keep a backup file
11 set backupcopy=auto,breakhardlink
12 set swapsync=
13 set esckeys                     " allow usage of curs keys within insert mode
14 set timeout
15 set ttimeoutlen=10
16 set timeoutlen=500              " set timout for esc to 50ms
17
18 set listchars=tab:\ \ ,trail:-,extends:>,precedes:<
19 set list
20 set joinspaces                  " insert two spaces after a period with every joining of lines.
21                                 " This is very nice!
22 set lazyredraw                  " [VIM5];  do not update screen while executing macros
23 set ttyfast
24 set magic                       " Use some magic in search patterns?  Certainly!
25 set modeline                    " Allow the last line to be a modeline - useful when
26                                 " the last line in sig gives the preferred text-width
27                                 " for replies.
28 set modelines=5
29 set pastetoggle=<F4>
30
31 set nonumber
32 set report=0                    " show a report when N lines were changed.
33                                 " report=0 thus means "show all changes"!
34
35 set laststatus=2                " show status line?  Yes, always!
36 set noruler                       " show cursor position?  Yep!
37 set statusline=[\ %f%m\ %r%y\ %{fugitive#statusline()}\ %=\ hex:%B\ \ %l,%c%V\ \ %P\ ]
38
39 set shiftwidth=4                " Number of spaces to use for each insertion of
40                                 " (auto)indent.
41 set shortmess=at                " Kind of messages to show.   Abbreviate them all!
42                                 " New since vim-5.0v: flag 'I' to suppress "intro message".
43 set scrolloff=2                 " context
44 set showcmd                     " Show current uncompleted command?  Absolutely!
45 set showmatch                   " Show the matching bracket for the last ')'?
46 set showmode                    " Show the current mode?  YEEEEEEEEESSSSSSSSSSS!
47
48 set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.cmi,.cmo
49                                 " Suffixes to ignore in file completion
50
51 set tabstop=8                   " tabstop
52 set softtabstop=4               " sts
53 set expandtab                   " expand tabs
54 set notextmode                  " no - I am using Vim on UNIX!
55 set textwidth=0                 " Don't wrap words by default
56 set cc=+1
57 set title                       " Permet de voir le tit. du doc. crt. ds les XTERM
58 set viminfo='1000,/1000,:1000,<1000,@1000,n~/.viminfo
59 set history=1000
60                                 " What info to store from an editing session
61                                 " in the viminfo file;  can be used at next session.
62 set undofile
63 set undodir=~/.cache/vim/
64 au BufWritePre /tmp/* setlocal noundofile
65 set sessionoptions=buffers,folds,localoptions,options,tabpages,help
66
67 set ignorecase                  " Do case insensitive matching
68 set incsearch                   " Incremental search
69 set hlsearch                    " hilight search
70
71
72 set whichwrap=<,>,[,]           "
73 set wildchar=<TAB>              " the char used for "expansion" on the command line
74                                 " default value is "<C-E>" but I prefer the tab key:
75 set wildmenu                    " Completion on the command line shows a menu
76 set wildmode=longest,full
77 set winminheight=0              " Minimum height of VIM's windows opened
78 set mouse=a
79 set mousefocus
80 set wrapmargin=1
81 set nowritebackup
82 set foldmethod=marker
83
84 set noequalalways
85 set eadirection=
86
87 set cpoptions-=C                " enable commands that continue on the next line
88
89 " use ctrl-n ctrl-n instead of ctrl-x ctrl-k
90 set complete-=k complete+=k
91
92 set tags=tags;/,.tags;/,TAGS;/
93
94 set cinoptions=
95 set cinoptions+=Ls           " align labels at 0 shiftwidth
96 set cinoptions+=:0,=1s    " same for case labels
97 "set cinoptions+=g0.5s,h0.5s   " same for c++ stuff
98 set cinoptions+=t0             " type on the line before the functions is not idented
99 set cinoptions+=(0,Ws          " indent in functions ( ... ) when it breaks
100 set cinoptions+=m1             " aligh the closing ) properly
101 set cinoptions+=j1             " java/javscript -> fixes blocks
102 "set cinoptions+=l0.5s          " align code after label ignoring braces.
103
104 set diffopt=filler,context:5,iwhite
105 set fillchars+=diff:\ ,vert:│
106
107 exe "set path=." . system("echo | cpp -v 2>&1 | grep '^ .*/include' | tr -d \"\n\" | tr \" \" \",\"")
108 set path+=.;/
109
110 " }}}
111 " {{{ vim 7 settings
112
113 if version >= 700
114     set autochdir              " autochdir...
115     set virtualedit=onemore    " Yes I want to be able to be "on \n"
116     set spelllang=en_us,fr
117     set pumheight=16
118
119     " make <enter> work in popup
120     inoremap <cr> <C-R>=pumvisible() ? "\<lt>C-Y>" : "\<lt>cr>"<cr>
121 else
122     au BufEnter * :lcd %:p:h
123 endif
124
125 " }}}
126 " {{{ Window magic
127
128 function! DeleteBuffer()
129    let bid = bufnr("%")
130    bnext
131    exe "bdel " . bid
132    redraw
133 endfunction
134
135 map <C-W>d :call DeleteBuffer()<cr>
136 "map <C-W>k :bd<cr>
137 map <C-W>g :bo cw 8<cr>
138
139 " }}}
140 " {{{ Mappings
141
142 " {{{ Tab Key magic ...
143 vnoremap <tab> >gv
144 xnoremap <tab> >gv
145 snoremap <tab> >gv
146 vnoremap <bs> <gv
147 xnoremap <bs> <gv
148 snoremap <bs> <gv
149
150 function! TabAlign()
151     let col  = col('.')
152     let lnum = line('.')
153
154     while lnum > 1
155         let lnum = lnum - 1
156         let ln = strpart(getline(lnum), col-1)
157         let ms = matchstr(ln, '[^ ]*  *[^ ]')
158         if ms != ""
159             break
160         endif
161     endwhile
162
163     if lnum == 1
164         return "\<Tab>"
165     else
166         let @z = substitute(strpart(ms, 0, strlen(ms)-1), '.', ' ', 'g')
167         if col > strlen(getline('.'))
168             return "\<C-O>\"zp"
169         else
170             return "\<C-O>\"zP"
171         endif
172     endif
173
174 endfunction
175
176 function! CleverTab()
177     let c = strpart(getline('.'), col('.')-2, 1)
178     if c == ' ' || c == '\t' || c == ''
179         return TabAlign()
180     else
181         return "\<C-P>"
182     endif
183 endfunction
184 inoremap <Tab> <C-R>=CleverTab()<CR>
185 inoremap <S-Tab> <C-R>=TabAlign()<CR>
186
187 " }}}
188
189 map + :cnext<cr>
190 map - :cprevious<cr>
191 map <kPlus> :cnext<cr>
192 map <kMinus> :cprevious<cr>
193
194 map Q gq
195
196 noremap  <F2>   :set mouse=a<cr>
197 noremap  <F3>   :set mouse=h<cr>
198 noremap  <F5>   :source ~/.vimrc<cr>
199
200 inoremap <F6>   <c-o>mzviwU`z
201 noremap  <F7>   :set ai!<CR>:set ai?<cr>
202 inoremap <F7>   <space><esc><F7>a<bs>
203
204 noremap  <F11>  :make!<cr>:bo cw 8<cr><cr>
205 inoremap <F11>  <esc>:make!<cr>:bo cw 8<cr><cr>
206 noremap  <S-F11> :make clean<cr><cr>
207 inoremap <S-F11> <esc>:make clean<cr><cr>
208
209 " }}}
210 "{{{ FTYPES
211
212 if has("autocmd")
213     filetype plugin indent on
214     syntax on
215
216     au Syntax {cpp,c,javascript} runtime syntax/doxygen.vim
217
218     au BufReadPost *
219                 \ if line("'\"") > 0 && line("'\"") <= line("$") |
220                 \   exe "normal g`\"" |
221                 \ endif
222
223     au VimLeave * mksession! ~/.cache/session.vim
224
225     au FileType debchangelog normal zO
226
227     au FileType asciidoc setlocal tw=78 noet ts=8 sw=8
228     au FileType javascript setlocal cindent tw=78 iskeyword+=$
229     au FileType actionscript setlocal cindent tw=78 iskeyword+=$ noignorecase ff=dos
230     au FileType mail setlocal noet iskeyword+=- tw=72
231
232     au FileType haxe setlocal tw=78 noignorecase cin ai
233     au FileType d,c,cpp setlocal tw=78 noignorecase "fo-=ro
234     au FileType ocaml,acute,omlet setlocal sw=2 sts=2 tw=78
235     au FileType php  setlocal et fo+=ro tw=78 indentexpr= cin
236     au FileType python setlocal foldmethod=indent foldnestmax=1
237
238     au FileType diff   setlocal nofoldenable
239
240     au FileType html,xhtml,xml setlocal sw=2
241     au FileType mail setlocal spell
242
243     " make error list special
244     au BufRead quickfix setlocal nobuflisted nowrap number
245
246     au FileType svn setlocal spell tw=76
247     au FileType git setlocal spell tw=76
248
249     au BufRead,BufNewFile */dev/scm/git/* setlocal noet sw=8
250
251     let ocaml_noindent_let=1
252     let git_diff_spawn_mode=2
253     let git_diff_opts = "--no-renames --summary -C -M"
254     let c_gnu=1
255     let c_space_errors=1
256     let c_no_curly_error=1
257
258     let g:bufExplorerFindActive=0
259     let g:bufExplorerSplitOutPathName=1
260     let g:bufExplorerShowRelativePath=0
261     let g:bufExplorerSortBy='fullpath'
262
263     let g:is_bash=1
264     let g:sh_fold_enabled=1
265
266     let g:debchangelog_fold_enable = 1
267     let g:debcontrol_fold_enable = 1
268 endif " has ("autocmd")
269
270 " }}}
271 " {{{ PLUGINS
272
273 runtime macros/matchit.vim
274 "runtime macros/justify.vim
275
276 runtime ftplugin/man.vim
277 nmap ! :exe "Man" expand("<cword>")<cr>
278
279 " }}}
280 " {{{ COLORS, GUI and FOLDING
281
282 set background=light
283 hi clear
284 if exists("syntax_on")
285    syntax reset
286 endif
287
288 if has("gui_running")
289     set guioptions=eit
290     set guifont=terminus
291     set guicursor=a:blinkon0
292     set background=light
293
294     fun! GuiTabLabel()
295         let label = ''
296         let bufnrlist = tabpagebuflist(v:lnum)
297
298         " Append the number of windows in the tab page if more than one
299         let wincount = tabpagewinnr(v:lnum, '$')
300         let label .= wincount
301
302         " Add '[*]' if one of the buffers in the tab page is modified
303         for bufnr in bufnrlist
304             if getbufvar(bufnr, "&modified")
305                 let label .= '[*]'
306                 break
307             endif
308         endfor
309
310
311         if exists("t:tabname")
312             return t:tabname . ': ' . label
313         else
314             return label . '[' . bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]) .']'
315         endif
316     endf
317     set guitablabel=%{GuiTabLabel()}
318 endif
319
320 fun! <SID>Y(a)
321     if strlen(a:a) != 6 || a:a == "yellow"
322         return a:a
323     endif
324     if has("gui_running")
325         return "#".a:a
326     endif
327     let l:r = ("0x" . strpart(a:a, 0, 2)) + 0
328     let l:g = ("0x" . strpart(a:a, 2, 2)) + 0
329     let l:b = ("0x" . strpart(a:a, 4, 2)) + 0
330     if &t_Co == 88
331         let l:gray  = 10
332         let l:cube  = 4
333         let l:shift = 79
334     else
335         let l:gray  = 26
336         let l:cube  = 6
337         let l:shift = 232
338     endif
339
340     if l:r * l:gray / 256 == l:g * l:gray / 256 && l:r * l:gray / 256 == l:b * l:gray / 256
341         let l:s = l:r * l:gray / 256
342         if l:s == 0
343             return "black"
344         elseif l:s == l:gray - 1
345             return "white"
346         else
347             return l:shift + l:s
348         endif
349     endif
350     let l:x = ((l:r * l:cube) / 256)
351     let l:y = ((l:g * l:cube) / 256)
352     let l:z = ((l:b * l:cube) / 256)
353     return 16 + ((l:x * l:cube + l:y) * l:cube) + l:z
354 endfun
355
356 fun! <SID>myhi(cls, m, fg, bg)
357     if has("gui_running")
358         exec "hi ".a:cls." gui=".a:m." guifg=".<SID>Y(a:fg)." guibg=".<SID>Y(a:bg)
359     else
360         exec "hi ".a:cls." cterm=".a:m." ctermfg=".<SID>Y(a:fg)." ctermbg=".<SID>Y(a:bg)
361     endif
362 endfun
363
364 if has("gui_running") || &t_Co >= 88
365     if has("gui_running")
366         exec <SID>myhi("Normal",       "none",       "dfdfdf",    "00000f")
367         exec <SID>myhi("MoreMsg",      "none",       "dfdfdf",    "00000f")
368     else
369         exec <SID>myhi("Normal",       "none",       "dfdfdf",    "NONE")
370         exec <SID>myhi("MoreMsg",      "none",       "dfdfdf",    "NONE")
371     endif
372     exec <SID>myhi("ColorColumn",  "none",       "NONE",      "0f0f0f")
373     exec <SID>myhi("Comment",      "none",       "afafff",    "0f0f0f")
374     exec <SID>myhi("Folded",       "none",       "afafff",    "0f0f0f")
375
376     exec <SID>myhi("SpecialKey",   "none",       "dfdfdf",    "0f0f0f")
377     exec <SID>myhi("Todo",         "underline",  "yellow",    "2f2f2f")
378     exec <SID>myhi("Error",        "bold",       "white",     "red")
379
380     exec <SID>myhi("Function",     "none",       "4fdfdf",    "NONE")
381     exec <SID>myhi("Identifier",   "none",       "4fdfdf",    "NONE")
382
383     exec <SID>myhi("Cursor",       "reverse",    "dfdfdf",    "black")
384     exec <SID>myhi("Visual",       "none",       "NONE",      "2f2f2f")
385     exec <SID>myhi("IncSearch",    "none",       "black",     "yellow")
386     exec <SID>myhi("Search",       "none",       "black",     "yellow")
387
388     exec <SID>myhi("StatusLine",   "none",       "yellow",    "2f2f2f")
389     exec <SID>myhi("StatusLineNc", "none",       "dfdfdf",    "1c1c1c")
390     exec <SID>myhi("WildMenu",     "none",       "white",     "0f0f0f")
391     exec <SID>myhi("VertSplit",    "none",       "darkgray",  "0f0f0f")
392     exec <SID>myhi("NonText",      "none",       "darkgray",  "NONE")
393
394     exec <SID>myhi("MatchParen",   "none",       "white",     "0f0f0f")
395     exec <SID>myhi("Pmenu",        "none",       "dfdfdf",    "0f0f0f")
396     exec <SID>myhi("PmenuSel",     "none",       "white",     "3f3f7f")
397     exec <SID>myhi("PmenuSbar",    "none",       "white",     "0f0f0f")
398     exec <SID>myhi("PmenuThumb",   "none",       "3f3f7f",    "3f3f7f")
399
400     exec <SID>myhi("SpellBad",     "none",       "NONE",      "800000")
401     exec <SID>myhi("SpellCap",     "none",       "NONE",      "004000")
402     exec <SID>myhi("SpellLocal",   "none",       "NONE",      "004000")
403     exec <SID>myhi("SpellRare",    "none",       "NONE",      "NONE")
404
405     exec <SID>myhi("Label",        "none",       "bf7f00",    "NONE")
406     exec <SID>myhi("Conditional",  "none",       "bf7f00",    "NONE")
407     exec <SID>myhi("Repeat",       "none",       "bf7f00",    "NONE")
408     exec <SID>myhi("Statement",    "none",       "bf7f00",    "NONE")
409
410     exec <SID>myhi("StorageClass", "none",       "20b020",    "NONE")
411     exec <SID>myhi("Type",         "none",       "20b020",    "NONE")
412     exec <SID>myhi("Structure",    "none",       "20b020",    "NONE")
413     exec <SID>myhi("Directory",    "none",       "20b020",    "NONE")
414
415     exec <SID>myhi("Include",      "none",       "bf0fbf",    "NONE")
416     exec <SID>myhi("PreProc",      "none",       "bf0fbf",    "NONE")
417     exec <SID>myhi("Macro",        "none",       "bf0fbf",    "NONE")
418     exec <SID>myhi("SpecialChar",  "none",       "bf0fbf",    "NONE")
419
420     exec <SID>myhi("Character",    "none",       "bf0f0f",    "NONE")
421     exec <SID>myhi("String",       "none",       "bf0f0f",    "NONE")
422     exec <SID>myhi("Constant",     "none",       "bf0f0f",    "NONE")
423
424     " diff
425     exec <SID>myhi("DiffAdd",      "none",       "NONE",      "002f0f")
426     exec <SID>myhi("DiffDelete",   "none",       "NONE",      "2f000f")
427     exec <SID>myhi("DiffChange",   "none",       "NONE",      "00003f")
428     exec <SID>myhi("DiffText",     "underline",  "NONE",      "00003f")
429     exec <SID>myhi("diffRemoved",  "none",       "bf0fbf",    "NONE")
430
431     " C
432     exec <SID>myhi("cFunction",    "none",       "b0b0b0",    "NONE")
433
434     " Doxygen
435     if !exists(':SynLink')
436         command -nargs=+ SynLink hi def link <args>
437     endif
438     SynLink doxygenSpecialTypeOnelineDesc  doxygenBrief
439     SynLink doxygenSpecialOnelineDesc      doxygenBrief
440     SynLink doxygenSpecialHeading          doxygenBrief
441     SynLink doxygenParamDirection          doxygenSpecial
442
443     exec <SID>myhi("javaScriptTpl",    "none",       "7fcf7f",    "none")
444     exec <SID>myhi("javaScriptTplMark","none",       "b218b2",    "none")
445     exec <SID>myhi("doxygenComment",   "none",       "6060ff",    "0f0f0f")
446     exec <SID>myhi("doxygenBrief",     "none",       "6060ff",    "0f0f0f")
447     exec <SID>myhi("doxygenPrev",      "none",       "6060ff",    "0f0f0f")
448     exec <SID>myhi("doxygenParam",     "none",       "6060ff",    "0f0f0f")
449     exec <SID>myhi("doxygenSpecial",   "none",       "6060ff",    "0f0f0f")
450     exec <SID>myhi("doxygenParamName", "underline",  "6060ff",    "0f0f0f")
451 else
452     hi Comment      cterm=none       ctermfg=blue       ctermbg=none
453     hi Folded       cterm=none       ctermfg=brown      ctermbg=none
454
455     hi Visual       cterm=reverse    ctermfg=none       ctermbg=none
456     hi IncSearch    cterm=underline  ctermfg=white      ctermbg=none
457     hi Search       cterm=underline  ctermfg=white      ctermbg=none
458
459     hi StatusLine   cterm=none       ctermfg=white      ctermbg=blue
460     hi StatusLineNc cterm=none       ctermfg=black      ctermbg=white
461     hi WildMenu     cterm=none       ctermfg=white      ctermbg=none
462     hi VertSplit    cterm=none       ctermfg=darkgray   ctermbg=none
463     hi NonText      cterm=none       ctermfg=darkgray   ctermbg=none
464
465     hi MatchParen   cterm=underline  ctermfg=none       ctermbg=none
466     hi Pmenu        cterm=none       ctermfg=gray       ctermbg=black
467     hi PmenuSel     cterm=none       ctermfg=black      ctermbg=gray
468     hi PmenuSbar    cterm=none       ctermfg=blue       ctermbg=blue
469     hi PmenuThumb   cterm=none       ctermfg=gray       ctermbg=gray
470
471     hi SpellBad     cterm=underline  ctermfg=lightred   ctermbg=none
472     hi SpellCap     cterm=none       ctermfg=lightred   ctermbg=none
473     hi SpellLocal   cterm=underline  ctermfg=darkgreen  ctermbg=none
474     hi SpellRare    cterm=none       ctermfg=none       ctermbg=none
475 endif
476
477 " Custom
478 hi def link htmlTag htmlStatement
479 hi def link htmlEndTag htmlStatement
480
481 ia <buffer> sabine Sabine
482 " }}}
483
484 call pathogen#infect()
485 let g:clang_complete_copen=1
486 let g:clang_snippets=1
487 let g:clang_complete_patterns=1
488 let g:clang_snippets_engine = 'clang_complete'
489 set completeopt=menu,longest
490 set concealcursor=inv