.vimrc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. "
  2. " Vim configuration file (~/.vimrc)
  3. " 2009-2014, kolter <kolter@openics.org>
  4. "
  5. " This file is distributed in the hope that it will be useful,
  6. " but WITHOUT ANY WARRANTY
  7. "
  8. " {{{ Load Plugins
  9. call plug#begin('~/.vim/plugged')
  10. Plug 'junegunn/indentLine'
  11. Plug 'sjl/gundo.vim'
  12. Plug 'scrooloose/syntastic'
  13. Plug 'majutsushi/tagbar'
  14. Plug 'scrooloose/nerdtree'
  15. Plug 'bling/vim-airline'
  16. Plug 'kien/ctrlp.vim'
  17. Plug 'tpope/vim-fugitive'
  18. Plug 'airblade/vim-gitgutter'
  19. Plug 'gregsexton/gitv'
  20. Plug 'terryma/vim-multiple-cursors'
  21. Plug 'jlanzarotta/bufexplorer'
  22. Plug 'flazz/vim-colorschemes'
  23. Plug 'vim-scripts/comments.vim'
  24. Plug 'ervandew/supertab'
  25. Plug 'rstacruz/sparkup'
  26. Plug 'Lokaltog/vim-easymotion'
  27. Plug 'editorconfig/editorconfig-vim'
  28. Plug 'godlygeek/tabular'
  29. Plug 'plasticboy/vim-markdown'
  30. Plug 'pearofducks/ansible-vim'
  31. Plug 'LaTeX-Box-Team/LaTeX-Box'
  32. Plug 'SirVer/ultisnips'
  33. Plug 'honza/vim-snippets'
  34. Plug 'http://git.openics.org/kolter/vim-bindzone.git'
  35. call plug#end()
  36. " }}}
  37. " {{{ General Settings
  38. " Filetypes Settings
  39. if has('autocmd')
  40. filetype plugin indent on
  41. "reload Vim config file after saving
  42. "autocmd BufWritePost $MYVIMRC :source $MYVIMRC
  43. "always limit the width for text files
  44. autocmd BufRead *.txt set tw=78
  45. autocmd QuickFixCmdPre * botright cwindow 5
  46. endif
  47. "Term settings (under tmux)
  48. if &term =~ '^screen'
  49. "tmux will send xterm-style keys when its xterm-keys option is on
  50. execute "set <xUp>=\e[1;*A"
  51. execute "set <xDown>=\e[1;*B"
  52. execute "set <xRight>=\e[1;*C"
  53. execute "set <xLeft>=\e[1;*D"
  54. endif
  55. set nocompatible "no vi compatibility
  56. set history=1000 "command history size
  57. set undolevels=120 "undo levels count
  58. set autoread "notify file changes
  59. set autochdir "switch to the current file directory
  60. set clipboard+=unnamed "share system clipboard
  61. set backup "enable backups
  62. set backupdir=~/.vim/backups "backup directory
  63. set directory=~/.vim/tmp "directory to place swap files in
  64. "Encoding settings
  65. if has("multi_byte")
  66. if &termencoding == ""
  67. let &termencoding = &encoding
  68. endif
  69. set encoding=utf-8
  70. setglobal fileencoding=utf-8
  71. set fileencodings=utf-8,default,latin1,ucs-bom
  72. endif
  73. "Syntax highlight
  74. syntax on
  75. set t_Co=256
  76. set bg=dark
  77. colorscheme grb256
  78. " }}}
  79. " {{{ Interface Settings
  80. set title "show title
  81. set number "show line numbers
  82. set ruler "statusline for each window
  83. set visualbell t_vb= "visual beep
  84. set showcmd "show incomplete commands
  85. set confirm "raise a dialog asking what to do instead of failing
  86. "set mouse=a "enable mouse support
  87. set lazyredraw "do not redraw when running macros
  88. set ttyfast "fast terminal connection support
  89. set ttimeout
  90. set ttimeoutlen=100
  91. set scrolloff=999
  92. set sidescrolloff=5
  93. set shortmess=a "abbreviations on status line
  94. set laststatus=2 "always statusline
  95. set wildmenu "display completion menu
  96. set wildmode=list:longest,list:full "content of completion menu
  97. "ignore some extensions while completing filename
  98. "set wildignore=*.o,*.so,,*.gz,*.bz2,*.tar,*.tgz,*.tbz2,*.png,*.jpg,*.jpeg,*.gif
  99. set wildchar=<TAB> "wildcar expansion character
  100. set modeline "allow last lines of documents set vim mode
  101. set modelines=3 "number of lines to check for modelines
  102. " }}}
  103. " {{{ Keyboard Settings
  104. " fix home and end keys with some terminals
  105. if $TERM =~ '^screen-256color'
  106. map <Esc>OH <Home>
  107. map! <Esc>OH <Home>
  108. map <Esc>OF <End>
  109. map! <Esc>OF <End>
  110. endif
  111. " keep ctrl-a/ctrl-e for begining/end of line
  112. nmap <c-a> <c-o>I
  113. imap <c-a> <c-o>I
  114. vmap <c-a> <c-o>I
  115. nmap <c-e> <c-o>A
  116. imap <c-e> <c-o>A
  117. vmap <c-e> <c-o>A
  118. "reopen current file
  119. map <F5> :e!<cr>
  120. "using redraw to disable highlighted search patterns
  121. nnoremap <c-L> :nohl<cr><c-L>
  122. "map F1 to open previous buffer
  123. nmap <F1> :bp<cr>
  124. imap <F1> <ESC>:bp<cr>a
  125. "map F2 to open next buffer
  126. nmap <F2> :bn<cr>
  127. imap <F2> <ESC>:bn<cr>a
  128. imap <c-@> <c-x><c-o>
  129. nmap <c-s-left> :tabprevious<cr>
  130. nmap <c-s-right> :tabnext<cr>
  131. nmap <c-s-up> :tabnew<cr>
  132. nmap <c-s-down> :tabclose<cr>
  133. nmap <c-d> :bw<cr>
  134. nmap <F6> :vsplit<cr>
  135. nmap <F7> :split<cr>
  136. "ctrl-$arrow to cycle around splitted windows
  137. map <c-left> <c-w>h
  138. map <c-right> <c-w>l
  139. map <c-Up> <c-w>k
  140. map <c-Down> <c-w>j
  141. "ident in visual mode keep selection
  142. vmap > >gv
  143. vmap < <gv
  144. " }}}
  145. " {{{ Editor Settings
  146. set fileformats=unix,dos,mac "support all three, in this order
  147. set hidden "make possible to change buffer without saving
  148. set report=0 "agressive reporting
  149. set pastetoggle=<F11> "use <F11> to toggle between 'paste' and 'nopaste'
  150. set nostartofline "leave the cursor where it is
  151. "indent settings
  152. set autoindent
  153. set backspace=indent,eol,start "enhance backspacing
  154. set smartindent
  155. set cindent
  156. set smarttab
  157. "tabs and spaces settings
  158. set expandtab "tab are spaces
  159. set tabstop=4
  160. set shiftwidth=4
  161. set shiftround "round indent to shiftwidth
  162. set softtabstop=4
  163. set showmatch "brace/parenthese/bracket matching
  164. set nowrap "wrap long lines
  165. if has("multi_byte")
  166. set showbreak="…"
  167. else
  168. set showbreak="+++"
  169. endif
  170. "show some not printable chars
  171. set list
  172. if has("multi_byte")
  173. set listchars=trail:·,extends:>,precedes:<,nbsp:•,tab:▷\⋅
  174. else
  175. set listchars=tab:>.,trail:·,extends:>,precedes:<,nbsp:%
  176. endif
  177. "search settings
  178. set hlsearch "highlight searches
  179. set incsearch "incremental searches
  180. set ignorecase "ignore case in search patterns
  181. set infercase "smart case support
  182. " }}}
  183. " {{{ Code folding
  184. set foldmethod=indent "fold based on indent
  185. set nofoldenable "dont fold by default
  186. set foldlevel=0
  187. " }}}
  188. " {{{ Email Settings
  189. if has('autocmd')
  190. autocmd BufRead ~/.mutt/tmp/mutt-* set filetype=mail
  191. autocmd FileType mail set autoindent expandtab nocindent formatoptions=tcqn
  192. autocmd FileType mail vmap D dO[...]<CR>
  193. autocmd FileType mail call EnableSpellChecking()
  194. endif
  195. " }}}
  196. " {{{ Spell Checking
  197. "set spellfile=~/.vim/spell/words
  198. function! EnableSpellChecking()
  199. setlocal spell spelllang=fr,en_us
  200. let b:spell = 1
  201. endfunction
  202. function! DisableSpellChecking()
  203. setlocal nospell
  204. unlet b:spell
  205. endfunction
  206. function! ToggleSpell()
  207. if !exists("b:spell")
  208. execute 'call EnableSpellChecking()'
  209. else
  210. execute 'call DisableSpellChecking()'
  211. endif
  212. endfunction
  213. nmap <F4> :call ToggleSpell()<CR>
  214. imap <F4> <Esc>:call ToggleSpell()<CR>a
  215. " }}}
  216. " {{{ Gundo extension Setup
  217. " Gundo sidebar on the right
  218. let g:gundo_right = 1
  219. " Gundo layout
  220. let g:gundo_width = 60
  221. let g:gundo_preview_height = 40
  222. " Gundo status lines
  223. let g:gundo_tree_statusline = "Gundo"
  224. let g:gundo_preview_statusline = "Gundo Preview"
  225. " Preview pane below the buffer
  226. let g:gundo_preview_bottom = 1
  227. " Close Gundo panes on revert
  228. let g:gundo_close_on_revert = 1
  229. " F3 key to show/hide Gundo sidebar
  230. nnoremap <F3> :GundoToggle<CR>
  231. " }}}
  232. " {{{ Syntastic extension Setup
  233. " automatically open/close pane when errors (or not)
  234. let g:syntastic_auto_loc_list = 1
  235. " Redefine errors/warning symbols on sidebar
  236. let g:syntastic_error_symbol = 'EE'
  237. let g:syntastic_style_error_symbol = 'ee'
  238. let g:syntastic_warning_symbol = 'WW'
  239. let g:syntastic_style_warning_symbol = 'Ws'
  240. " redefine default python linter
  241. "let g:syntastic_python_checker = 'pylint'
  242. " add options to python linter
  243. "let g:syntastic_python_checker_args = ''
  244. " }}}
  245. " {{{ ctrlp extension Setup
  246. " Change default key
  247. let g:ctrlp_map = '<c-o>'
  248. " Match window height
  249. let g:ctrlp_max_height = 20
  250. " Add a key to search in opened buffers
  251. map <c-b> :CtrlPBuffer<cr>
  252. " }}}
  253. " {{{ airline extension setup
  254. let g:airline_powerline_fonts=1
  255. let g:airline#extensions#tabline#enabled=1
  256. " }}}
  257. " {{{ tagbar extension setup
  258. nmap <F8> :TagbarToggle<CR>
  259. " }}}
  260. " {{{ Latex settings
  261. let g:tex_conceal = ""
  262. let g:LatexBox_Folding = 1
  263. let g:UltiSnipsExpandTrigger="<tab>"
  264. let g:UltiSnipsJumpForwardTrigger="<tab>"
  265. let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
  266. if has('autocmd')
  267. autocmd FileType tex set foldlevel=0 foldenable
  268. endif
  269. " }}}
  270. " vim: foldmethod=marker foldlevel=0 foldenable