.vimrc 7.7 KB

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