[zsh/vim/irssi/...] My home files
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.

.vimrc 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. " Skia < skia AT libskia DOT so >
  2. " Released under the Beer License - 2014:2017
  3. "
  4. " Based on an initial vimrc by Julien (jvoisin) Voisin <julien.voisin@dustri.org>
  5. " Released under the Beer License - 2010:2012
  6. call plug#begin('~/.vim/plugged')
  7. Plug 'scrooloose/nerdtree'
  8. Plug 'airblade/vim-gitgutter'
  9. Plug 'ervandew/supertab'
  10. Plug 'jiangmiao/auto-pairs'
  11. Plug 'terryma/vim-multiple-cursors'
  12. Plug 'vim-scripts/nginx.vim'
  13. Plug 'osyo-manga/vim-over'
  14. Plug 'lepture/vim-jinja'
  15. Plug 'SirVer/ultisnips' "Both snippet plugins are needed for them to work
  16. Plug 'honza/vim-snippets'
  17. Plug 'morhetz/gruvbox'
  18. Plug 'ambv/black'
  19. call plug#end()
  20. let g:UltiSnipsExpandTrigger="<tab>"
  21. let g:UltiSnipsJumpForwardTrigger="<c-b>"
  22. let g:UltiSnipsJumpBackwardTrigger="<c-z>"
  23. "GENERAL
  24. set nocompatible " vim, and not vi
  25. set history=128 " keep 128 lines of history
  26. set showcmd " show incomplete commands
  27. colorscheme gruvbox " colorsheme : gruvbox \o/
  28. let g:gruvbox_contrast_dark="hard"
  29. set background=dark
  30. set nomodeline " modeline are for pussies
  31. set textwidth=80 " max number of characters on a single line
  32. set laststatus=2 " display statusline
  33. set statusline=%<%F\ %h%m%r%y%=%-14.(%l,%c%V%)\ %P
  34. filetype plugin on
  35. "ENCODING
  36. set encoding=utf-8
  37. set fileencoding=utf-8
  38. set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,nbsp:‡
  39. set list
  40. "SEARCH and/or REPLACE
  41. set ignorecase " caseless search
  42. set smartcase " except when using capitals
  43. set showmatch " show matching brackets
  44. set incsearch " instant search
  45. set nohlsearch " don't highlight the search
  46. set wrapscan " wrap search
  47. set gdefault " assume /g flag on :s/
  48. "UI
  49. set cursorline " print cursorline
  50. set number " print the line number
  51. syntax on " activate the syntax
  52. set ruler " always show the current position
  53. set so=7 " 9 lines margin to the cursor when moving
  54. set t_Co=256 " 256 colors
  55. set splitbelow " split below current window
  56. set ttyfast " smooth !
  57. "change color of char that are beyond the 79th column
  58. highlight rightMargin ctermfg=grey
  59. match rightMargin /.\%>119v/
  60. " MOUSE
  61. set mousehide " hide mouse pointer while typing
  62. set mouse=a " mouse support
  63. behave xterm " behave like xterm
  64. "FOLDING
  65. set foldmethod=manual " folding on indentation
  66. set foldlevel=99 " maxindent = inf !
  67. "SYNTAX/LAYOUT
  68. filetype plugin indent on " automatic recognition of filetype
  69. set wrap " wrap
  70. "AUTOCOMPLETION
  71. set wildmode=list:longest,full
  72. set wildignore+=*.pyc,*.o " ignored on autocomplete
  73. set completeopt=longest,menuone,preview " cool completion view
  74. set complete=.,w,b,u,U,t,i,d " mega tab completion
  75. set omnifunc=syntaxcomplete#Complete
  76. " TODO complete with more filetypes
  77. autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
  78. autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
  79. let g:SuperTabDefaultCompletionType = 'context'
  80. autocmd FileType *
  81. \ if &omnifunc != '' |
  82. \ call SuperTabChain(&omnifunc, '<c-p>') |
  83. \ endif
  84. "SPELLCHECK
  85. "setlocal spell spelllang=fr
  86. setlocal spell spelllang=en_gb
  87. set spell
  88. "BACKUP
  89. set nobackup " no backup : everything is on git/svn
  90. set nowb
  91. set noswapfile " I said everything was on git !
  92. "MAPPING
  93. " ROT13, olol !
  94. map <F12> ggVGg?
  95. map <C-y> "+y
  96. map <C-p> "+p
  97. set backspace=indent,eol,start " allow backspacing over everything in insert mode
  98. let mapleader = "," " remap the leader key to ','
  99. "IDENT
  100. set autoindent " Auto-ident
  101. set smartindent " Smart ident
  102. set smarttab " Reset autoindent after a blank line
  103. set expandtab " tabs are spaces
  104. set tabstop=4 " how many spaces on tab
  105. set softtabstop=4 " one tab = 4 spaces
  106. set shiftwidth=4 " reduntant with above
  107. "skeleton
  108. autocmd BufnewFile *.sh 0r ~/.vim/skeleton.sh|3
  109. autocmd BufnewFile *.py 0r ~/.vim/skeleton.py|4
  110. autocmd BufnewFile *.cpp 0r ~/.vim/skeleton.cpp|7
  111. autocmd BufnewFile *.c 0r ~/.vim/skeleton.c|5
  112. autocmd BufnewFile *.tex 0r ~/.vim/skeleton.tex|47
  113. " Filetype hack
  114. " autocmd BufRead,BufNewFile *.pl set filetype=prolog
  115. autocmd BufRead,BufNewFile *.md set filetype=markdown
  116. autocmd BufRead,BufNewFile *.jinja set filetype=jinja
  117. autocmd Filetype pl set syntax=prolog
  118. au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif
  119. autocmd BufWritePre *.py execute ':Black'
  120. "BINDINGS
  121. " For all text files set 'textwidth' to 79 characters.
  122. autocmd FileType text setlocal textwidth=120
  123. " nerdtree
  124. map <silent> <C-e> :NERDTreeToggle<CR>
  125. map <silent> <F6> :tabprevious<CR>
  126. map <silent> <F7> :tabnext<CR>
  127. map <silent> <F8> :set spell!<CR>
  128. set pastetoggle=<F9>
  129. " Shifting visual block should keep it selected
  130. vnoremap < <gv
  131. vnoremap > >gv
  132. " Auto brackets
  133. inoremap (( ()<Esc>i
  134. inoremap [[ []<Esc>i
  135. inoremap {{ {}<Esc>i
  136. inoremap "" ""<Esc>i
  137. inoremap '' ''<Esc>i
  138. " nice xml !
  139. inoremap <buffer> </ </<C-x><C-o><Esc>a
  140. inoremap <buffer> <!D <!D<C-x><C-o>
  141. inoremap <buffer> <!- <!--<Space><Space>--><Esc>3hi
  142. " mousepaste
  143. map <MouseMiddle> <esc>"*p
  144. " MISC
  145. set visualbell " no beep !
  146. " no trailing spaces !
  147. let g:noStripWhitespace=0
  148. fun! StripTrailingWhitespace()
  149. if g:noStripWhitespace
  150. return
  151. endif
  152. %s/\s\+$//e
  153. endfun
  154. autocmd BufWritePre * call StripTrailingWhitespace()
  155. " Don't strip on these filetypes
  156. autocmd FileType markdown,sh let g:noStripWhitespace=1
  157. map <silent> <F5> :let g:noStripWhitespace=!g:noStripWhitespace<CR>
  158. " show unwanted spaces
  159. highlight ExtraWhitespace ctermbg=red guibg=red
  160. match ExtraWhitespace /\s\+$/
  161. autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/
  162. " sudo with !!
  163. map w!! %!sudo tee % > /dev/null
  164. " auto cd
  165. autocmd BufEnter * lcd %:p:h
  166. "tag list
  167. let g:Tlist_Use_Right_Window=1
  168. "nerd tree
  169. let NERDTreeIgnore=['\.pyc$', '\.pyrc$', '\.svn$', '\.git$']
  170. let NERDTreeQuitOnOpen=1
  171. "autocmd BufEnter * NERDTreeMirror
  172. "Phase of the Moon calculation
  173. let time = localtime()
  174. let fullday = 86400
  175. let offset = 592500
  176. let period = 2551443
  177. let phase = (time - offset) % period
  178. let phase = phase / fullday
  179. " USEFUL FUNCTIONS
  180. if has("autocmd")
  181. " When editing a file, always jump to the last cursor position
  182. autocmd BufReadPost *
  183. \ if line("'\"") > 0 && line ("'\"") <= line("$") |
  184. \ exe "normal! g'\"" |
  185. \ endif
  186. endif
  187. " specific stuffs
  188. " no tabexpand for makefiles
  189. autocmd FileType make setlocal noexpandtab
  190. "" Neocomplete
  191. "" Disable AutoComplPop.
  192. "let g:acp_enableAtStartup = 0
  193. "" Use neocomplete.
  194. "let g:neocomplete#enable_at_startup = 1
  195. "" Use smartcase.
  196. "let g:neocomplete#enable_smart_case = 1
  197. "" Set minimum syntax keyword length.
  198. "let g:neocomplete#sources#syntax#min_keyword_length = 3
  199. "let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
  200. "
  201. "" Define dictionary.
  202. "let g:neocomplete#sources#dictionary#dictionaries = {
  203. " \ 'default' : '',
  204. " \ 'scheme' : $HOME.'/.gosh_completions'
  205. " \ }
  206. "
  207. "" Define keyword.
  208. "if !exists('g:neocomplete#keyword_patterns')
  209. " let g:neocomplete#keyword_patterns = {}
  210. "endif
  211. "let g:neocomplete#keyword_patterns['default'] = '\h\w*'
  212. "
  213. "" Plugin key-mappings.
  214. "inoremap <expr><C-g> neocomplete#undo_completion()
  215. "inoremap <expr><C-l> neocomplete#complete_common_string()
  216. "
  217. "" Recommended key-mappings.
  218. "" <CR>: close popup and save indent.
  219. "inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
  220. "function! s:my_cr_function()
  221. " return (pumvisible() ? "\<C-y>" : "" ) . "\<CR>"
  222. " " For no inserting <CR> key.
  223. " "return pumvisible() ? "\<C-y>" : "\<CR>"
  224. "endfunction
  225. "" <TAB>: completion.
  226. "inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
  227. "" <C-h>, <BS>: close popup and delete backword char.
  228. "inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
  229. "inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
  230. "" Close popup by <Space>.
  231. ""inoremap <expr><Space> pumvisible() ? "\<C-y>" : "\<Space>"
  232. "
  233. "" AutoComplPop like behavior.
  234. ""let g:neocomplete#enable_auto_select = 1
  235. "
  236. "" Enable omni completion.
  237. "autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
  238. "autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
  239. "autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
  240. "autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
  241. "
  242. "" Enable heavy omni completion.
  243. "if !exists('g:neocomplete#sources#omni#input_patterns')
  244. " let g:neocomplete#sources#omni#input_patterns = {}
  245. "endif
  246. ""let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
  247. ""let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
  248. ""let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
  249. "
  250. "" For perlomni.vim setting.
  251. "" https://github.com/c9s/perlomni.vim
  252. "let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
  253. "
  254. "
  255. "Load language specific config file
  256. "autocmd BufRead,BufNewFile,FileReadPost *.py source ~/.vimrc.python