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