.vimrc 7.9 KB

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