]>
Commit | Line | Data |
---|---|---|
1 | " ---------- Init, config, backup --------------- | |
2 | " Respect XDG directories (more below for cache) | |
3 | set viminfo+='1000,n$XDG_STATE_HOME/vim/viminfo | |
4 | set runtimepath=$XDG_DATA_HOME/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$XDG_DATA_HOME/vim/after | |
5 | ||
6 | " Run :PlugInstall after adding plugins there | |
7 | call plug#begin(expand($XDG_DATA_HOME) . '/vim/plugged') | |
8 | ||
9 | Plug 'vim-scripts/cecutil' | |
10 | Plug 'vim-scripts/LargeFile' | |
11 | Plug 'vim-scripts/Align' | |
12 | Plug 'vim-scripts/AutoAlign' | |
13 | Plug 'jamessan/vim-gnupg' | |
14 | Plug 'vim-scripts/taglist.vim' | |
15 | Plug 'chrisbra/csv.vim' | |
16 | Plug 'mustache/vim-mustache-handlebars' | |
17 | Plug 'cakebaker/scss-syntax.vim' | |
18 | Plug 'tpope/vim-bundler' | |
19 | Plug 'tpope/vim-rails' | |
20 | Plug 'ledger/vim-ledger' | |
21 | Plug 'beyondwords/vim-twig' | |
22 | Plug 'scrooloose/nerdtree' | |
23 | Plug 'kien/ctrlp.vim' | |
24 | Plug 'rodjek/vim-puppet' | |
25 | Plug 'szw/vim-tags' | |
26 | Plug 'neomutt/neomutt.vim' | |
27 | Plug 'kchmck/vim-coffee-script' | |
28 | Plug 'digitaltoad/vim-pug' | |
29 | Plug 'vim-scripts/slapd.vim' | |
30 | Plug 'vimwiki/vimwiki', { 'branch': 'dev' } | |
31 | Plug 'vim-vdebug/vdebug' | |
32 | Plug 'tpope/vim-fugitive' | |
33 | Plug 'tpope/vim-rhubarb' | |
34 | Plug 'shumphrey/fugitive-gitlab.vim' | |
35 | Plug 'tomlion/vim-solidity' | |
36 | Plug 'chrisbra/SudoEdit.vim' | |
37 | Plug 'Chiel92/vim-autoformat' | |
38 | Plug 'pearofducks/ansible-vim' | |
39 | Plug 'juliosueiras/vim-terraform-completion' | |
40 | Plug 'sjl/gundo.vim' | |
41 | Plug 'LnL7/vim-nix' | |
42 | Plug 'purescript-contrib/purescript-vim' | |
43 | Plug 'vmchale/dhall-vim' | |
44 | Plug 'junegunn/fzf' | |
45 | ||
46 | call plug#end() | |
47 | ||
48 | " Charge automatiquement les ftplugins/*.vim selon le type de fichier | |
49 | filetype plugin on | |
50 | " Charge automatiquement les indent/*.vim selon le type de fichier | |
51 | filetype indent on | |
52 | ||
53 | " Pour que vim garde une copie de sauvegarde des fichiers modifiés. | |
54 | set backup | |
55 | """ Copied from /usr/share/vim/vimfiles/archlinux.vim | |
56 | " Move temporary files to a secure location to protect against CVE-2017-1000382 | |
57 | if exists('$XDG_CACHE_HOME') | |
58 | let &g:directory=$XDG_CACHE_HOME | |
59 | else | |
60 | let &g:directory=$HOME . '/.cache' | |
61 | endif | |
62 | let g:ctrlp_cache_dir=&g:directory . '/vim/ctrlp//' | |
63 | let &g:undodir=&g:directory . '/vim/undo//' | |
64 | let &g:backupdir=&g:directory . '/vim/backup//' | |
65 | let g:vim_tags_cache_dir = &g:directory . '/vim/ctags//' | |
66 | let &g:directory.='/vim/swap//' | |
67 | " Create directories if they doesn't exist | |
68 | if ! isdirectory($XDG_STATE_HOME . '/vim') | |
69 | silent! call mkdir($XDG_STATE_HOME . '/vim') | |
70 | endif | |
71 | if ! isdirectory(expand(&g:directory)) | |
72 | silent! call mkdir(expand(&g:directory), 'p', 0700) | |
73 | endif | |
74 | if ! isdirectory(expand(&g:backupdir)) | |
75 | silent! call mkdir(expand(&g:backupdir), 'p', 0700) | |
76 | endif | |
77 | if ! isdirectory(expand(&g:undodir)) | |
78 | silent! call mkdir(expand(&g:undodir), 'p', 0700) | |
79 | endif | |
80 | if ! isdirectory(expand(g:vim_tags_cache_dir)) | |
81 | silent! call mkdir(expand(g:vim_tags_cache_dir), 'p', 0700) | |
82 | endif | |
83 | """ /Copied from /usr/share/vim/vimfiles/archlinux.vim | |
84 | ||
85 | ||
86 | " Ne pas sauver un backup spécial pour les fichiers réseau | |
87 | let g:netrw_dirhistmax = 0 | |
88 | ||
89 | " ---------- Mappings --------------------------- | |
90 | " map : Normal, Visual, Select, Operator-pending | |
91 | " map! : Insert and Command-line | |
92 | ||
93 | " Le BackSpace fonctionne aussi en mode normal. | |
94 | map <BS> X | |
95 | ||
96 | " Les Control-flèches | |
97 | map <ESC>[1;5A <C-Up> | |
98 | map! <ESC>[1;5A <C-Up> | |
99 | map <ESC>[1;5B <C-Down> | |
100 | map! <ESC>[1;5B <C-Down> | |
101 | map <ESC>[1;5C <C-Right> | |
102 | map! <ESC>[1;5C <C-Right> | |
103 | map <ESC>[1;5D <C-Left> | |
104 | map! <ESC>[1;5D <C-Left> | |
105 | ||
106 | map <S-Up> { | |
107 | map! <S-Up> <C-O>{ | |
108 | map <S-Down> } | |
109 | map! <S-Down> <C-O>} | |
110 | ||
111 | ||
112 | " ---------- Comportement à la frappe ----------- | |
113 | " <BS> passe à travers l'indentation, les fins de ligne et le début du "insert" | |
114 | set backspace=indent,eol,start | |
115 | ||
116 | " '<BS>e écrit un é (sinon : ctrl+K ' e) | |
117 | " set digraph | |
118 | ||
119 | " La taille d'une ligne, pour la frappe au kilomètre. | |
120 | " Permet 4 niveaux de 'citation' pour les mails/forum | |
121 | set textwidth=72 | |
122 | " set textwidth=80 | |
123 | ||
124 | " Les touches qui font passer à la ligne suivante/précédente. backspace (b), | |
125 | " espace (s), flèches (<,>,[,]). | |
126 | set whichwrap=b,s,<,>,[,] | |
127 | ||
128 | " Ne pas mettre deux espaces après la ponctuation quand on "join" deux lignes | |
129 | set nojoinspaces | |
130 | ||
131 | " Quand on tape un ), vim montre furtivement le ( correspondant. | |
132 | set showmatch | |
133 | ||
134 | " Les options de formatage. | |
135 | set formatoptions=tcq2 | |
136 | ||
137 | ||
138 | " ---------- Recherche -------------------------- | |
139 | " Pour voir tous les matchs d'une recherche | |
140 | set hlsearch | |
141 | ||
142 | " Pour que les matchs soient affichés pendant que vous tapez le mot recherché | |
143 | set incsearch | |
144 | ||
145 | " On ignore la casse des caractères dans les recherches de chaînes en | |
146 | " minuscules; par contre, dès qu'une lettre est en majuscule, on tient compte | |
147 | " de la casse de toute la chaîne. | |
148 | " Pendant la recherche : \c pour ignorer quand même, \C pour case-sensitive | |
149 | set ignorecase | |
150 | set smartcase | |
151 | ||
152 | ||
153 | " ---------- Fichiers --------------------------- | |
154 | " Pour une complétion automatique des noms de fichiers | |
155 | set wildmenu | |
156 | ||
157 | " La façon dont la complétion présente les choix. | |
158 | set wildmode=longest,list:longest,full | |
159 | ||
160 | " La complétion automatique ignore les fichiers suivants. | |
161 | set suffixes=.bak.o.aux.dvi.log.toc.tof | |
162 | ||
163 | ||
164 | " ---------- Buffers ---------------------------- | |
165 | " On veut pouvoir rendre invisible un buffer | |
166 | set hidden | |
167 | ||
168 | " Pour éviter de trop ralentir en faisant défiler le texte pendant l'exécution | |
169 | " des macros. | |
170 | set lazyredraw | |
171 | ||
172 | ||
173 | " ----------- Interactions ---------------------- | |
174 | " On affiche en permanence les numéros de ligne et de colonne. | |
175 | set ruler | |
176 | ||
177 | " Pour ne pas se faire bipper tout le temps. | |
178 | set noerrorbells | |
179 | set visualbell t_vb= | |
180 | ||
181 | " Pour avoir des messages de vim qui tiennent sur une seule ligne, ce | |
182 | " qui évite d'avoir à presser «Enter» pour voir les messages suivants. | |
183 | set shortmess=filnrxoOt | |
184 | ||
185 | " Quand on tape une commande complexe en mode normal, vim affiche ce que l'on | |
186 | " a déjà tapé | |
187 | set showcmd | |
188 | ||
189 | ||
190 | " ------------ Indentations --------------------- | |
191 | " Conserve l'indentation | |
192 | set autoindent | |
193 | ||
194 | " Remplace les <Tab> par des espaces | |
195 | set expandtab | |
196 | ||
197 | " Nombre d'espaces | |
198 | set shiftwidth=2 | |
199 | set softtabstop=2 | |
200 | ||
201 | " Pour que l'indentation ajuste sur un multiple de 'shiftwidth'. | |
202 | set shiftround | |
203 | ||
204 | " ------------ Folding -------------------------- | |
205 | set foldmethod=indent | |
206 | set foldnestmax=10 | |
207 | set nofoldenable | |
208 | set foldlevel=0 | |
209 | set foldlevelstart=0 | |
210 | ||
211 | ||
212 | " ------------ Auto-commandes ------------------- | |
213 | " On commence par enlever toutes les autocommandes avant de les définir | |
214 | " (pour le cas où ce fichier serait lu plusieurs fois.) | |
215 | autocmd! | |
216 | ||
217 | autocmd BufRead,BufNewFile mutt*[0-9] set nobackup nowritebackup | |
218 | autocmd BufRead,BufNewFile .article.* set filetype=mail nobackup | |
219 | ||
220 | " ledger | |
221 | " Don't load ftplugin for ledger | |
222 | " autocmd BufReadPre,BufNewFile *ledger* let b:did_ftplugin = 1 | |
223 | autocmd FileType ledger set textwidth=0 | |
224 | let g:ledger_main = '~/.ledger/perso' | |
225 | ||
226 | autocmd FileType puppet set textwidth=0 | |
227 | ||
228 | " ----------- Coloration syntaxique ------------- | |
229 | syntax enable | |
230 | ||
231 | highlight Comment term=none ctermfg=darkCyan cterm=none | |
232 | highlight Constant term=underline ctermfg=Blue cterm=none | |
233 | highlight Error term=reverse ctermfg=White ctermbg=Red cterm=none | |
234 | highlight Identifier term=none ctermfg=Green cterm=none | |
235 | highlight IncSearch term=reverse ctermfg=Blue ctermbg=White | |
236 | highlight Operator term=none ctermfg=darkGray cterm=bold | |
237 | highlight PreProc term=underline ctermfg=Magenta cterm=none | |
238 | highlight Search term=reverse cterm=reverse | |
239 | highlight Special term=bold ctermfg=Blue cterm=bold | |
240 | highlight Statement term=bold ctermfg=Red cterm=none | |
241 | highlight Todo term=standout ctermfg=White ctermbg=Green cterm=bold | |
242 | highlight Type term=bold ctermfg=Brown cterm=none | |
243 | ||
244 | highlight link Delimiter Operator | |
245 | highlight link SpecialChar Special | |
246 | ||
247 | " lignes "foldées" | |
248 | highlight Folded term=standout ctermfg=White ctermbg=Blue cterm=bold | |
249 | ||
250 | " Pour les diffs (commande vimdiff). | |
251 | highlight DiffAdd term=bold ctermfg=Green ctermbg=none cterm=bold | |
252 | highlight DiffChange term=bold ctermfg=Cyan ctermbg=none | |
253 | highlight DiffDelete term=bold ctermfg=Red ctermbg=none cterm=bold | |
254 | highlight DiffText term=standout ctermfg=White ctermbg=Cyan cterm=bold | |
255 | ||
256 | " ------------- Fonctions, commandes, macros ---- | |
257 | " Identer les fichiers (json, xml) | |
258 | function PRangeFunc(command_line, syntax) range | |
259 | if a:firstline==1 && a:lastline==line('$') | |
260 | execute 'set filetype=' . a:syntax | |
261 | execute 'syntax on' | |
262 | endif | |
263 | execute a:firstline . "," . a:lastline . '!' . a:command_line | |
264 | endfunction | |
265 | ||
266 | command -range=% Pjson normal <Esc>`>a<CR><Esc>mb`<i<CR><Esc>ma:'a,'b-1 call PRangeFunc('python -m json.tool', 'json')<CR> | |
267 | command -range=% Pxml normal <Esc>`>a<CR><Esc>mb`<i<CR><Esc>ma:'a,'b-1 call PRangeFunc('xmllint --format --encode UTF8 -', 'xml')<CR> | |
268 | command -range=% Pdeflate normal <Esc>`>a<CR><Esc>mb`<i<CR><Esc>ma:'a,'b-1 call PRangeFunc('python -c "import zlib; import sys; sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))"', '')<CR> | |
269 | command -range=% Pinflate normal <Esc>`>a<CR><Esc>mb`<i<CR><Esc>ma:'a,'b-1 call PRangeFunc('python -c "import zlib; import sys; sys.stdout.buffer.write(zlib.compress(sys.stdin.buffer.read()))"', '')<CR> | |
270 | command! -range=% Pastebin execute <line1> . "," . <line2> . "w !curl -F 'c=@-' https://ptpb.pw" | |
271 | ||
272 | noremap <F3> :Autoformat<CR> | |
273 | vmap <F8> :Pxml<CR> | |
274 | vmap <F9> :Pjson<CR> | |
275 | ||
276 | " gpg-encryptes files | |
277 | let g:GPGPreferArmor=1 | |
278 | let g:GPGDefaultRecipients=["ismael.bouya@normalesup.org"] | |
279 | let g:GPGUsesPipes=1 | |
280 | ||
281 | command Decrypt 1,$!gpg -d -q | |
282 | command Encrypt 1,$!gpg -e -q --armor -r ismael.bouya@normalesup.org | |
283 | command -range=% Runhash s/:\([_a-zA-Z0-9]\+\)\( \+\)=> \( *\)/\1:\2\3/ | |
284 | ||
285 | function! s:DiffWithSaved() | |
286 | let filetype=&ft | |
287 | diffthis | |
288 | vnew | r # | normal! 1Gdd | |
289 | diffthis | |
290 | exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype | |
291 | endfunction | |
292 | command! DiffSaved call s:DiffWithSaved() | |
293 | ||
294 | " Load NERDTree on startup if no file were specified | |
295 | " autocmd StdinReadPre * let s:std_in=1 | |
296 | " autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | |
297 | " Load NERDTree on startup | |
298 | "autocmd VimEnter * NERDTree | wincmd p | |
299 | let g:vim_tags_auto_generate = 1 | |
300 | let g:vim_tags_project_tags_command = "ctags -R {OPTIONS} {DIRECTORY} 2>/dev/null" | |
301 | map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR> | |
302 | map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR> | |
303 | ||
304 | let g:ctrlp_extensions = ['tag', 'buffertag', 'dir', 'undo', 'line'] | |
305 | let g:ctrlp_max_files = 0 | |
306 | set modeline | |
307 | ||
308 | set grepprg=grep\ -rn\ $*\ /dev/null | |
309 | let c_comment_strings=1 | |
310 | if !exists(":DiffOrig") | |
311 | command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis | |
312 | \ | wincmd p | diffthis | |
313 | endif | |
314 | ||
315 | set list | |
316 | set listchars=tab:>-,trail:- | |
317 | let &colorcolumn="80,120" | |
318 | highlight ColorColumn ctermbg=235 guibg=#2c2d27 |